@markprompt/web
Advanced tools
Comparing version 0.2.2-beta32 to 0.2.2-beta33
@@ -1,2 +0,2 @@ | ||
var u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var o=(l,p,t,e)=>{for(var i=e>1?void 0:e?y(p,t):p,d=l.length-1,c;d>=0;d--)(c=l[d])&&(i=(e?c(p,t,i):c(i))||i);return e&&i&&u(p,t,i),i};import{LitElement as w,html as n,css as g,nothing as m}from"lit";import{customElement as f,property as s}from"lit/decorators.js";import{classMap as b}from"lit/directives/class-map.js";import{I_DONT_KNOW_MESSAGE as v,MARKPROMPT_COMPLETIONS_URL as x,DEFAULT_MODEL as z,submitPrompt as k}from"@markprompt/core";import{unified as S}from"unified";import $ from"remark-parse";import I from"remark-rehype";import T from"rehype-sanitize";import q from"rehype-stringify";import E from"remark-gfm";import{until as A}from"lit/directives/until.js";import{unsafeHTML as C}from"lit/directives/unsafe-html.js";let r=class extends w{constructor(){super(...arguments);this.model=z;this.iDontKnowMessage=v;this.completionsUrl=x;this.projectKey="";this.dark=!1;this.accentColor="";this.responseStyle="";this.referenceItemStyle="";this.placeholder="Ask me anything\u2026";this.prompt="";this.idToRefMap={};this.loading=!1;this.answer="";this.references=[]}onInput(t){const e=t.target;this.prompt=e.value}scrollToBottom(){const t=this.renderRoot.querySelector("#response");t.scrollTop=t.scrollHeight}getRefFromId(t){}show(){console.log("Show!")}async onSubmit(t){t.preventDefault(),this.prompt!==""&&(this.answer="",this.references=[],this.loading=!0,await k(this.prompt,this.projectKey,e=>{this.scrollToBottom(),this.answer+=e},e=>{this.scrollToBottom(),this.references=e},{model:this.model,iDontKnowMessage:this.iDontKnowMessage,completionsUrl:this.completionsUrl}),this.loading=!1)}async renderMarkdown(t){const e=await S().use($).use(E).use(I,{allowDangerousHtml:!0}).use(T).use(q).process(t);return typeof e.value!="string"?"":C(e.value)}render(){return n` | ||
var u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var r=(l,p,e,o)=>{for(var i=o>1?void 0:o?y(p,e):p,d=l.length-1,c;d>=0;d--)(c=l[d])&&(i=(o?c(p,e,i):c(i))||i);return o&&i&&u(p,e,i),i};import{LitElement as w,html as n,css as g,nothing as m}from"lit";import{customElement as f,property as s}from"lit/decorators.js";import{classMap as b}from"lit/directives/class-map.js";import{I_DONT_KNOW_MESSAGE as v,MARKPROMPT_COMPLETIONS_URL as x,DEFAULT_MODEL as z,submitPrompt as k}from"@markprompt/core";import{unified as S}from"unified";import $ from"remark-parse";import I from"remark-rehype";import T from"rehype-sanitize";import q from"rehype-stringify";import E from"remark-gfm";import{until as A}from"lit/directives/until.js";import{unsafeHTML as R}from"lit/directives/unsafe-html.js";let t=class extends w{constructor(){super(...arguments);this.model=z;this.iDontKnowMessage=v;this.completionsUrl=x;this.projectKey="";this.dark=!1;this.accentColor="";this.responseStyle="";this.referenceItemStyle="";this.placeholder="Ask me anything\u2026";this.prompt="";this.idToRefMap={};this.loading=!1;this.answer="";this.references=[]}onInput(e){const o=e.target;this.prompt=o.value}scrollToBottom(){const e=this.renderRoot.querySelector("#response");e.scrollTop=e.scrollHeight}getRefFromId(e){}clearInputAndFocus(){const e=this.renderRoot.querySelector("#prompt-input");e.value="",e.focus()}async onSubmit(e){e.preventDefault(),this.prompt!==""&&(this.answer="",this.references=[],this.loading=!0,await k(this.prompt,this.projectKey,o=>{this.scrollToBottom(),this.answer+=o},o=>{this.scrollToBottom(),this.references=o},{model:this.model,iDontKnowMessage:this.iDontKnowMessage,completionsUrl:this.completionsUrl}),this.loading=!1)}async renderMarkdown(e){const o=await S().use($).use(E).use(I,{allowDangerousHtml:!0}).use(T).use(q).process(e);return typeof o.value!="string"?"":R(o.value)}render(){return n` | ||
<div class="root"> | ||
@@ -18,2 +18,3 @@ <div class="prompt"> | ||
<input | ||
id="prompt-input" | ||
class="prompt-input" | ||
@@ -54,8 +55,8 @@ type="text" | ||
<div class="references"> | ||
${this.references.map(t=>{let e=this.idToRefMap?this.idToRefMap[t]:void 0;return e||(e=this.getRefFromId(t)),e&&e.href?n`<a | ||
href="${e.href}" | ||
${this.references.map(e=>{let o=this.idToRefMap?this.idToRefMap[e]:void 0;return o||(o=this.getRefFromId(e)),o&&o.href?n`<a | ||
href="${o.href}" | ||
style="color: ${this.accentColor||"#0ea5e9"}" | ||
class="reference-item" | ||
> | ||
${e.label||t}</a | ||
${o.label||e}</a | ||
>`:n`<div | ||
@@ -65,3 +66,3 @@ style="color: ${this.accentColor||"#0ea5e9"}" | ||
> | ||
${t} | ||
${e} | ||
</div>`})} | ||
@@ -75,3 +76,3 @@ </div> | ||
</div> | ||
`}};r.styles=g` | ||
`}};t.styles=g` | ||
.root { | ||
@@ -224,3 +225,3 @@ position: relative; | ||
} | ||
`,o([s({type:String})],r.prototype,"model",2),o([s({type:String})],r.prototype,"iDontKnowMessage",2),o([s({type:String})],r.prototype,"completionsUrl",2),o([s({type:String})],r.prototype,"projectKey",2),o([s({type:Boolean})],r.prototype,"dark",2),o([s({type:String})],r.prototype,"accentColor",2),o([s({type:String})],r.prototype,"responseStyle",2),o([s({type:String})],r.prototype,"referenceItemStyle",2),o([s({type:String})],r.prototype,"placeholder",2),o([s({type:String,state:!0})],r.prototype,"prompt",2),o([s({type:Object})],r.prototype,"idToRefMap",2),o([s({type:Boolean,state:!0})],r.prototype,"loading",2),o([s({type:String,state:!0})],r.prototype,"answer",2),o([s({type:Array,state:!0})],r.prototype,"references",2),r=o([f("markprompt-content")],r);let h=class extends w{render(){return n`<span></span>`}};h.styles=g` | ||
`,r([s({type:String})],t.prototype,"model",2),r([s({type:String})],t.prototype,"iDontKnowMessage",2),r([s({type:String})],t.prototype,"completionsUrl",2),r([s({type:String})],t.prototype,"projectKey",2),r([s({type:Boolean})],t.prototype,"dark",2),r([s({type:String})],t.prototype,"accentColor",2),r([s({type:String})],t.prototype,"responseStyle",2),r([s({type:String})],t.prototype,"referenceItemStyle",2),r([s({type:String})],t.prototype,"placeholder",2),r([s({type:String,state:!0})],t.prototype,"prompt",2),r([s({type:Object})],t.prototype,"idToRefMap",2),r([s({type:Boolean,state:!0})],t.prototype,"loading",2),r([s({type:String,state:!0})],t.prototype,"answer",2),r([s({type:Array,state:!0})],t.prototype,"references",2),t=r([f("markprompt-content")],t);let h=class extends w{render(){return n`<span></span>`}};h.styles=g` | ||
:host { | ||
@@ -249,3 +250,3 @@ display: inline-block; | ||
} | ||
`,h=o([f("animated-caret")],h);let a=class extends w{constructor(){super(...arguments);this.class=""}render(){return n` | ||
`,h=r([f("animated-caret")],h);let a=class extends w{constructor(){super(...arguments);this.class=""}render(){return n` | ||
<div | ||
@@ -890,2 +891,2 @@ class="${b({prose:!0,[this.class]:this.class.length>0})}" | ||
} | ||
`,o([s({type:String})],a.prototype,"class",2),a=o([f("prose-block")],a);export{h as Caret,r as Markprompt,a as ProseBlock}; | ||
`,r([s({type:String})],a.prototype,"class",2),a=r([f("prose-block")],a);export{h as Caret,t as Markprompt,a as ProseBlock}; |
{ | ||
"name": "@markprompt/web", | ||
"version": "0.2.2-beta32", | ||
"version": "0.2.2-beta33", | ||
"description": "A web component for adding GPT-4 powered search using the Markprompt API.", | ||
@@ -5,0 +5,0 @@ "author": "Motif", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
640313
16290