Files
aiot-platform-ui/apps/web-antd/dist/js/index-CSkDI6ZM.js
lzh 2deb263bf9
All checks were successful
Web UI CI/CD / build-and-deploy (push) Successful in 8s
chore: build and deploy web-antd
2026-03-08 00:18:15 +08:00

3 lines
10 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var l=(J,U,b)=>new Promise((z,I)=>{var r=d=>{try{u(b.next(d))}catch(o){I(o)}},v=d=>{try{u(b.throw(d))}catch(o){I(o)}},u=d=>d.done?z(d.value):Promise.resolve(d.value).then(r,v);u((b=b.apply(J,U)).next())});import{ae as _e,bA as B,ay as M,an as S,bB as we,aM as Y,a9 as Z}from"./bootstrap-D7yvUSkm.js";import{g as xe}from"./index-CEMIDoPM.js";import{g as be,d as ke,s as Te}from"./index-m5tE4JsD.js";import{_ as Me}from"./list.vue_vue_type_script_setup_true_lang-fWZrB6pW.js";import{_ as Se}from"./update-form.vue_vue_type_script_setup_true_lang-CwkldPTP.js";import{_ as Ie}from"./file-upload.vue_vue_type_script_setup_true_lang-DvRJY7gL.js";import{_ as Le}from"./list-empty.vue_vue_type_script_setup_true_lang-SWvsN5kc.js";import{_ as Be}from"./list.vue_vue_type_script_setup_true_lang-BoOm6FD6.js";import{_ as De}from"./loading.vue_vue_type_script_setup_true_lang-DPlaJ_VP.js";import{_ as Ue}from"./new-conversation.vue_vue_type_script_setup_true_lang-C2Qwqpik.js";import{_ as Oe}from"./page.vue_vue_type_script_setup_true_lang-DH9gM2_9.js";import{a as D,v as Re}from"./AlertBuilder-CI4mxLbQ.js";import{m as $e,b9 as i,aa as ze,v as Ve,ab as x,b2 as y,bJ as f,j as s,u as n,ae as p,ad as ee,ac as C,ai as P,bp as q,bL as Ne,n as G}from"../jse/index-index-BAlyf32H.js";import{u as Ae}from"./use-modal-CIPEfvn4.js";import"./fetch-ByP_rkuS.js";import"./index-Bd3IrQ3C.js";import"./index-Cw08LTGw.js";import"./repository.vue_vue_type_script_setup_true_lang-3Bc9Ccvy.js";import"./form.vue_vue_type_script_setup_true_lang-DlZ7g4t4.js";import"./index-Baz1utxc.js";import"./index-BT6j_90R.js";import"./index-CvnPzXfK.js";import"./biz-ai-enum-CqA6Ev1u.js";import"./dict-enum-CaHgMaDZ.js";import"./biz-system-enum-BAorzMA8.js";import"./category-list.vue_vue_type_script_setup_true_lang-DYwH4Yec.js";import"./list.vue_vue_type_script_setup_true_lang-Dm1ebl9o.js";import"./index-Dcju38uI.js";import"./use-drawer-CWn_8guH.js";import"./x-CIB7fInP.js";import"./reasoning-Bd-ieWzl.js";import"./index-CTuTk1Md.js";import"./index-B2ey4j0C.js";import"./files.vue_vue_type_script_setup_true_lang-NEd98GFl.js";import"./knowledge.vue_vue_type_script_setup_true_lang-CrEs5MRx.js";import"./web-search.vue_vue_type_script_setup_true_lang-C9ST1Dbl.js";import"./circle-check-big-F4NP1qhl.js";const Ee={class:"text-lg font-bold"},Fe={key:0},je={key:0,class:"flex w-72 justify-end"},He=["innerHTML"],Ke={class:"absolute inset-0 m-0 overflow-y-hidden p-0"},Pe={class:"mx-4 mb-8 mt-2 flex flex-col rounded-xl border border-border p-2"},qe={class:"flex justify-between pb-0 pt-1"},Ge={class:"flex items-center gap-3"},Je={class:"flex items-center"},We={class:"flex items-center"},Rt=$e({name:"AiChat",__name:"index",setup(J){const U=_e(),[b,z]=Ae({connectedComponent:Se,destroyOnClose:!0}),I=i(),r=i(null),v=i(null),u=i(!1),d=i(),o=i([]),k=i(!1),V=i(),h=i(50),N=i(!1),T=i(!1),O=i(),A=i(),m=i(),E=i(!0),F=i(!1),_=i([]),w=i(""),R=i("");function W(e){return l(this,null,function*(){if(!e)return;const t=yield xe(e);t&&(v.value=t,r.value=t.id)})}function te(e){return l(this,null,function*(){return u.value?(yield D("对话中,不允许切换!"),!1):(r.value=e.id,v.value=e,yield j(),yield L(!0),m.value="",m.value="",_.value=[],!0)})}function ae(e){return l(this,null,function*(){r.value===e.id&&(yield Q())})}function Q(){return l(this,null,function*(){if(u.value)return yield D("对话中,不允许切换!"),!1;r.value=null,v.value=null,o.value=[],m.value="",_.value=[]})}function ne(){return l(this,null,function*(){z.setData({id:r.value}).open()})}function oe(){return l(this,null,function*(){yield W(r.value)})}function le(){return l(this,null,function*(){yield I.value.createConversation()})}function se(){return l(this,null,function*(){m.value="",_.value=[]})}function j(){return l(this,null,function*(){try{if(r.value===null)return;V.value=setTimeout(()=>{k.value=!0},60),o.value=yield be(r.value),yield G(),yield L()}finally{V.value&&clearTimeout(V.value),k.value=!1}})}const H=ze(()=>{var e;return o.value.length>0?o.value:(e=v.value)!=null&&e.systemMessage?[{id:0,type:"system",content:v.value.systemMessage}]:[]});function ie(){if(u.value){D("回答中,不能删除!");return}j()}function re(){return l(this,null,function*(){if(r.value)try{yield Re("确认清空对话消息?"),yield ke(r.value),o.value=[]}catch(e){}})}function ue(){d.value.handlerGoTop()}function ce(e){return l(this,null,function*(){var a;if(T.value||u.value)return;const t=(a=m.value)==null?void 0:a.trim();e.key==="Enter"&&(e.shiftKey?(m.value+=`\r
`,e.preventDefault()):(yield $(t),e.preventDefault()))})}function ve(){var e;$((e=m.value)==null?void 0:e.trim())}function de(e){if(!T.value){if(e.data===null||e.data==="null")return;T.value=!0}A.value&&clearTimeout(A.value),A.value=setTimeout(()=>{T.value=!1},400)}function fe(){T.value=!0}function me(){setTimeout(()=>{T.value=!1},200)}function $(e){return l(this,null,function*(){if(e.length===0){Z.error("发送失败,原因:内容为空!");return}if(r.value===null){Z.error("还没创建对话,不能发送!");return}const t=[..._.value];m.value="",_.value=[],yield pe({conversationId:r.value,content:e,attachmentUrls:t})})}function pe(e){return l(this,null,function*(){O.value=new AbortController,u.value=!0,w.value="";try{o.value.push({id:-1,conversationId:r.value,type:"user",content:e.content,attachmentUrls:e.attachmentUrls||[],createTime:new Date},{id:-2,conversationId:r.value,type:"assistant",content:"思考中...",reasoningContent:"",createTime:new Date}),yield G(),yield L(),ge().then();let t=!0;yield Te(e.conversationId,e.content,O.value,E.value,F.value,a=>l(null,null,function*(){const{code:g,data:c,msg:Ce}=JSON.parse(a.data);if(g!==0){yield D(`对话异常! ${Ce}`),w.value===""&&o.value.pop();return}if(!(c.receive.content===""&&!c.receive.reasoningContent)){if(t&&(t=!1,o.value.pop(),o.value.pop(),o.value.push(c.send,c.receive),c.send.attachmentUrls=e.attachmentUrls),c.receive.reasoningContent){const X=o.value[o.value.length-1];X.reasoningContent=(X.reasoningContent||"")+c.receive.reasoningContent}c.receive.content!==""&&(w.value=w.value+c.receive.content),yield L()}}),a=>{throw D("对话异常!"),K(),a},()=>{K()},e.attachmentUrls)}catch(t){}})}function K(){return l(this,null,function*(){O.value&&O.value.abort(),u.value=!1})}function ye(e){m.value=e.content}function he(e){$(e.content)}function L(e){return l(this,null,function*(){yield G(),d.value&&d.value.scrollToBottom(e)})}function ge(){return l(this,null,function*(){let e=0;try{if(N.value)return;N.value=!0,R.value="";function t(){return l(this,null,function*(){const g=(w.value.length-R.value.length)/10;if(g>5?h.value=10:g>2?h.value=30:g>1.5?h.value=50:h.value=100,u.value||(h.value=10),e<w.value.length){R.value+=w.value[e],e++;const c=o.value[o.value.length-1];c&&(c.content=R.value),yield L(),a=setTimeout(t,h.value)}else u.value?a=setTimeout(t,h.value):(N.value=!1,clearTimeout(a))})}let a=setTimeout(t,h.value)}catch(t){}})}return Ve(()=>l(null,null,function*(){if(U.query.conversationId){const e=U.query.conversationId;r.value=e,yield W(e)}k.value=!0,yield j()})),(e,t)=>(y(),x(n(Oe),{"auto-content-height":""},{default:f(()=>[s(n(B),{class:"absolute left-0 top-0 m-4 h-full w-full flex-1"},{default:f(()=>[s(Me,{class:"!bg-card","active-id":r.value,ref_key:"conversationListRef",ref:I,onOnConversationCreate:se,onOnConversationClick:te,onOnConversationClear:Q,onOnConversationDelete:ae},null,8,["active-id"]),s(n(B),{class:"mx-4 bg-card"},{default:f(()=>[s(n(B).Header,{class:"flex !h-12 items-center justify-between border-b border-border !bg-card !px-4"},{default:f(()=>{var a,g;return[p("div",Ee,[P(q((a=v.value)!=null&&a.title?(g=v.value)==null?void 0:g.title:"对话")+" ",1),o.value.length>0?(y(),ee("span",Fe," ("+q(o.value.length)+") ",1)):C("",!0)]),v.value?(y(),ee("div",je,[s(n(M),{type:"primary",ghost:"",class:"mr-2 px-2",size:"small",onClick:ne},{default:f(()=>{var c;return[p("span",{innerHTML:(c=v.value)==null?void 0:c.modelName},null,8,He),s(n(S),{icon:"lucide:settings",class:"ml-2 size-4"})]}),_:1}),s(n(M),{size:"small",class:"mr-2 px-2",onClick:re},{default:f(()=>[s(n(S),{icon:"lucide:trash-2",color:"#787878"})]),_:1}),s(n(M),{size:"small",class:"mr-2 px-2"},{default:f(()=>[s(n(S),{icon:"lucide:download",color:"#787878"})]),_:1}),s(n(M),{size:"small",class:"mr-2 px-2",onClick:ue},{default:f(()=>[s(n(S),{icon:"lucide:arrow-up",color:"#787878"})]),_:1})])):C("",!0)]}),_:1}),s(n(B).Content,{class:"relative m-0 h-full w-full p-0"},{default:f(()=>[p("div",Ke,[k.value?(y(),x(De,{key:0})):C("",!0),v.value?C("",!0):(y(),x(Ue,{key:1,onOnNewConversation:le})),!k.value&&H.value.length===0&&v.value?(y(),x(Le,{key:2,onOnPrompt:$})):C("",!0),!k.value&&H.value.length>0?(y(),x(Be,{key:3,ref_key:"messageRef",ref:d,conversation:v.value,list:H.value,onOnDeleteSuccess:ie,onOnEdit:ye,onOnRefresh:he},null,8,["conversation","list"])):C("",!0)])]),_:1}),s(n(B).Footer,{class:"flex flex-col !bg-card !p-0"},{default:f(()=>[p("form",Pe,[Ne(p("textarea",{class:"box-border h-24 resize-none overflow-auto rounded-md p-2 focus:outline-none","onUpdate:modelValue":t[0]||(t[0]=a=>m.value=a),onKeydown:ce,onInput:de,onCompositionstart:fe,onCompositionend:me,placeholder:"问我任何问题...Shift+Enter 换行,按下 Enter 发送)"},null,544),[[we,m.value]]),p("div",qe,[p("div",Ge,[s(Ie,{modelValue:_.value,"onUpdate:modelValue":t[1]||(t[1]=a=>_.value=a),disabled:u.value},null,8,["modelValue","disabled"]),p("div",Je,[s(n(Y),{checked:E.value,"onUpdate:checked":t[2]||(t[2]=a=>E.value=a),size:"small"},null,8,["checked"]),t[5]||(t[5]=p("span",{class:"ml-1 text-sm text-gray-400"},"上下文",-1))]),p("div",We,[s(n(Y),{checked:F.value,"onUpdate:checked":t[3]||(t[3]=a=>F.value=a),size:"small"},null,8,["checked"]),t[6]||(t[6]=p("span",{class:"ml-1 text-sm text-gray-400"},"联网搜索",-1))])]),u.value===!1?(y(),x(n(M),{key:0,type:"primary",onClick:ve,loading:u.value},{default:f(()=>[s(n(S),{icon:u.value?"lucide:loader":"lucide:send-horizontal"},null,8,["icon"]),P(" "+q(u.value?"进行中":"发送"),1)]),_:1},8,["loading"])):C("",!0),u.value===!0?(y(),x(n(M),{key:1,type:"primary",danger:"",onClick:t[4]||(t[4]=a=>K())},{default:f(()=>[s(n(S),{icon:"lucide:circle-stop"}),t[7]||(t[7]=P(" 停止 ",-1))]),_:1})):C("",!0)])])]),_:1})]),_:1})]),_:1}),s(n(b),{onSuccess:oe})]),_:1}))}});export{Rt as default};