| | |
| | | trigger="click" |
| | | > |
| | | <a-button border |
| | | >{{agentTitle}} |
| | | > |
| | | <span style=" |
| | | width: 100px; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | ">{{ from.name }}</span> |
| | | <icon-down style="margin-left: 4px" /> |
| | | </a-button> |
| | | <template #content> |
| | |
| | | auto-size |
| | | v-model="sessionDetail.content" |
| | | :class="{ chatItemAnswer: theme === 'light' }" |
| | | :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}" |
| | | :style="{ backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}" |
| | | style="border: none" |
| | | > |
| | | </a-textarea> |
| | |
| | | <!-- </div>--> |
| | | </div> |
| | | <a-modal v-model:visible="visible" title="修改名称" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start"> |
| | | <a-form ref="formRef" :rules="rules" :model="agentObj" @submit="handleSubmit" > |
| | | <a-form ref="formRef" :rules="rules" :model="from" @submit="handleSubmit" > |
| | | <a-form-item field="name" label="名称"> |
| | | <a-input v-model="agentTitle" placeholder="请输入名称"/> |
| | | <a-input v-model="from.name" placeholder="请输入名称"/> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <div style="width: 100%;text-align: right"> |
| | |
| | | const streamStr = ref(''); |
| | | const inputMsg = ref(''); |
| | | const activeSessionId = ref(''); |
| | | const conversation_id = ref(''); |
| | | const fieldNames = { value: 'id', label: 'name' }; |
| | | const agentObj = reactive({}); |
| | | const agentList = ref([]); |
| | |
| | | const appStore = useAppStore(); |
| | | const theme = computed(() => { |
| | | return appStore.theme; |
| | | }); |
| | | let from = reactive({ |
| | | name:'未命名会话', |
| | | }); |
| | | |
| | | const visible = ref(false); |
| | |
| | | |
| | | const handleSubmit = async({values, errors}) => { |
| | | if(errors) return; |
| | | // agentObj.name = agentTitle.value; |
| | | // agentObj.conversation_id = agentObj.id; |
| | | console.log(agentObj, 'agentObj'); |
| | | let chatData = { |
| | | id:activeSessionId.value, |
| | | conversation_id:activeSessionId.value, |
| | | name: agentTitle.value |
| | | id:conversation_id.value, |
| | | conversation_id:conversation_id.value, |
| | | name: from.name |
| | | } |
| | | const { code, data } = await addSessionApi(chatData); |
| | | if (data) { |
| | | Message.success("修改成功"); |
| | | handleCancel() |
| | | // queryAgentSessionDetail(agentObj.id); |
| | | } |
| | | } |
| | | |
| | |
| | | }; |
| | | |
| | | const createNewAgent = async (session) => { |
| | | console.log(session,'新建agent会话对象'); |
| | | Object.assign(agentObj, session); |
| | | isHistory.value = false; |
| | | initPage(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // 调用set方法 |
| | | const agentSet = async () => { |
| | | const res = await agentSetApi({ |
| | |
| | | title: agentObj.title, |
| | | dsl: agentObj.dsl, |
| | | }); |
| | | console.log(res,'agentSet'); |
| | | // console.log(res,'agentSet'); |
| | | if (res.code == 0) { |
| | | // sessionDetailList.value = res.data.dsl.messages; |
| | | // Message.success('修改成功'); |
| | | conversation_id.value = res.data.conversation_id; |
| | | agentReset(); |
| | | } |
| | | } |
| | |
| | | Object.assign(chatObj, data); |
| | | sessionDetailList.value = data.dsl.messages; |
| | | agentTitle.value = `${data.title}` || '未命名会话'; |
| | | from.name = `${data.title}` || '未命名会话'; |
| | | refreshScroll(); //刷新滚动条位置 |
| | | } |
| | | }; |
| | | |
| | | // 历史记录跳转获取agent会话详情 |
| | | const querySessionDetail = async (session) => { |
| | | Object.assign(agentObj, session); |
| | | agentObj.id = session.dialog_id; |
| | | activeSessionId.value = session.id; |
| | | agentTitle.value = session.name; |
| | | console.log(agentTitle.value, '会话名称'); |
| | | conversation_id.value = session.id; |
| | | from.name = session.name; |
| | | const { code, data } = await getSessionDetailsApi(session.id); |
| | | if (code == 200) { |
| | | sessionDetailList.value = data.message.messages; |
| | | const res = await getAgentSessionDetailsApi(session.dialog_id); |
| | | if (res.code == 0) { |
| | | console.log(res.data,'agent会话详情'); |
| | | Object.assign(chatObj, data); |
| | | Object.assign(agentObj, res.data); |
| | | Object.assign(chatObj, res.data); |
| | | Object.assign(dsl, res.data.dsl); |
| | | refreshScroll(); //刷新滚动条位置 |
| | | } |
| | |
| | | } |
| | | |
| | | const stopChat=async()=>{ |
| | | // const { code, data } = await stopChatApi(activeSessionId.value); |
| | | // const { code, data } = await stopChatApi(agentObj.id); |
| | | // if (code === 200) { |
| | | // Message.success("已停止"); |
| | | // } |
| | |
| | | sessionDetailList.value = sessionDetailList.value.splice(0, sessionDetailList.value.length-2).concat(lastArr); |
| | | console.log(sessionDetailList.value, 'sessionDetailList2'); |
| | | console.log(chatObj, 'chatObj对象'); |
| | | chatObj.dsl.message = chatObj.dsl.message.concat(lastArr); |
| | | chatObj.dsl.messages = chatObj.dsl.messages.concat(lastArr); |
| | | Object.assign(chatDataMeg, { |
| | | id: chatObj.id, |
| | | conversation_id: chatObj.id, |
| | |
| | | clearTimeout(timer!); |
| | | timer = null; |
| | | // displayedText.value = ""; |
| | | queryNewSessionDetail(activeSessionId.value); |
| | | queryAgentSessionDetail(chatObj.id); |
| | | } |
| | | }; |
| | | |
| | | // const queryNewSessionDetail = async (id) => { |
| | | // activeSessionId.value = id; |
| | | // const { code, data } = await getSessionDetailsApi(id); |
| | | // if (code === 200) { |
| | | // console.log(data, 'agent会话详情'); |
| | | // Object.assign(chatObj, data); |
| | | // sessionDetailList.value = data.message; |
| | | // agentTitle.value = data.name; |
| | | // refreshScroll(); //刷新滚动条位置 |
| | | // } |
| | | // }; |
| | | |
| | | const handleShiftEnter = (event) => { |
| | | event.preventDefault(); |