@markprompt/web
Advanced tools
Comparing version 0.3.1-beta4 to 0.3.2
@@ -15,2 +15,3 @@ import { OpenAIModelId } from '@markprompt/core'; | ||
iDontKnowMessage: string; | ||
showReferencesImmediatebly: boolean; | ||
completionsUrl: string; | ||
@@ -17,0 +18,0 @@ projectKey: string; |
@@ -26,2 +26,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
this.iDontKnowMessage = I_DONT_KNOW_MESSAGE; | ||
this.showReferencesImmediatebly = true; | ||
this.completionsUrl = MARKPROMPT_COMPLETIONS_URL; | ||
@@ -75,7 +76,7 @@ this.projectKey = ''; | ||
await submitPrompt(this.prompt, this.projectKey, (chunk) => { | ||
this.scrollToBottom(); | ||
this.answer += chunk; | ||
setTimeout(() => this.scrollToBottom(), 50); | ||
}, (references) => { | ||
this.scrollToBottom(); | ||
this.references = references; | ||
setTimeout(() => this.scrollToBottom(), 50); | ||
}, (error) => { | ||
@@ -106,2 +107,5 @@ console.error(error); | ||
render() { | ||
const shouldShowReferences = this.references.length > 0 && | ||
((!this.loading && this.answer.length > 0) || | ||
this.showReferencesImmediatebly); | ||
return html ` | ||
@@ -141,23 +145,22 @@ <div class="root"> | ||
<div class="gradient"></div> | ||
<prose-block class="result" ${ref(this.resultRef)}> | ||
<div class="answer"> | ||
${this.loading && !(this.answer.length > 0) | ||
<prose-block class="result"> | ||
<div class="stacked-result"> | ||
<div class="answer" ${ref(this.resultRef)}> | ||
${this.loading && !(this.answer.length > 0) | ||
? html `<animated-caret class="caret"></animated-caret>` | ||
: nothing} | ||
${until(this.renderMarkdown(this.answer), nothing)} | ||
${this.loading && this.answer.length > 0 | ||
${until(this.renderMarkdown(this.answer), nothing)} | ||
${this.loading && this.answer.length > 0 | ||
? html `<animated-caret class="caret"></animated-caret>` | ||
: nothing} | ||
</div> | ||
${this.answer.length > 0 && this.references.length > 0 | ||
</div> | ||
${shouldShowReferences | ||
? html ` | ||
<div class="references-container"> | ||
<div | ||
class="${classMap({ | ||
'animate-slide-up': !this.loading, | ||
})}" | ||
> | ||
<p>Generated from the following sources:</p> | ||
<div class="references"> | ||
${this.references.map((reference) => { | ||
<div class="references-container"> | ||
<div class="animate-slide-up"> | ||
<div style="margin-bottom: 0.5rem;"> | ||
Generated from the following sources: | ||
</div> | ||
<div class="references"> | ||
${this.references.map((reference) => { | ||
let refInfo = this.idToRefMap | ||
@@ -171,18 +174,18 @@ ? this.idToRefMap[reference] | ||
return html `<a | ||
href="${refInfo.href}" | ||
class="reference-item" | ||
> | ||
${refInfo.label || reference}</a | ||
>`; | ||
href="${refInfo.href}" | ||
class="reference-item" | ||
> | ||
${refInfo.label || reference}</a | ||
>`; | ||
} | ||
return html `<div class="reference-item"> | ||
${reference} | ||
</div>`; | ||
${reference} | ||
</div>`; | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
` | ||
` | ||
: nothing} | ||
<div class="spacer"></div> | ||
</div> | ||
</prose-block> | ||
@@ -260,3 +263,2 @@ </div> | ||
box-sizing: border-box; | ||
border-top: 1px solid var(--border-color); | ||
background-color: var(--result-bg-color); | ||
@@ -272,3 +274,2 @@ scrollbar-width: none; | ||
max-width: 100%; | ||
overflow-y: auto; | ||
scroll-behavior: smooth; | ||
@@ -281,4 +282,19 @@ } | ||
.stacked-result { | ||
box-sizing: border-box; | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
display: flex; | ||
flex-direction: column; | ||
flex: 1; | ||
} | ||
.answer { | ||
padding: 2rem; | ||
overflow-y: auto; | ||
box-sizing: border-box; | ||
flex-grow: 1 !important; | ||
padding: 1rem; | ||
color: var(--text-color); | ||
@@ -300,9 +316,7 @@ } | ||
.spacer { | ||
height: 2rem; | ||
} | ||
.references-container { | ||
flex: none; | ||
box-sizing: border-box; | ||
border-top: 1px solid var(--border-color); | ||
padding: 2rem; | ||
padding: 1rem; | ||
font-size: 0.875rem; | ||
@@ -345,2 +359,6 @@ line-height: 1.25rem; | ||
.spacer { | ||
height: 2rem; | ||
} | ||
@keyframes slide-up { | ||
@@ -374,2 +392,5 @@ from { | ||
__decorate([ | ||
property({ type: Boolean }) | ||
], Markprompt.prototype, "showReferencesImmediatebly", void 0); | ||
__decorate([ | ||
property({ type: String }) | ||
@@ -376,0 +397,0 @@ ], Markprompt.prototype, "completionsUrl", void 0); |
{ | ||
"name": "@markprompt/web", | ||
"version": "0.3.1-beta4", | ||
"version": "0.3.2", | ||
"description": "A web component for adding GPT-4 powered search using the Markprompt API.", | ||
@@ -16,3 +16,3 @@ "author": "Motif", | ||
"type": "git", | ||
"url": "git+https://github.com/motifland/markprompt.git", | ||
"url": "git+https://github.com/motifland/markprompt-js.git", | ||
"directory": "packages/web" | ||
@@ -30,3 +30,3 @@ }, | ||
"dependencies": { | ||
"@markprompt/core": "^0.3.2", | ||
"@markprompt/core": "0.4.0", | ||
"lit": "^2.7.2", | ||
@@ -33,0 +33,0 @@ "rehype-sanitize": "^5.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
0
1
44353
10
1057
+ Added@markprompt/core@0.4.0(transitive)
- Removed@markprompt/core@0.3.2(transitive)
Updated@markprompt/core@0.4.0