@szjy/ai-coms 0.1.1

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.
@@ -0,0 +1,2 @@
1
+ (function(O,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(O=typeof globalThis<"u"?globalThis:O||self,e(O["szjy-ai-coms"]={},O.Vue))})(this,function(O,e){"use strict";const J="/images/ai-round.png",Q="/images/ai-sqrt.png",W="/images/bars-loading.svg";function Z(t,o=location.href){return new URLSearchParams(new URL(o).search).get(t)}function K(t){return t.startsWith("http://")||t.startsWith("https://")?t:`${location.protocol}//${location.host}${t}`}async function G(t){const o=new URL("http://localhost:11434/api/chat"),r={};Object.keys(r).forEach(s=>{o.searchParams.append(s,r[s])});const c=new Request(o,{mode:"cors",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:"llama3",stream:!0,messages:[{role:"system",content:"全程使用中文回答问题。"},{role:"user",content:t}]})});return fetch(c)}async function X(t,o){const r=new URL(`${location.origin}/spark/v1/chat/completions`),c={};Object.keys(c).forEach(n=>{r.searchParams.append(n,c[n])});const s=new Request(r,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:"generalv4.0Ultra",stream:!0,messages:[{role:"user",content:t}]})});return fetch(s)}async function Y(t,o){const r=new URL(`${location.origin}/siliconflow/v1/chat/completions`),c={};Object.keys(c).forEach(n=>{r.searchParams.append(n,c[n])});const s=new Request(r,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:"Qwen/Qwen1.5-110B-Chat",stream:!0,messages:[{role:"user",content:t}]})});return fetch(s)}async function ee(t,o){const r=new URL(`${location.origin}/moonshot/v1/chat/completions`),c={};Object.keys(c).forEach(n=>{r.searchParams.append(n,c[n])});const s=new Request(r,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:"moonshot-v1-8k",stream:!0,messages:[{role:"system",content:"你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。"},{role:"user",content:t}]})});return fetch(s)}async function te(t,o){const r=new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`),c={};Object.keys(c).forEach(n=>{r.searchParams.append(n,c[n])});const s=new Request(r,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:"qwq-32b-preview",stream:!0,messages:[{role:"system",content:"全程使用中文回答问题"},{role:"user",content:t}]})});return fetch(s)}async function ne(t,o,r,c=""){console.log(12342,o,r);const s=K(c),n=new URL(`${s}/support/${r}/a`),f={};Object.keys(f).forEach(y=>{n.searchParams.append(y,f[y])});const _=new Request(n,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({content:t})});return fetch(_)}const oe=t=>{if(t.startsWith("data:")){const o=t.substring(5).trim();if(o==="[DONE]")return{done:!0};try{return JSON.parse(o)}catch(r){console.error("JSON parsing error:",r)}}return null},re=[{label:"模拟数据模型",modelName:"standard",api:null},{label:"Spark 星火大模型",modelName:"spark",api:X},{label:"Ollama 3 大模型",modelName:"ollama3",api:G},{label:"SiliconFlow 硅基流动大模型",modelName:"siliconflow",api:Y},{label:"Kimi Moonshot 月之暗面大模型",modelName:"moonshot",api:ee},{label:"通义千问大模型",modelName:"dashscope",api:te},{label:"数智建管大模型",modelName:"szjy",api:ne}],U={standard(t,o){let r="";return t instanceof Uint8Array?r=o.decode(t,{stream:!0}):r=t,{content:r}},spark(t){const o=oe(t);return o.done?{done:!0}:{content:o.choices[0].delta.content||""}},siliconflow(t){return this.spark(t)},moonshot(t){return this.spark(t)},dashscope(t){return this.spark(t)},szjy(t){return this.spark(t)},ollama3(t){return{content:JSON.parse(t).message.content}}},q=(t,o,r)=>{const c=t.split(r);return c.slice(0,-1).forEach(s=>{s.trim()!==""&&o.enqueue(s)}),c[c.length-1]},ae=t=>{let o="";return new TransformStream({transform(r,c){if(o+=r,o.trim().startsWith("data:"))o=q(o,c,t);else try{JSON.parse(o),o=q(o,c,t)}catch{c.enqueue(r),o=""}},flush(r){o.trim()!==""&&r.enqueue(o)}})};async function le(t,o){const r=t.api;return r?new Promise(c=>{r(o.text,o.token,o.identifier,o.baseUrl).then(s=>{if(s.body){const n=s.body.pipeThrough(new TextDecoderStream).pipeThrough(ae(`
2
+ `)).getReader();console.log("reader from response:",n),c({error:0,reader:n})}else c({error:1,reader:null})}).catch(s=>{c({error:1,reader:null})})}):{error:1,reader:null}}let R=null;function se(){return R||(window.markdownit?R=new window.markdownit({html:!0,linkify:!0,typographer:!0}):console.log("markdownit is not loaded"),R)}const j=(t,o)=>{const r=t.__vccOpts||t;for(const[c,s]of o)r[c]=s;return r},ie=e.defineComponent({name:"SvgIcon",props:{prefix:{type:String,default:"icon"},name:{type:String,required:!0},color:{type:String,default:"#333"}},setup(t){const o=e.computed(()=>`#${t.prefix}-${t.name}`),r=e.computed(()=>t.name?`svg-icon icon-${t.name}`:"svg-icon");return{symbolId:o,svgClass:r}}}),ce=["xlink:href","fill"];function de(t,o,r,c,s,n){return e.openBlock(),e.createElementBlock("svg",e.mergeProps({class:t.svgClass,"aria-hidden":"true"},t.$attrs),[e.createElementVNode("use",{"xlink:href":t.symbolId,fill:t.color},null,8,ce)],16)}const I=j(ie,[["render",de],["__scopeId","data-v-349f049f"]]),ue=async t=>{if(navigator.clipboard&&navigator.permissions)await navigator.clipboard.writeText(t);else{const o=document.createElement("textArea");o.value=t,o.style.width=0,o.style.position="fixed",o.style.left="-999px",o.style.top="10px",o.setAttribute("readonly","readonly"),document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}},fe=["innerHTML"],me=j({__name:"Previewer",props:{reader:null,model:"szjy",scrollToBottomFn:null,displayText:""},emits:["failed","completed","updating"],setup(t,{expose:o,emit:r}){const{appContext:c}=e.getCurrentInstance(),{$message:s}=c.config.globalProperties,n=t,f=e.ref(n.displayText||""),_=e.ref(""),y=e.ref(!0),b=e.ref(!1),T=e.ref(!!n.displayText),N=r,$=e.ref(null);let x=null;const B=e.computed(()=>R?R.render(f.value):f.value),L=()=>{n.reader&&n.reader.cancel(),b.value=!0,l.value=!1,u(),T.value=!0,N("completed",f.value),y.value=!1,x&&(cancelAnimationFrame(x),x=null)},M=e.computed(()=>`${B.value}`),m=e.ref(!1),d=()=>{m.value=!0},u=()=>{m.value=!1},l=e.ref(!1),a=async()=>{if(!n.reader)return;const w=new TextDecoder("utf-8");for(y.value=!0;!b.value;)try{if(!n.reader){l.value=!0;break}const{value:i,done:h}=await n.reader.read();if(!n.reader){l.value=!0;break}if(h){l.value=!0;break}const v=U[n.model];if(!v)break;const C=v.call(U,i,w);if(C.done){l.value=!0;break}_.value+=C.content,x===null&&S()}catch(i){l.value=!0,console.log(3333,i),N("failed",i),L();break}finally{u()}},g=async()=>{n.scrollToBottomFn&&n.scrollToBottomFn()},p=(w=()=>{},i=()=>{})=>{if(_.value.length>0){const h=_.value.substring(0,10);f.value+=h,_.value=_.value.substring(10),w()}else i()},S=()=>{if(b.value&&x){cancelAnimationFrame(x),x=null,y.value=!1;return}l.value?p(()=>{x=requestAnimationFrame(S),N("updating",null)},()=>{N("completed",f.value),y.value=!1,T.value=!0,e.nextTick(()=>{l.value=!1}),x=null}):(p(),x=requestAnimationFrame(S)),g()};e.watch(()=>n.reader,()=>{n.reader&&a()},{immediate:!0,deep:!0}),e.onUnmounted(()=>{L()}),o({abortReader:L,initializeStart:d,initializeEnd:u}),e.computed(()=>m.value?!0:(!n.reader||!y||f.value,!1));const k=async()=>{try{const w=f.value;await ue(w),s.success("复制成功")}catch(w){console.error("复制失败:",w),s.error("复制失败")}};return(w,i)=>(e.openBlock(),e.createBlock(e.Transition,{name:"fade"},{default:e.withCtx(()=>[M.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"refWrapperContent",ref:$,"text-16":"",class:"w-full h-full overflow-y-auto relative","p-24px":""},[e.createElementVNode("div",{class:"markdown-wrapper",innerHTML:M.value},null,8,fe),T.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"copy-btn-wrapper",onClick:k},[e.createVNode(I,{name:"copy",color:"#666666"}),i[0]||(i[0]=e.createElementVNode("span",{class:"copy-text"},"复制",-1))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)]),_:1}))}},[["__scopeId","data-v-c3f65f53"]]),pe={class:"panel-header"},he={class:"header-actions"},ye={class:"header-title"},ge={class:"action-icons"},we={class:"body-content"},be={key:0,class:"welcome-content"},ve={class:"subtitle"},ke={class:"highlight"},_e={class:"quick-questions"},Se=["onClick"],xe={key:1,class:"message-content user-content"},Ce={class:"panel-footer"},Ee={key:0,src:W,alt:"加载中",class:"loading-icon"},Ne={class:"input-box"},Te=["src"],Ve=j({__name:"ChatPanel",props:{modelValue:{type:Boolean,default:!1},token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"}},emits:["update:modelValue","submit"],setup(t,{emit:o}){const{appContext:r}=e.getCurrentInstance(),{$message:c}=r.config.globalProperties,s=Z("llmName")||"szjy",n=e.computed(()=>re.find(h=>h.modelName===s)),f=t,_=o,y=e.ref(""),b=e.ref(null),T=e.ref(!1),N=e.ref([]),$=e.ref(["什么是AI助理,能做什么?","当前项目的基本情况?","当前项目的进度情况?","当前项目的参建方有哪些?","数智建管平台有哪些功能?能做什么?"]),x=e.ref([]),B=e.ref(!1),L=e.ref(null),M=()=>{e.nextTick(()=>{if(L.value){const h=L.value,v=h.scrollHeight,C=h.scrollTop,P=h.clientHeight;v-C-P<100?h.scrollTop=v:h.scrollTo({top:v})}})},m=e.ref(!1),d=e.computed(()=>m.value?"/images/ai-stop.png":"/images/ai-send.png"),u=(h,v)=>{console.log("onFailedReader",h,v),B.value=!1;const C=w();C&&C.initializeEnd(),c.error("转换失败,请重试"),m.value=!1,setTimeout(()=>{b.value&&b.value.focus()})},l=(h,v)=>{B.value=!1,m.value=!1,M(),v&&N.value[h]&&(N.value[h].displayText=v),setTimeout(()=>{b.value&&b.value.focus()})},a=h=>{m.value=!0},g=()=>{m.value=!1,_("update:modelValue",!1),T.value=!1,N.value=[]},p=e.ref(!1),S=()=>{p.value=!p.value},k=h=>{y.value=h,i()},w=()=>{for(let h=x.value.length-1;h>=0;h--)if(x.value[h])return x.value[h];return null},i=async()=>{if(console.log("stylizingLoading:",B.value),B.value){const E=w();console.log("lastPreviewer:",E),E&&(console.log("abortReader"),E.abortReader());return}if(!y.value.trim()){console.log("no input, return"),b.value.focus();return}N.value.push({type:"user",content:y.value}),m.value=!0,T.value=!0,_("submit",y.value),M();const h=y.value;y.value="";const v=N.value.length;x.value[v]&&x.value[v].initializeStart(),B.value=!0,N.value.push({type:"ai"});const{error:C,reader:P}=await le(n.value,{text:h,token:f.token,identifier:f.identifier,baseUrl:f.baseUrl});if(C){console.log(45455,C),u(v,C);return}P&&(N.value[v].reader=P)};return(h,v)=>{const C=e.resolveComponent("el-icon"),P=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(e.Transition,{name:"slide"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ai-panel",{"drawer-mode":p.value}])},[e.createElementVNode("div",pe,[e.createElementVNode("div",he,[e.createElementVNode("div",ye,e.toDisplayString(t.title),1),e.createElementVNode("div",ge,[e.createVNode(C,{class:"action-icon",onClick:S},{default:e.withCtx(()=>[e.createVNode(I,{name:"drawer-layout",color:"#999999"})]),_:1}),e.createVNode(C,{class:"action-icon",onClick:g},{default:e.withCtx(()=>[e.createVNode(I,{name:"close",color:"#999999"})]),_:1})])])]),e.createElementVNode("div",we,[T.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"chat-messages",ref_key:"messageContainerRef",ref:L},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(E,z)=>(e.openBlock(),e.createElementBlock("div",{key:z,class:e.normalizeClass(["message-item",E.type==="user"?"user-message":"ai-message"])},[E.type==="ai"?(e.openBlock(),e.createBlock(me,{key:0,ref_for:!0,ref:V=>x.value[z]=V,reader:E.reader,"onUpdate:reader":V=>E.reader=V,model:e.unref(s),displayText:E.displayText,scrollToBottomFn:M,onFailed:V=>u(z,V),onCompleted:V=>l(z,V),onUpdating:()=>a()},null,8,["reader","onUpdate:reader","model","displayText","onFailed","onCompleted","onUpdating"])):(e.openBlock(),e.createElementBlock("div",xe,e.toDisplayString(E.content),1))],2))),128))],512)):(e.openBlock(),e.createElementBlock("div",be,[v[2]||(v[2]=e.createElementVNode("div",{class:"title"},[e.createElementVNode("img",{src:Q,alt:"AI助手",class:"panel-icon"}),e.createElementVNode("h3",{class:"title-text"},"Hi, 您好")],-1)),e.createElementVNode("div",ve,[v[1]||(v[1]=e.createTextVNode(" 我是")),e.createElementVNode("span",ke,e.toDisplayString(t.title),1)]),e.createElementVNode("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(E,z)=>(e.openBlock(),e.createElementBlock("div",{key:z,class:"question-item",onClick:V=>k(E)},[e.createElementVNode("span",null,e.toDisplayString(E),1),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(I,{name:"arrow-right",color:"#999999"})]),_:1})],8,Se))),128))])]))]),e.createElementVNode("div",Ce,[m.value?(e.openBlock(),e.createElementBlock("img",Ee)):e.createCommentVNode("",!0),e.createElementVNode("div",Ne,[e.createVNode(P,{modelValue:y.value,"onUpdate:modelValue":v[0]||(v[0]=E=>y.value=E),ref_key:"refInputTextString",ref:b,placeholder:"请输入您的问题",autofocus:"",onKeyup:e.withKeys(i,["enter"])},{append:e.withCtx(()=>[e.createElementVNode("div",{class:"send-icon-box",onClick:i},[e.createElementVNode("img",{src:d.value,alt:"发送",class:"send-icon"},null,8,Te)])]),_:1},8,["modelValue"])])])],2)):e.createCommentVNode("",!0)]),_:1})}}},[["__scopeId","data-v-fe7b1f6c"]]);var H={exports:{}};(function(t,o){(function(r,c){t.exports=c()})(window,function(){return function(r){var c={};function s(n){if(c[n])return c[n].exports;var f=c[n]={i:n,l:!1,exports:{}};return r[n].call(f.exports,f,f.exports,s),f.l=!0,f.exports}return s.m=r,s.c=c,s.d=function(n,f,_){s.o(n,f)||Object.defineProperty(n,f,{enumerable:!0,get:_})},s.r=function(n){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},s.t=function(n,f){if(1&f&&(n=s(n)),8&f||4&f&&typeof n=="object"&&n&&n.__esModule)return n;var _=Object.create(null);if(s.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:n}),2&f&&typeof n!="string")for(var y in n)s.d(_,y,(function(b){return n[b]}).bind(null,y));return _},s.n=function(n){var f=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(f,"a",f),f},s.o=function(n,f){return Object.prototype.hasOwnProperty.call(n,f)},s.p="",s(s.s=0)}([function(r,c,s){function n(m,d,u,l){u.push(m),l.push([].concat(d[m]||[]))}function f(m,d){if(!m)throw new Error("[getMaxDepsChain] dep 参数不能为空");var u=[],l=[],a=[];for(n(m,d,l,a);l.length;){var g=a.pop();if(g&&g.length){var p=g.shift();if(a.push(g),~l.indexOf(p))throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: "+p+", mainStack: "+l);n(p,d,l,a)}else u.push([].concat(l)),l.pop()}return u.reduce(function(S,k){return k.length>S.length?k:S},[])}function _(m){if(!m)throw new Error("[depsParser] 入参不能为空");var d={};m.forEach(function(l){d[l.name]=l.deps||[]});var u=[];return m.forEach(function(l){var a=f(l.name,d).length-1;l.priority=a,u[a]=(u[a]||[]).concat(l)}),u}s.r(c),s.d(c,"loadScript",function(){return $}),s.d(c,"loadScripts",function(){return x}),s.d(c,"dynamicLoadScripts",function(){return B}),s.d(c,"createScriptsLoadIterator",function(){return L}),s.d(c,"loadScriptsQueue",function(){return M}),s.d(c,"getMaxDepsChain",function(){return f}),s.d(c,"depsParser",function(){return _});var y=function(){return(y=Object.assign||function(m){for(var d,u=1,l=arguments.length;u<l;u++)for(var a in d=arguments[u])Object.prototype.hasOwnProperty.call(d,a)&&(m[a]=d[a]);return m}).apply(this,arguments)},b=function(m,d,u,l){return new(u||(u=Promise))(function(a,g){function p(w){try{k(l.next(w))}catch(i){g(i)}}function S(w){try{k(l.throw(w))}catch(i){g(i)}}function k(w){var i;w.done?a(w.value):(i=w.value,i instanceof u?i:new u(function(h){h(i)})).then(p,S)}k((l=l.apply(m,[])).next())})},T=function(m,d){var u,l,a,g,p={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return g={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function S(k){return function(w){return function(i){if(u)throw new TypeError("Generator is already executing.");for(;p;)try{if(u=1,l&&(a=2&i[0]?l.return:i[0]?l.throw||((a=l.return)&&a.call(l),0):l.next)&&!(a=a.call(l,i[1])).done)return a;switch(l=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return p.label++,{value:i[1],done:!1};case 5:p.label++,l=i[1],i=[0];continue;case 7:i=p.ops.pop(),p.trys.pop();continue;default:if(a=p.trys,!((a=a.length>0&&a[a.length-1])||i[0]!==6&&i[0]!==2)){p=0;continue}if(i[0]===3&&(!a||i[1]>a[0]&&i[1]<a[3])){p.label=i[1];break}if(i[0]===6&&p.label<a[1]){p.label=a[1],a=i;break}if(a&&p.label<a[2]){p.label=a[2],p.ops.push(i);break}a[2]&&p.ops.pop(),p.trys.pop();continue}i=d.call(m,p)}catch(h){i=[6,h],l=0}finally{u=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([k,w])}}},N=function(m){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d,u=m[Symbol.asyncIterator];return u?u.call(m):(m=typeof __values=="function"?__values(m):m[Symbol.iterator](),d={},l("next"),l("throw"),l("return"),d[Symbol.asyncIterator]=function(){return this},d);function l(a){d[a]=m[a]&&function(g){return new Promise(function(p,S){(function(k,w,i,h){Promise.resolve(h).then(function(v){k({value:v,done:i})},w)})(p,S,(g=m[a](g)).done,g.value)})}}};function $(m,d){return d===void 0&&(d=!1),new Promise(function(u,l){var a=d?document.head:document.body,g=document.createElement("script");g.type="text/javascript",g.src=m,g.crossOrigin="anonymous",g.onreadystatechange=u,g.onload=u,g.onerror=l,a.appendChild(g)})}var x=function(m,d){return d===void 0&&(d={}),b(void 0,void 0,void 0,function(){var u,l,a,g,p;return T(this,function(S){switch(S.label){case 0:return u=d.baseUrl,l=u===void 0?"":u,a=d.lastLoadResult,g=d.inHead,p=g!==void 0&&g,[4,Promise.all(m.map(function(k){return b(void 0,void 0,void 0,function(){var w,i,h,v,C,P,E,z;return T(this,function(V){switch(V.label){case 0:return w=k.name,i=k.path,h=k.deps,(E={})[w]=!0,v=E,(z={})[w]=!1,C=z,window[w]?[2,v]:[3,1];case 1:return P=!0,h&&a&&[].concat(h).forEach(function(je){a[je]!==!1&&(P=!0)}),P?[4,$(i.indexOf("http")===0||i.indexOf("//:")===0?i:l+i,p).then(function(){return v}).catch(function(){return C})]:[3,3];case 2:return[2,V.sent()];case 3:return[2,C]}})})}))];case 1:return[2,S.sent()]}})})},B=function(m,d){return d===void 0&&(d={}),function(){var u=[].concat(_(m));return{next:function(){if(u.length){var l=u.shift();return x(l,d).then(function(a){return{value:a,done:!1}})}return Promise.resolve({done:!0})}}}},L=function(m,d){var u;return d===void 0&&(d={}),(u={})[Symbol.asyncIterator]=B(m,d),u},M=function(m,d){return d===void 0&&(d={}),b(void 0,void 0,void 0,function(){var u,l,a,g,p,S;return T(this,function(k){switch(k.label){case 0:k.trys.push([0,5,6,11]),u=N(L(m,d)),k.label=1;case 1:return[4,u.next()];case 2:if((l=k.sent()).done)return[3,4];a=l.value,d.lastLoadResult=d.lastLoadResult||{},console.log("current load: ",a),a.forEach(function(w){d.lastLoadResult=y(y({},d.lastLoadResult),w)}),k.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return g=k.sent(),p={error:g},[3,11];case 6:return k.trys.push([6,,9,10]),l&&!l.done&&(S=u.return)?[4,S.call(u)]:[3,8];case 7:k.sent(),k.label=8;case 8:return[3,10];case 9:if(p)throw p.error;return[7];case 10:return[7];case 11:return[2,d.lastLoadResult]}})})}}])})})(H);var Be=H.exports;const Le={key:0,class:"ai-assistant"},Pe={name:"AiChat"},Oe=e.defineComponent({...Pe,props:{token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"}},setup(t){const o=e.ref(!1),r=e.ref(!1),c=()=>{o.value=!o.value},s=()=>{r.value=!0,o.value=!1},n=y=>{console.log("用户输入:",y)},f=[{name:"markdownit",path:"markdown-it.min.js"},{name:"hljs",path:"highlight.11.11.1.min.js"}];let _={};return Be.loadScriptsQueue(f,{baseUrl:"/scripts/ai/",lastLoadResult:_,inHead:!1}).then(y=>{if(console.log("load ai deps: ",y),window.markdownit){const b=window.markdownit();console.log("markdownit: ",b),se()}}),(y,b)=>r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Le,[e.createVNode(Ve,{modelValue:o.value,"onUpdate:modelValue":b[0]||(b[0]=T=>o.value=T),onSubmit:n,token:t.token,identifier:t.identifier,baseUrl:t.baseUrl,title:t.title},null,8,["modelValue","token","identifier","baseUrl","title"]),e.createElementVNode("div",{class:"ai-icon",onClick:c},[e.createElementVNode("div",{class:"close-icon",onClick:e.withModifiers(s,["stop"])},b[1]||(b[1]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"8",height:"8"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])),b[2]||(b[2]=e.createElementVNode("img",{src:J,alt:"AI助手"},null,-1)),b[3]||(b[3]=e.createElementVNode("span",{class:"ai-icon-text"},"AI助手",-1))])]))}}),F=j(Oe,[["__scopeId","data-v-4b85f480"]]);if(typeof window<"u"){let t=function(){var o=document.body,r=document.getElementById("__svg__icons__dom__");r||(r=document.createElementNS("http://www.w3.org/2000/svg","svg"),r.style.position="absolute",r.style.width="0",r.style.height="0",r.id="__svg__icons__dom__",r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("xmlns:link","http://www.w3.org/1999/xlink")),r.innerHTML='<symbol viewBox="0 0 16 16" id="icon-arrow-right"><g fill="none" fill-rule="evenodd"><path d="M0 0h16v16H0Z" /><path d="m8.44 3.854.706-.707 4.642 4.641a.3.3 0 0 1 0 .424l-4.642 4.642-.707-.708L12.086 8.5H2v-1h10.086L8.439 3.854Z" fill="currentColor" fill-rule="nonzero" /></g></symbol><symbol viewBox="0 0 24 24" id="icon-close"><g fill="none" fill-rule="evenodd"><path d="M0 0h24v24H0z" /><path d="m12.865 12 3.956-3.955a.61.61 0 1 0-.864-.864L12 11.135 8.043 7.179a.61.61 0 1 0-.863.864L11.134 12 7.18 15.956a.61.61 0 1 0 .864.864L12 12.864l3.957 3.957c.12.12.275.179.432.179a.61.61 0 0 0 .432-1.042L12.865 12Z" fill-opacity=".65" fill="currentColor" fill-rule="nonzero" /></g></symbol><symbol viewBox="0 0 32 32" id="icon-copy"><path fill="currentColor" d="m27.4 14.7-6.1-6.1C21 8.2 20.5 8 20 8h-8c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V16.1c0-.5-.2-1-.6-1.4M20 10l5.9 6H20zm-8 18V10h6v6c0 1.1.9 2 2 2h6v10z" /><path fill="currentColor" d="M6 18H4V4c0-1.1.9-2 2-2h14v2H6z" /></symbol><symbol viewBox="0 0 24 24" id="icon-drawer-layout"><path d="M4.813 4.188a.624.624 0 0 0-.625.625v14.375c0 .345.279.625.625.625h14.375c.345 0 .625-.28.625-.625V4.813a.624.624 0 0 0-.625-.625ZM15.75 5.593h2.656v12.812H15.75V5.594Zm-10.156 0H14.5v12.812H5.594V5.594Z" fill="#999" fill-rule="nonzero" /></symbol>',o.insertBefore(r,o.lastChild)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}const D=Object.freeze(Object.defineProperty({__proto__:null,SzAiChat:F},Symbol.toStringTag,{value:"Module"})),A=function(t){if(!A.installed){A.installed=!0;for(let o in D){const r=Reflect.get(D,o);t.component(r.name,r)}}},ze="0.1.1",Me="Sz";function Re({componentPrefix:t=Me,components:o=[]}={}){const r=[];function c(n,f,_){n.component(t+f)||n.component(t+f,_)}function s(n){r.includes(n)||(r.push(n),o.forEach(f=>{const{name:_,alias:y}=f;console.log(444,_,y),c(n,_,f),y&&y.forEach(b=>{c(n,b,f)})}))}return{version:ze,componentPrefix:t,install:s}}const $e={install(t){A(t)}};O.SzAiChat=F,O.create=Re,O.default=$e,Object.defineProperties(O,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Event Stream 调用大模型接口 Ollama3 (Fetch 调用)
3
+ */
4
+ export declare function createOllama3Stylized(text: any): Promise<Response>;
5
+ /**
6
+ * Event Stream 调用大模型接口 Spark 星火认知大模型 (Fetch 调用)
7
+ */
8
+ export declare function createSparkStylized(text: any, token: any): Promise<Response>;
9
+ /**
10
+ * Event Stream 调用大模型接口 SiliconFlow 硅基流动大模型 (Fetch 调用)
11
+ */
12
+ export declare function createSiliconFlowStylized(text: any, token: any): Promise<Response>;
13
+ /**
14
+ * Event Stream 调用大模型接口 Kimi Moonshot 月之暗面大模型 (Fetch 调用)
15
+ */
16
+ export declare function createKimiMoonshotStylized(text: any, token: any): Promise<Response>;
17
+ /**
18
+ * Event Stream 调用大模型接口 Kimi Moonshot 月之暗面大模型 (Fetch 调用)
19
+ */
20
+ export declare function createDashScopeStylized(text: any, token: any): Promise<Response>;
21
+ /**
22
+ * Event Stream 调用大模型接口 数智交院 月之暗面大模型 (Fetch 调用)
23
+ */
24
+ export declare function createSZJYStylized(text: any, token: any, identifier: any, baseUrl?: string): Promise<Response>;
@@ -0,0 +1 @@
1
+ export declare function generateId(): string;
@@ -0,0 +1 @@
1
+ export declare function loadStyleSheet(url: string, cb?: any): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 从 URL 中获取指定 query 参数的值。
3
+ *
4
+ * @param {string} name - 要获取的 query 参数的名称。
5
+ * @param {string} [url=location.href] - 要解析的 URL。默认为当前页面的 URL。
6
+ * @returns {string | null} - 如果找到该参数,则返回其值;否则返回 null。
7
+ */
8
+ export declare function getQueryByName(name: any, url?: string): string | null;
9
+ export declare function ensureFullURL(url: any): any;
@@ -0,0 +1,3 @@
1
+ import { default as SzAiChat } from './src/index.vue';
2
+
3
+ export { SzAiChat };
@@ -0,0 +1,3 @@
1
+ declare let MarkdownInstance: null;
2
+ export declare function genMarkdownIt(): null;
3
+ export { MarkdownInstance };
@@ -0,0 +1,41 @@
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ token: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ identifier: {
7
+ type: StringConstructor;
8
+ default: string;
9
+ };
10
+ baseUrl: {
11
+ type: StringConstructor;
12
+ default: string;
13
+ };
14
+ title: {
15
+ type: StringConstructor;
16
+ default: string;
17
+ };
18
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
19
+ token: {
20
+ type: StringConstructor;
21
+ default: string;
22
+ };
23
+ identifier: {
24
+ type: StringConstructor;
25
+ default: string;
26
+ };
27
+ baseUrl: {
28
+ type: StringConstructor;
29
+ default: string;
30
+ };
31
+ title: {
32
+ type: StringConstructor;
33
+ default: string;
34
+ };
35
+ }>> & Readonly<{}>, {
36
+ token: string;
37
+ identifier: string;
38
+ baseUrl: string;
39
+ title: string;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
41
+ export default _default;
@@ -0,0 +1,66 @@
1
+ import { createSZJYStylized } from '../../../../api/ai';
2
+
3
+ /**
4
+ * 转义处理响应值为 data: 的 json 字符串
5
+ * 如: 科大讯飞星火、Kimi Moonshot 等大模型的 response
6
+ */
7
+ export declare const parseJsonLikeData: (content: any) => any;
8
+ /**
9
+ * 大模型映射列表
10
+ */
11
+ export declare const LLMTypes: ({
12
+ label: string;
13
+ modelName: string;
14
+ api: null;
15
+ } | {
16
+ label: string;
17
+ modelName: string;
18
+ api: typeof createSZJYStylized;
19
+ })[];
20
+ /**
21
+ * 用于处理不同类型流的值转换器
22
+ */
23
+ export declare const transformStreamValue: {
24
+ standard(readValue: any, textDecoder: any): {
25
+ content: string;
26
+ };
27
+ spark(readValue: any): {
28
+ done: boolean;
29
+ content?: undefined;
30
+ } | {
31
+ content: any;
32
+ done?: undefined;
33
+ };
34
+ siliconflow(readValue: any): {
35
+ done: boolean;
36
+ content?: undefined;
37
+ } | {
38
+ content: any;
39
+ done?: undefined;
40
+ };
41
+ moonshot(readValue: any): {
42
+ done: boolean;
43
+ content?: undefined;
44
+ } | {
45
+ content: any;
46
+ done?: undefined;
47
+ };
48
+ dashscope(readValue: any): {
49
+ done: boolean;
50
+ content?: undefined;
51
+ } | {
52
+ content: any;
53
+ done?: undefined;
54
+ };
55
+ szjy(readValue: any): {
56
+ done: boolean;
57
+ content?: undefined;
58
+ } | {
59
+ content: any;
60
+ done?: undefined;
61
+ };
62
+ ollama3(readValue: any): {
63
+ content: any;
64
+ };
65
+ };
66
+ export declare const splitStream: (splitOn: any) => TransformStream<any, any>;
@@ -0,0 +1 @@
1
+ export declare function createAssistantWriterStylized(llmType: any, data: any): Promise<unknown>;
@@ -0,0 +1 @@
1
+ export * from './AiChat/index';
@@ -0,0 +1,2 @@
1
+ export declare const VERSION: any;
2
+ export declare const COMP_PREFIX = "Sz";
@@ -0,0 +1,14 @@
1
+ import { App } from 'vue';
2
+
3
+ type ComponentType = any;
4
+ export interface SZInstance {
5
+ version: string;
6
+ componentPrefix: string;
7
+ install: (app: App) => void;
8
+ }
9
+ interface SZCreateOptions {
10
+ components?: ComponentType[];
11
+ componentPrefix?: string;
12
+ }
13
+ declare function create({ componentPrefix, components }?: SZCreateOptions): SZInstance;
14
+ export default create;
@@ -0,0 +1,5 @@
1
+ import { App } from 'vue';
2
+
3
+ export declare const commonInstall: (app: App) => void;
4
+ declare const installer: (app: App) => void;
5
+ export default installer;
@@ -0,0 +1,9 @@
1
+ /*!
2
+ Theme: Default
3
+ Description: Original highlight.js style
4
+ Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
5
+ Maintainer: @highlightjs/core-team
6
+ Website: https://highlightjs.org/
7
+ License: see project LICENSE
8
+ Touched: 2021
9
+ */pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}