@blueking/ai-blueking 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21571,6 +21571,9 @@ const tE = {
|
|
|
21571
21571
|
onChangePrompt() {
|
|
21572
21572
|
e("change-prompt", ...arguments);
|
|
21573
21573
|
},
|
|
21574
|
+
onShortcutClick() {
|
|
21575
|
+
e("shortcut-click", ...arguments);
|
|
21576
|
+
},
|
|
21574
21577
|
"onUpdate:model"() {
|
|
21575
21578
|
e("update:model", ...arguments);
|
|
21576
21579
|
},
|
|
@@ -541,4 +541,4 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
541
541
|
margin-bottom: 8px;
|
|
542
542
|
}
|
|
543
543
|
}`;this.styleEle=document.createElement("style"),this.styleEle.textContent=e,document.head.appendChild(this.styleEle)}removeStyle(){this.styleEle&&(this.styleEle.remove(),this.styleEle=null)}}class Qle{constructor(e,n,r,i,o,l){gi(this,"controllerMap");gi(this,"handleEnd");gi(this,"handleError");gi(this,"handleReceiveMessage");gi(this,"handleStart");gi(this,"messages");gi(this,"styleManager");gi(this,"thinkStyleManager");gi(this,"url");this.url=e,this.handleStart=n,this.handleReceiveMessage=r,this.handleEnd=i,this.handleError=o,this.styleManager=new zle,this.thinkStyleManager=new Hle,this.styleManager.addStyle(),this.thinkStyleManager.addStyle(),this.controllerMap={},this.messages=l}destroy(){this.styleManager.removeStyle(),this.thinkStyleManager.removeStyle()}stop(e){var n,r;return(r=(n=this.controllerMap[e])==null?void 0:n.abort)==null||r.call(n),this.handleEnd(e)}async stream(e,n,r){const i=new AbortController;this.controllerMap[n]=i,fetch(this.url,{method:"post",signal:i.signal,headers:{"Content-Type":"application/json",...r},mode:"cors",credentials:"include",body:JSON.stringify(e)}).then(async o=>{const l=o.body.pipeThrough(new window.TextDecoderStream).getReader();let s="";for(;;)try{const{value:u,done:d}=await l.read();if(!o.ok){this.handleError(u||o.statusText,o.status,n);break}if(d){this.handleEnd(n);break}s+=u,s.toString().split(`
|
|
544
|
-
`).forEach(_=>{const g=_.replace("data:","").trim();if(IF(g)){const{event:m,content:E,cover:b,documents:v,result:h,code:N,message:O,elapsed_time:R}=JSON.parse(g);if(h===!1||o.status!==200){this.handleError(O,N,n);return}switch(m){case"text":this.handleReceiveMessage(E,n,b);break;case"reference_doc":const w=Ble(v);this.handleReceiveMessage(w,n,b);break;case"think":const T=this.messages.at(-1),$=Yle((T==null?void 0:T.content)||"",E,R);T&&(T.content=$);break;case"done":this.handleEnd(n,b?E:"");break;case"error":this.handleError(O,N,n);break}}else s=_})}catch(u){const d=u;(d==null?void 0:d.code)!==20&&this.handleError(d.message||"Unknown error",d.code||500,n);break}}).catch(o=>{(o==null?void 0:o.code)!==20&&this.handleError(o.message,o.code,n)}),await this.handleStart(n)}}mQ({prefix:"ai-blueking"});const Vle={name:"AiBlueking",render(t){return t("div",{style:{width:"100%"}})},props:{messages:{default:()=>[],type:Array},prompts:{default:()=>[],type:Array},loading:{default:!1,type:Boolean},headBackground:{default:"linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)",type:String},background:{default:"#f5f7fa",type:String},positionLimit:{default:()=>({top:0,bottom:0,left:0,right:0}),type:Object},sizeLimit:{default:()=>({height:320,width:400}),type:Object},startPosition:{default:()=>({top:window.innerHeight-560,bottom:0,left:window.innerWidth-400,right:0}),type:Object},userPhoto:{default:KI,type:String},logo:{default:"ai-blueking-icon ai-blueking-ai",type:String},name:{default:"",type:String},placeholder:{default:"",type:String},scrollLoading:{default:!1,type:Boolean},scrollLoadingEnd:{default:!0,type:Boolean},alert:{default:"",type:[String,Object]},models:{default:void 0,type:Array},model:{default:"",type:String},isShow:{type:Boolean},shortcuts:{default:()=>Hc,type:Array},enablePopup:{default:!0,type:Boolean}},data(){return{app:null,unWatchStack:[]}},watch:{messages:{handler(){setTimeout(()=>{const t=document.querySelector(".ai-blueking-messages");(t==null?void 0:t.scrollTop)+(t==null?void 0:t.clientHeight)+100>=(t==null?void 0:t.scrollHeight)&&(t.scrollTop=t.scrollHeight)},10)},deep:!0}},created(){const t=this.$emit.bind(this);let e=null,n=null;const r=this;this.app=Bp({render(){return e=this,n=Zt(Fle,{messages:JSON.parse(JSON.stringify(r.messages)),prompts:r.prompts,loading:r.loading,headBackground:r.headBackground,background:r.background,positionLimit:r.positionLimit,sizeLimit:r.sizeLimit,userPhoto:r.userPhoto,logo:r.logo,name:r.name,placeholder:r.placeholder,startPosition:r.startPosition,scrollLoading:r.scrollLoading,scrollLoadingEnd:r.scrollLoadingEnd,alert:r.alert,models:r.models,model:r.model,isShow:r.isShow,shortcuts:r.shortcuts,enablePopup:r.enablePopup,onClear(){t("clear",...arguments)},onClose(){t("close",...arguments)},onSend(){t("send",...arguments)},onChoosePrompt(){t("choose-prompt",...arguments)},onStop(){t("stop",...arguments)},onScrollLoad(){t("scroll-load",...arguments)},onAiClick(){t("ai-click",...arguments)},onChangePrompt(){t("change-prompt",...arguments)},"onUpdate:model"(){t("update:model",...arguments)},"onUpdate:isShow"(){t("update:isShow",...arguments),t("showDialog",...arguments)},...r.$attrs}),n}}),this.unWatchStack=Object.keys(this.$props).map(i=>this.$watch(i,()=>{e.$forceUpdate()},{deep:!0})),this.setInputMessage=i=>{n.component.exposed.setInputMessage(i)},this.quickActions=(i,o)=>{n.component.exposed.quickActions(i,o)}},mounted(){var t;(t=this.app)==null||t.mount(this.$el)},beforeDestroy(){var t;this.unWatchStack.forEach(e=>e==null?void 0:e()),(t=this.app)==null||t.unmount()}};return Qr.ChatHelper=Qle,Qr.MessageStatus=Id,Qr.RoleType=Ky,Qr.default=Vle,Object.defineProperties(Qr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Qr}({});
|
|
544
|
+
`).forEach(_=>{const g=_.replace("data:","").trim();if(IF(g)){const{event:m,content:E,cover:b,documents:v,result:h,code:N,message:O,elapsed_time:R}=JSON.parse(g);if(h===!1||o.status!==200){this.handleError(O,N,n);return}switch(m){case"text":this.handleReceiveMessage(E,n,b);break;case"reference_doc":const w=Ble(v);this.handleReceiveMessage(w,n,b);break;case"think":const T=this.messages.at(-1),$=Yle((T==null?void 0:T.content)||"",E,R);T&&(T.content=$);break;case"done":this.handleEnd(n,b?E:"");break;case"error":this.handleError(O,N,n);break}}else s=_})}catch(u){const d=u;(d==null?void 0:d.code)!==20&&this.handleError(d.message||"Unknown error",d.code||500,n);break}}).catch(o=>{(o==null?void 0:o.code)!==20&&this.handleError(o.message,o.code,n)}),await this.handleStart(n)}}mQ({prefix:"ai-blueking"});const Vle={name:"AiBlueking",render(t){return t("div",{style:{width:"100%"}})},props:{messages:{default:()=>[],type:Array},prompts:{default:()=>[],type:Array},loading:{default:!1,type:Boolean},headBackground:{default:"linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)",type:String},background:{default:"#f5f7fa",type:String},positionLimit:{default:()=>({top:0,bottom:0,left:0,right:0}),type:Object},sizeLimit:{default:()=>({height:320,width:400}),type:Object},startPosition:{default:()=>({top:window.innerHeight-560,bottom:0,left:window.innerWidth-400,right:0}),type:Object},userPhoto:{default:KI,type:String},logo:{default:"ai-blueking-icon ai-blueking-ai",type:String},name:{default:"",type:String},placeholder:{default:"",type:String},scrollLoading:{default:!1,type:Boolean},scrollLoadingEnd:{default:!0,type:Boolean},alert:{default:"",type:[String,Object]},models:{default:void 0,type:Array},model:{default:"",type:String},isShow:{type:Boolean},shortcuts:{default:()=>Hc,type:Array},enablePopup:{default:!0,type:Boolean}},data(){return{app:null,unWatchStack:[]}},watch:{messages:{handler(){setTimeout(()=>{const t=document.querySelector(".ai-blueking-messages");(t==null?void 0:t.scrollTop)+(t==null?void 0:t.clientHeight)+100>=(t==null?void 0:t.scrollHeight)&&(t.scrollTop=t.scrollHeight)},10)},deep:!0}},created(){const t=this.$emit.bind(this);let e=null,n=null;const r=this;this.app=Bp({render(){return e=this,n=Zt(Fle,{messages:JSON.parse(JSON.stringify(r.messages)),prompts:r.prompts,loading:r.loading,headBackground:r.headBackground,background:r.background,positionLimit:r.positionLimit,sizeLimit:r.sizeLimit,userPhoto:r.userPhoto,logo:r.logo,name:r.name,placeholder:r.placeholder,startPosition:r.startPosition,scrollLoading:r.scrollLoading,scrollLoadingEnd:r.scrollLoadingEnd,alert:r.alert,models:r.models,model:r.model,isShow:r.isShow,shortcuts:r.shortcuts,enablePopup:r.enablePopup,onClear(){t("clear",...arguments)},onClose(){t("close",...arguments)},onSend(){t("send",...arguments)},onChoosePrompt(){t("choose-prompt",...arguments)},onStop(){t("stop",...arguments)},onScrollLoad(){t("scroll-load",...arguments)},onAiClick(){t("ai-click",...arguments)},onChangePrompt(){t("change-prompt",...arguments)},onShortcutClick(){t("shortcut-click",...arguments)},"onUpdate:model"(){t("update:model",...arguments)},"onUpdate:isShow"(){t("update:isShow",...arguments),t("showDialog",...arguments)},...r.$attrs}),n}}),this.unWatchStack=Object.keys(this.$props).map(i=>this.$watch(i,()=>{e.$forceUpdate()},{deep:!0})),this.setInputMessage=i=>{n.component.exposed.setInputMessage(i)},this.quickActions=(i,o)=>{n.component.exposed.quickActions(i,o)}},mounted(){var t;(t=this.app)==null||t.mount(this.$el)},beforeDestroy(){var t;this.unWatchStack.forEach(e=>e==null?void 0:e()),(t=this.app)==null||t.unmount()}};return Qr.ChatHelper=Qle,Qr.MessageStatus=Id,Qr.RoleType=Ky,Qr.default=Vle,Object.defineProperties(Qr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Qr}({});
|
|
@@ -459,4 +459,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
459
459
|
margin-bottom: 8px;
|
|
460
460
|
}
|
|
461
461
|
}`;this.styleEle=document.createElement("style"),this.styleEle.textContent=t,document.head.appendChild(this.styleEle)}removeStyle(){this.styleEle&&(this.styleEle.remove(),this.styleEle=null)}}class dO{constructor(t,n,r,i,o,l){Ft(this,"controllerMap");Ft(this,"handleEnd");Ft(this,"handleError");Ft(this,"handleReceiveMessage");Ft(this,"handleStart");Ft(this,"messages");Ft(this,"styleManager");Ft(this,"thinkStyleManager");Ft(this,"url");this.url=t,this.handleStart=n,this.handleReceiveMessage=r,this.handleEnd=i,this.handleError=o,this.styleManager=new sO,this.thinkStyleManager=new uO,this.styleManager.addStyle(),this.thinkStyleManager.addStyle(),this.controllerMap={},this.messages=l}destroy(){this.styleManager.removeStyle(),this.thinkStyleManager.removeStyle()}stop(t){var n,r;return(r=(n=this.controllerMap[t])==null?void 0:n.abort)==null||r.call(n),this.handleEnd(t)}async stream(t,n,r){const i=new AbortController;this.controllerMap[n]=i,fetch(this.url,{method:"post",signal:i.signal,headers:{"Content-Type":"application/json",...r},mode:"cors",credentials:"include",body:JSON.stringify(t)}).then(async o=>{const l=o.body.pipeThrough(new window.TextDecoderStream).getReader();let a="";for(;;)try{const{value:s,done:c}=await l.read();if(!o.ok){this.handleError(s||o.statusText,o.status,n);break}if(c){this.handleEnd(n);break}a+=s,a.toString().split(`
|
|
462
|
-
`).forEach(d=>{const v=d.replace("data:","").trim();if(d4(v)){const{event:f,content:b,cover:g,documents:k,result:m,code:E,message:B,elapsed_time:S}=JSON.parse(v);if(m===!1||o.status!==200){this.handleError(B,E,n);return}switch(f){case"text":this.handleReceiveMessage(b,n,g);break;case"reference_doc":const P=oO(k);this.handleReceiveMessage(P,n,g);break;case"think":const D=this.messages.at(-1),Y=cO((D==null?void 0:D.content)||"",b,S);D&&(D.content=Y);break;case"done":this.handleEnd(n,g?b:"");break;case"error":this.handleError(B,E,n);break}}else a=d})}catch(s){const c=s;(c==null?void 0:c.code)!==20&&this.handleError(c.message||"Unknown error",c.code||500,n);break}}).catch(o=>{(o==null?void 0:o.code)!==20&&this.handleError(o.message,o.code,n)}),await this.handleStart(n)}}e8({prefix:"ai-blueking"});const fO={name:"AiBlueking",render(e){return e("div",{style:{width:"100%"}})},props:{messages:{default:()=>[],type:Array},prompts:{default:()=>[],type:Array},loading:{default:!1,type:Boolean},headBackground:{default:"linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)",type:String},background:{default:"#f5f7fa",type:String},positionLimit:{default:()=>({top:0,bottom:0,left:0,right:0}),type:Object},sizeLimit:{default:()=>({height:320,width:400}),type:Object},startPosition:{default:()=>({top:window.innerHeight-560,bottom:0,left:window.innerWidth-400,right:0}),type:Object},userPhoto:{default:Fu,type:String},logo:{default:"ai-blueking-icon ai-blueking-ai",type:String},name:{default:"",type:String},placeholder:{default:"",type:String},scrollLoading:{default:!1,type:Boolean},scrollLoadingEnd:{default:!0,type:Boolean},alert:{default:"",type:[String,Object]},models:{default:void 0,type:Array},model:{default:"",type:String},isShow:{type:Boolean},shortcuts:{default:()=>Yi,type:Array},enablePopup:{default:!0,type:Boolean}},data(){return{app:null,unWatchStack:[]}},watch:{messages:{handler(){setTimeout(()=>{const e=document.querySelector(".ai-blueking-messages");(e==null?void 0:e.scrollTop)+(e==null?void 0:e.clientHeight)+100>=(e==null?void 0:e.scrollHeight)&&(e.scrollTop=e.scrollHeight)},10)},deep:!0}},created(){const e=this.$emit.bind(this);let t=null,n=null;const r=this;this.app=p.createApp({render(){return t=this,n=p.h(iO,{messages:JSON.parse(JSON.stringify(r.messages)),prompts:r.prompts,loading:r.loading,headBackground:r.headBackground,background:r.background,positionLimit:r.positionLimit,sizeLimit:r.sizeLimit,userPhoto:r.userPhoto,logo:r.logo,name:r.name,placeholder:r.placeholder,startPosition:r.startPosition,scrollLoading:r.scrollLoading,scrollLoadingEnd:r.scrollLoadingEnd,alert:r.alert,models:r.models,model:r.model,isShow:r.isShow,shortcuts:r.shortcuts,enablePopup:r.enablePopup,onClear(){e("clear",...arguments)},onClose(){e("close",...arguments)},onSend(){e("send",...arguments)},onChoosePrompt(){e("choose-prompt",...arguments)},onStop(){e("stop",...arguments)},onScrollLoad(){e("scroll-load",...arguments)},onAiClick(){e("ai-click",...arguments)},onChangePrompt(){e("change-prompt",...arguments)},"onUpdate:model"(){e("update:model",...arguments)},"onUpdate:isShow"(){e("update:isShow",...arguments),e("showDialog",...arguments)},...r.$attrs}),n}}),this.unWatchStack=Object.keys(this.$props).map(i=>this.$watch(i,()=>{t.$forceUpdate()},{deep:!0})),this.setInputMessage=i=>{n.component.exposed.setInputMessage(i)},this.quickActions=(i,o)=>{n.component.exposed.quickActions(i,o)}},mounted(){var e;(e=this.app)==null||e.mount(this.$el)},beforeDestroy(){var e;this.unWatchStack.forEach(t=>t==null?void 0:t()),(e=this.app)==null||e.unmount()}};lt.ChatHelper=dO,lt.MessageStatus=ha,lt.RoleType=Tu,lt.default=fO,Object.defineProperties(lt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
462
|
+
`).forEach(d=>{const v=d.replace("data:","").trim();if(d4(v)){const{event:f,content:b,cover:g,documents:k,result:m,code:E,message:B,elapsed_time:S}=JSON.parse(v);if(m===!1||o.status!==200){this.handleError(B,E,n);return}switch(f){case"text":this.handleReceiveMessage(b,n,g);break;case"reference_doc":const P=oO(k);this.handleReceiveMessage(P,n,g);break;case"think":const D=this.messages.at(-1),Y=cO((D==null?void 0:D.content)||"",b,S);D&&(D.content=Y);break;case"done":this.handleEnd(n,g?b:"");break;case"error":this.handleError(B,E,n);break}}else a=d})}catch(s){const c=s;(c==null?void 0:c.code)!==20&&this.handleError(c.message||"Unknown error",c.code||500,n);break}}).catch(o=>{(o==null?void 0:o.code)!==20&&this.handleError(o.message,o.code,n)}),await this.handleStart(n)}}e8({prefix:"ai-blueking"});const fO={name:"AiBlueking",render(e){return e("div",{style:{width:"100%"}})},props:{messages:{default:()=>[],type:Array},prompts:{default:()=>[],type:Array},loading:{default:!1,type:Boolean},headBackground:{default:"linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)",type:String},background:{default:"#f5f7fa",type:String},positionLimit:{default:()=>({top:0,bottom:0,left:0,right:0}),type:Object},sizeLimit:{default:()=>({height:320,width:400}),type:Object},startPosition:{default:()=>({top:window.innerHeight-560,bottom:0,left:window.innerWidth-400,right:0}),type:Object},userPhoto:{default:Fu,type:String},logo:{default:"ai-blueking-icon ai-blueking-ai",type:String},name:{default:"",type:String},placeholder:{default:"",type:String},scrollLoading:{default:!1,type:Boolean},scrollLoadingEnd:{default:!0,type:Boolean},alert:{default:"",type:[String,Object]},models:{default:void 0,type:Array},model:{default:"",type:String},isShow:{type:Boolean},shortcuts:{default:()=>Yi,type:Array},enablePopup:{default:!0,type:Boolean}},data(){return{app:null,unWatchStack:[]}},watch:{messages:{handler(){setTimeout(()=>{const e=document.querySelector(".ai-blueking-messages");(e==null?void 0:e.scrollTop)+(e==null?void 0:e.clientHeight)+100>=(e==null?void 0:e.scrollHeight)&&(e.scrollTop=e.scrollHeight)},10)},deep:!0}},created(){const e=this.$emit.bind(this);let t=null,n=null;const r=this;this.app=p.createApp({render(){return t=this,n=p.h(iO,{messages:JSON.parse(JSON.stringify(r.messages)),prompts:r.prompts,loading:r.loading,headBackground:r.headBackground,background:r.background,positionLimit:r.positionLimit,sizeLimit:r.sizeLimit,userPhoto:r.userPhoto,logo:r.logo,name:r.name,placeholder:r.placeholder,startPosition:r.startPosition,scrollLoading:r.scrollLoading,scrollLoadingEnd:r.scrollLoadingEnd,alert:r.alert,models:r.models,model:r.model,isShow:r.isShow,shortcuts:r.shortcuts,enablePopup:r.enablePopup,onClear(){e("clear",...arguments)},onClose(){e("close",...arguments)},onSend(){e("send",...arguments)},onChoosePrompt(){e("choose-prompt",...arguments)},onStop(){e("stop",...arguments)},onScrollLoad(){e("scroll-load",...arguments)},onAiClick(){e("ai-click",...arguments)},onChangePrompt(){e("change-prompt",...arguments)},onShortcutClick(){e("shortcut-click",...arguments)},"onUpdate:model"(){e("update:model",...arguments)},"onUpdate:isShow"(){e("update:isShow",...arguments),e("showDialog",...arguments)},...r.$attrs}),n}}),this.unWatchStack=Object.keys(this.$props).map(i=>this.$watch(i,()=>{t.$forceUpdate()},{deep:!0})),this.setInputMessage=i=>{n.component.exposed.setInputMessage(i)},this.quickActions=(i,o)=>{n.component.exposed.quickActions(i,o)}},mounted(){var e;(e=this.app)==null||e.mount(this.$el)},beforeDestroy(){var e;this.unWatchStack.forEach(t=>t==null?void 0:t()),(e=this.app)==null||e.unmount()}};lt.ChatHelper=dO,lt.MessageStatus=ha,lt.RoleType=Tu,lt.default=fO,Object.defineProperties(lt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|