From 152183624a121ac15fe3545f15360d8c62b81051 Mon Sep 17 00:00:00 2001 From: han2015 <1019850453@qq.com> Date: Mon, 10 Nov 2025 09:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E4=BD=93=EF=BC=9A=E9=97=AE?= =?UTF-8?q?=E7=AD=94=E5=AE=A1=E6=9F=A5=E6=99=BA=E8=83=BD=E4=BD=93=E9=9B=86?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .env.production | 4 +- .../DesignForm/public/form/aiassist.vue | 294 +++++++++++++++--- 3 files changed, 256 insertions(+), 46 deletions(-) diff --git a/.env.development b/.env.development index c8ab71a..dfcd2f5 100644 --- a/.env.development +++ b/.env.development @@ -11,4 +11,6 @@ VITE_APP_TOKEN_KEY = 'offlineAccessSystemAppToken' VITE_APP_SJZT_URL = 'http://172.20.5.86/prod-api' VITE_OFFICE_HOST='http://myvuetest.net/kkapi' VITE_ONLYOFFICE_HOST = 'http://myvuetest.net/onlyoffice' -VITE_DEFAULT_AI_AGENT = '5bd9b0e9-d3f4-4089-670a-880009e925a8' \ No newline at end of file +VITE_DEFAULT_AI_AGENT = '5bd9b0e9-d3f4-4089-670a-880009e925a8' +#流程制度 +VITE_REGUL_AI_AGENT = 'e3be1378-3915-4e5c-b526-9f5447df39ea' diff --git a/.env.production b/.env.production index 40853e2..8c8549c 100644 --- a/.env.production +++ b/.env.production @@ -7,4 +7,6 @@ VITE_APP_TOKEN_KEY = 'onlineAccessSystemAppToken' VITE_APP_SJZT_URL = 'http://120.224.6.6:29911/prod-api' VITE_OFFICE_HOST='https://gyhlw.hxgk.group/kkapi' VITE_ONLYOFFICE_HOST = 'https://gyhlw.hxgk.group/onlyoffice' -VITE_DEFAULT_AI_AGENT = '74938263-ffe5-43c5-90af-25e62d34a51f' \ No newline at end of file +VITE_DEFAULT_AI_AGENT = '74938263-ffe5-43c5-90af-25e62d34a51f' +#流程制度 +VITE_REGUL_AI_AGENT = 'e3be1378-3915-4e5c-b526-9f5447df39ea' \ No newline at end of file diff --git a/src/components/DesignForm/public/form/aiassist.vue b/src/components/DesignForm/public/form/aiassist.vue index 0a0224b..f701330 100644 --- a/src/components/DesignForm/public/form/aiassist.vue +++ b/src/components/DesignForm/public/form/aiassist.vue @@ -7,17 +7,24 @@ import { doAiChat,aiChatData} from "@/api/doc/space" import { useUserStore } from "@/store/modules/user"; +import { VueMarkdown } from '@crazydos/vue-markdown' +import rehypeRaw from 'rehype-raw' //选中的咨询模式 const userStore = useUserStore(); const userid="p0"+userStore.userInfoCont.userId; - +const regulaKey=import.meta.env.VITE_REGUL_AI_AGENT; const baseURL=import.meta.env.VITE_APP_BASE_API +const regulaURL =`${baseURL}/aibot/agents/${regulaKey}/chat` const conversation=ref("") //当前会话的uuid const controller = ref(null) -const interact_msg=ref<{ask:boolean,think:string,content:string}[]>([]) +const interact_msg=ref<{ask:boolean,think:string,content:string}[]>([{ask:false,think:"是",content:`你好!我是你的AI助手, + 你可以直接向我提问,或者编辑表单,我会自动为你提供相关信息。`}]) +// 输入框内容 +const inputText = ref(''); +const respMsg=ref("") //markdown 内容,问答智能体的动态回复内容 //消息体 interface message{ @@ -37,29 +44,34 @@ interface chatRecord{ defineExpose({onSendParamToAI}) async function onSendParamToAI(arr:Array<{ uuids: string[]; params: { [key: string]: any } }>){ - interact_msg.value=[] + //interact_msg.value=[] for (let ele of arr){ //interact_msg.value.unshift({ask:true,think:"", content:"AI正在分析。。。"}) for (let uid of ele.uuids){ - await doRequest(userid,uid,ele.params) + let para={ + inputs: { + "checkType":"travel", + "checkInfo":JSON.stringify(ele.params) + }, + response_mode:"streaming", + user:userid,//这里已经base64解析了 + } + //添加问题记录 + interact_msg.value.push({ask:true,think:"", content:JSON.stringify(para)}) + + await doRequest(`${baseURL}/aibot/assisted/${uid}/workflow`,para) } } } -async function doRequest(_user:string,uuid:string,param:any){ +async function doRequest(furl:string,param:any){ let mRespMsg="" - const params={ - "checkType":"travel", - "checkInfo":JSON.stringify(param) - } - controller.value = new AbortController(); try{ - const res= await doAiChat(`${baseURL}/aibot/assisted/${uuid}/workflow`,{ - inputs: params, - response_mode:"streaming", - user:_user,//这里已经base64解析了 - },controller.value.signal + const res= await doAiChat( + furl, + param, + controller.value.signal ) if (!res.ok) { @@ -86,6 +98,9 @@ async function doRequest(_user:string,uuid:string,param:any){ if(json.event==="text_chunk"){ //conversation.value=json.conversation_id mRespMsg+=json.data.text + }else if(json.event==="message"){ + respMsg.value+=json.answer + mRespMsg+=json.answer } } } @@ -95,19 +110,18 @@ async function doRequest(_user:string,uuid:string,param:any){ console.log('用户手动中断') } } - - interact_msg.value.unshift({ask:true,think:"", content:JSON.stringify(param)}) + respMsg.value="" const arr=mRespMsg.split("") if(arr.length===1){ - interact_msg.value.unshift({ask:false,think:"",content:arr[0]}) + interact_msg.value.push({ask:false,think:"",content:arr[0]}) }else{ //思考模式 let st = arr[1].trim().match(/({.*})/s) if (st){ let res= JSON.parse(st[1]) - interact_msg.value.unshift({ask:false,think:res.success,content:res.reason}) + interact_msg.value.push({ask:false,think:res.success,content:res.reason}) }else{ - interact_msg.value.unshift({ask:false,think:arr[0],content:arr[1]}) + interact_msg.value.push({ask:false,think:arr[0],content:arr[1]}) } } } @@ -118,50 +132,242 @@ function resetContext(){ //props.closefunc() } +// 发送消息 +const sendMessage = () => { + const content = inputText.value.trim(); + if (!content) return; + + // 添加用户消息 + interact_msg.value.push({ ask: true,think:"", content }); + + const params={ + inputs: {"onlineSearch":"否", + "useDataset":"是", + "queryUrl":""}, + query:content, + response_mode:"streaming", + conversation_id:conversation.value, + user:userid + } + + doRequest(regulaURL,params) + + // 清空输入框 + inputText.value = ''; +}; + + + //渲染完页面再执行 // onMounted(() => { // });