(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-54926166"],{"5c76":function(t,e,n){"use strict";n("ce0d")},"6c19":function(t,e,n){t.exports=n.p+"img/gptUser.657729dc.png"},"6d4b":function(t,e,n){},"919d":function(t,e,n){"use strict";n("6d4b")},ce0d:function(t,e,n){},fed0:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t._self._c;return e("div",{attrs:{id:"intelligentAssistant"}},[e("div",{staticClass:"select"},[e("Select",{staticStyle:{width:"300px"},model:{value:t.GPTtype,callback:function(e){t.GPTtype=e},expression:"GPTtype"}},t._l(t.GPTLIst,(function(n){return e("Option",{key:n.value,attrs:{value:n.value}},[t._v(t._s(n.label))])})),1)],1),t.loading?e("Spin",{staticStyle:{width:"calc(100% -67px)",height:"calc(100vh - 250px)",position:"fixed",left:"67px",top:"90px"},attrs:{fix:""}},[e("Icon",{staticClass:"demo-spin-icon-load",attrs:{type:"ios-loading",size:"18"}}),e("div",[t._v("Loading")])],1):t._e(),e("main",t._l(t.messages,(function(n,a){return e("div",{key:a,class:n.sender},["ai"==n.sender?e("img",{staticClass:"avatar",attrs:{src:n.avatar}}):t._e(),"user"==n.sender?e("div",{staticClass:"action2"},[e("Poptip",{attrs:{placement:"left",trigger:"hover"}},[e("div",{staticClass:"dots"},[e("div",{staticClass:"dot"}),e("div",{staticClass:"dot"}),e("div",{staticClass:"dot"})]),e("div",{staticStyle:{color:"#000"},attrs:{slot:"content"},slot:"content"},[e("div",{staticStyle:{cursor:"pointer",height:"20px","line-height":"20px"},on:{click:function(e){return t.clear(a)}}},[e("Icon",{attrs:{type:"md-trash",color:"#00A0E9"}}),t._v("删除\n ")],1),e("div",{staticStyle:{cursor:"pointer",height:"20px","line-height":"20px"},on:{click:function(e){return t.copy(n)}}},[e("Icon",{attrs:{type:"md-copy",color:"#00A0E9"}}),t._v("复制\n ")],1)])])],1):t._e(),e("div",{staticClass:"message"},[e("div",{staticClass:"timestamp"},[t._v(t._s(n.timestamp))]),e("div",{staticClass:"text",domProps:{innerHTML:t._s(n.text)}})]),"ai"==n.sender?e("div",{staticClass:"action1"},[e("Poptip",{attrs:{placement:"right",trigger:"hover"}},[e("div",{staticClass:"dots"},[e("div",{staticClass:"dot"}),e("div",{staticClass:"dot"}),e("div",{staticClass:"dot"})]),e("div",{attrs:{slot:"content"},slot:"content"},[e("div",{staticStyle:{cursor:"pointer",height:"30px","line-height":"30px",width:"50px"},on:{click:function(e){return t.clear(a)}}},[e("Icon",{attrs:{type:"md-trash",color:"#00A0E9"}}),t._v("删除\n ")],1),e("div",{staticStyle:{cursor:"pointer",height:"30px","line-height":"30px",width:"50px"},on:{click:function(e){return t.copy(n)}}},[e("Icon",{attrs:{type:"md-copy",color:"#00A0E9"}}),t._v("复制\n ")],1)])])],1):t._e(),"user"==n.sender?e("img",{staticClass:"avatar",attrs:{src:n.avatar}}):t._e()])})),0),e("footer",[e("Button",{staticStyle:{"margin-left":"5px"},attrs:{type:"error",icon:"md-trash",disabled:!t.messages.length},on:{click:t.clearAll}},[t._v("\n 清空对话\n ")]),e("div",{staticStyle:{display:"flex","justify-content":"space-around","margin-top":"3px"}},[e("div",{staticStyle:{position:"relative",width:"calc(100% - 100px)"}},[e("Input",{attrs:{autosize:{minRows:4,maxRows:4},type:"textarea",placeholder:"在此处输入或者粘贴内容"},nativeOn:{keydown:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.submit.apply(null,arguments)}},model:{value:t.inputText,callback:function(e){t.inputText=e},expression:"inputText"}}),e("div",{staticStyle:{position:"absolute",top:"1px",right:"10px",cursor:"pointer"},on:{click:function(e){t.inputText=""}}},[e("Icon",{attrs:{type:"ios-close-circle",size:"14",color:"rgb(153, 151, 153)"}})],1)],1),e("div",{staticStyle:{"border-top":"1px solid #ececec"}},[e("Button",{staticStyle:{width:"80px"},attrs:{type:"primary",icon:"md-paper-plane",loading:t.loading,disabled:!t.inputText},on:{click:t.submit}},[t._v("\n 提交\n ")])],1)])],1)],1)},i=[],o=n("ade3");n("a481");async function s(t,e){const n=t.getReader();let a;while(!(a=await n.read()).done)e(a.value)}function r(t){let e,n,a,i=!1;return function(o){void 0===e?(e=o,n=0,a=-1):e=l(e,o);const s=e.length;let r=0;while(n<s){i&&(10===e[n]&&(r=++n),i=!1);let o=-1;for(;n<s&&-1===o;++n)switch(e[n]){case 58:-1===a&&(a=n-r);break;case 13:i=!0;case 10:o=n;break}if(-1===o)break;t(e.subarray(r,o),a),r=n,a=-1}r===s?e=void 0:0!==r&&(e=e.subarray(r),n-=r)}}function c(t,e,n){let a=d();const i=new TextDecoder;return function(o,s){if(0===o.length)null===n||void 0===n||n(a),a=d();else if(s>0){const n=i.decode(o.subarray(0,s)),r=s+(32===o[s+1]?2:1),c=i.decode(o.subarray(r));switch(n){case"data":a.data=a.data?a.data+"\n"+c:c;break;case"event":a.event=c;break;case"id":t(a.id=c);break;case"retry":const n=parseInt(c,10);isNaN(n)||e(a.retry=n);break}}}}function l(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function d(){return{data:"",event:"",id:"",retry:void 0}}var u=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"===typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n};const p="text/event-stream",h=1e3,g="last-event-id";function v(t,e){var{signal:n,headers:a,onopen:i,onmessage:o,onclose:l,onerror:d,openWhenHidden:v,fetch:f}=e,w=u(e,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((e,u)=>{const y=Object.assign({},a);let b;function x(){b.abort(),document.hidden||O()}y.accept||(y.accept=p),v||document.addEventListener("visibilitychange",x);let C=h,T=0;function k(){document.removeEventListener("visibilitychange",x),window.clearTimeout(T),b.abort()}null===n||void 0===n||n.addEventListener("abort",()=>{k(),e()});const I=null!==f&&void 0!==f?f:window.fetch,G=null!==i&&void 0!==i?i:m;async function O(){var n;b=new AbortController;try{const n=await I(t,Object.assign(Object.assign({},w),{headers:y,signal:b.signal}));await G(n),await s(n.body,r(c(t=>{t?y[g]=t:delete y[g]},t=>{C=t},o))),null===l||void 0===l||l(),k(),e()}catch(a){if(!b.signal.aborted)try{const t=null!==(n=null===d||void 0===d?void 0:d(a))&&void 0!==n?n:C;window.clearTimeout(T),T=window.setTimeout(O,t)}catch(i){k(),u(i)}}}O()})}function m(t){const e=t.headers.get("content-type");if(!(null===e||void 0===e?void 0:e.startsWith(p)))throw new Error(`Expected content-type to be ${p}, Actual: ${e}`)}var f=n("66df"),w=Object(o["a"])({name:"intelligentAssistant",components:{},props:{},data:function(){return{GPTtype:"基础AI模型(OpenAI GPT-3.5-turbo)",GPTLIst:[{value:"基础AI模型(OpenAI GPT-3.5-turbo)",label:"基础AI模型(OpenAI GPT-3.5-turbo)"}],loading:!1,inputText:"",type:"chatGpt",answer:{chatGpt:{value:"",tip:"OpenAI研发\n一款聊天机器人程序",loading:!1},wenXinYiYan:{value:"",tip:"百度研发\n有用、有趣、有温度的智能伙伴",loading:!1},qingHua:{value:"",tip:"清华大学计算机系技术成果\n新一代认知智能大模型",loading:!1},hangye:{value:"",tip:"开发中\n敬请期待...",loading:!1}},height:"",timer:{chatGpt:null,wenXinYiYan:null,qingHua:null},messages:[],messagesCopy:[],first:!0}},mounted:function(){this.height=window.innerHeight-305,this.getChat()},activated:function(){},beforeRouteLeave:function(t,e,n){n()},beforeDestroy:function(){clearInterval(this.timer.chatGpt),clearInterval(this.timer.wenXinYiYan),clearInterval(this.timer.qingHua)},methods:{getNowTime:function(){var t=new Date,e=t.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).replace(/\//g,"-").replace(/:/g,"-").replace(",","");return e},changeRadio:function(){document.getElementById("answer_end").scrollIntoView({behavior:"smooth"})},copy:function(t){var e=document.createElement("input");e.value=t.text,document.body.appendChild(e),e.select(),document.execCommand("copy"),this.$Message.success("复制成功!"),document.body.removeChild(e)},clear:function(t){var e=this;e.$Modal.confirm({title:"确认删除",content:"确认删除吗?此操作不可恢复!",loading:!0,onOk:function(){setTimeout((function(){f["a"].request({url:"/eventkg/DeleteGptChatContent",method:"post",data:{id:e.messagesCopy[t].id}}).then((function(n){1==n.data.Check&&(e.messages.splice(t,1),e.messagesCopy.splice(t,1))})).catch((function(t){})),e.$Modal.remove()}),1e3)}})},clearAll:function(){var t=this;t.$Modal.confirm({title:"确认清空",content:"确认清空吗?此操作不可恢复!",loading:!0,onOk:function(){setTimeout((function(){f["a"].request({url:"/eventkg/DeleteGptChatContent",method:"post",data:{id:localStorage.getItem("userId")}}).then((function(e){1==e.data.Check&&(t.messages=[],t.messagesCopy=[])})).catch((function(t){})),t.$Modal.remove()}),1e3)}})},getChat:function(){var t=this;this.loading=!0,this.messagesCopy=[],f["a"].request({url:"/eventkg/GetGptChatPages",method:"post",data:{pageIndex:1,pageSize:50}}).then((function(e){if(1==e.data.Check){for(var a=e.data.Data.Items,i=0;i<a.length;i++)"user"==a[i].Type&&t.messagesCopy.push({id:a[i].Id,sender:"user",text:a[i].Content,avatar:n("6c19"),timestamp:a[i].CreateTime}),"gpt"==a[i].Type&&t.messagesCopy.push({id:a[i].Id,sender:"ai",text:a[i].Content,avatar:n("d3e0"),timestamp:a[i].CreateTime});t.first&&(t.messages=JSON.parse(JSON.stringify(t.messagesCopy)),t.first=!1),t.loading=!1}else t.loading=!1})).catch((function(t){}))},submit:function(){var t=this;if(this.loading=!0,this.inputText){var e=this.inputText;this.inputText="",this.messages.push({sender:"user",text:e,avatar:n("6c19"),timestamp:this.getNowTime()}),f["a"].request({url:"/EventKg/GetChatGPT",method:"post",data:{keyword:e}}).then((function(a){if(1==a.data.Check){var i=JSON.parse(a.data.Data.Info).choices[0].message.content;i=i.replace(/\n/g,"<br>"),e="",t.messages.push({sender:"ai",text:i,avatar:n("d3e0"),timestamp:t.getNowTime()}),t.getChat(),t.loading=!1}else t.loading=!1})).catch((function(e){t.loading=!1}))}else this.$Message.error("请输入问题"),this.loading=!1},textShowType:function(t,e){},getAnswer_chatGpt:function(){var t={keyword:this.inputText};this.answer.chatGpt.loading=!0;var e=new AbortController,n=this,a=v("http://101.133.134.71:9019/EventKg/GetChatGPT",{method:"POST",data:t,signal:e.signal,onopen:function(){console.log("open"),n.answer.chatGpt.value&&(n.answer.chatGpt.value+="\n\n")},onmessage:function(t){n.answer.chatGpt.loading=!1;var e=JSON.parse(t.data);e.choices&&e.choices.length>0&&e.choices[0].delta&&e.choices[0].delta.content&&(n.answer.chatGpt.value+=e.choices[0].delta.content,"chatGpt"===n.type&&document.getElementById("answer_end").scrollIntoView({behavior:"smooth"}))},onclose:function(){n.answer.chatGpt.loading=!1,e.abort(),a.close()},onerror:function(t){n.answer.chatGpt.loading=!1,console.log("close",t),e.abort(),a.close()}})},getAnswer_wenXinYiYan:function(){this.inputText;this.answer.wenXinYiYan.loading=!0;var t=new AbortController,e=this,n=v("http://101.133.134.71:9019/EventKg/GetChatGPT",{method:"POST",data:{keyword:this.inputText},signal:t.signal,onopen:function(){console.log("open"),e.answer.wenXinYiYan.value&&(e.answer.wenXinYiYan.value+="\n\n")},onmessage:function(t){e.answer.wenXinYiYan.loading=!1;var n=JSON.parse(t.data);n&&n.result&&(e.answer.wenXinYiYan.value+=n.result,"wenXinYiYan"===e.type&&document.getElementById("answer_end").scrollIntoView({behavior:"smooth"}))},onclose:function(){e.answer.wenXinYiYan.loading=!1,t.abort(),n.close()},onerror:function(a){e.answer.wenXinYiYan.loading=!1,console.log("close",a),t.abort(),n.close()}})},getAnswer_qingHua:function(){this.inputText;this.answer.qingHua.loading=!0;var t=new AbortController,e=this,n=v("http://101.133.134.71:9019/EventKg/GetChatGPT",{method:"POST",data:{keyword:this.inputText},signal:t.signal,onopen:function(){console.log("open"),e.answer.qingHua.value&&(e.answer.qingHua.value+="\n\n")},onmessage:function(t){e.answer.qingHua.loading=!1,e.answer.qingHua.value+=t.data,"qingHua"===e.type&&document.getElementById("answer_end").scrollIntoView({behavior:"smooth"})},onclose:function(){e.answer.qingHua.loading=!1,t.abort(),n.close()},onerror:function(a){e.answer.qingHua.loading=!1,console.log("close",a),t.abort(),n.close()}})}},watch:{messages:function(){this.messages.length>0&&this.$nextTick((function(){var t=document.querySelectorAll(".message"),e=t[t.length-1];e.scrollIntoView()}))}},computed:{}},"watch",{GPTtype:function(t,e){"金融大模型问答"==t&&(window.open("https://76b1fb3a.r8.vip.cpolar.cn/"),this.GPTtype="基础AI模型(OpenAI GPT-3.5-turbo)")}}),y=w,b=(n("919d"),n("5c76"),n("2877")),x=Object(b["a"])(y,a,i,!1,null,"0b380cb7",null);e["default"]=x.exports}}]);
|