| | |
| | | /> |
| | | </template> |
| | | <template #content> |
| | | <!-- <a-card :class="{ chatItemAnswer: theme === 'light' }">--> |
| | | <!-- <div :class="{ light: theme === 'light' }"--> |
| | | <!-- >{{ sessionDetail.content }}--> |
| | | <!-- </div>--> |
| | | <!-- </a-card>--> |
| | | |
| | | <a-textarea |
| | | readonly |
| | | auto-size |
| | |
| | | style="border: none" |
| | | > |
| | | </a-textarea> |
| | | |
| | | </template> |
| | | <template #actions> |
| | | <span |
| | |
| | | > |
| | | <icon-refresh /> 重新生成 |
| | | </span> |
| | | <!-- <span class="action"><icon-to-bottom />下载 </span> --> |
| | | </template> |
| | | </a-comment> |
| | | <a-comment v-else-if="sessionDetail.role === 'last'"> |
| | |
| | | <icon-send size="32" style="color: #0960bd" /> |
| | | </a-button> |
| | | </div> |
| | | <!-- <div class="btn-send">--> |
| | | <!-- <!– <icon-send size="32" /> –>--> |
| | | <!-- <a-button--> |
| | | <!-- :disabled="chatDis"--> |
| | | <!-- @click="sentClick"--> |
| | | <!-- type="text"--> |
| | | <!-- style="border-radius: 24px"--> |
| | | <!-- :loading="loading"--> |
| | | <!-- >--> |
| | | <!-- <icon-send size="32" style="color: #0960bd;"/>--> |
| | | <!-- </a-button--> |
| | | <!-- >--> |
| | | <!-- </div>--> |
| | | |
| | | </div> |
| | | <a-modal |
| | | v-model:visible="visible" |
| | |
| | | import { |
| | | agentResetApi, |
| | | agentSetApi, |
| | | getAgentSessionDetailsApi, |
| | | } from '@/api/agentSession'; |
| | | getAgentSessionDetailsApi, updateAgentConversation |
| | | } from "@/api/agentSession"; |
| | | import EventBus from '@/utils/EventBus'; |
| | | import useClipboard from 'vue-clipboard3'; |
| | | import { addSessionApi, getSessionDetailsApi } from '@/api/session'; |
| | |
| | | const selectValue = ref(''); |
| | | const sectionList = ref({}); |
| | | let chatObj = reactive({}); |
| | | const isStopChat = ref(false); |
| | | let isStopChat = false; |
| | | const appStore = useAppStore(); |
| | | const theme = computed(() => { |
| | | return appStore.theme; |
| | |
| | | let isHistory = ref(false); //是否是历史记录 |
| | | let dsl = reactive({}); |
| | | const chatDataMeg = reactive({}); |
| | | |
| | | let toStop = false; |
| | | |
| | | const rules = { |
| | | name: [ |
| | |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | body: JSON.stringify({ |
| | | converson_id: conversation_id.value, |
| | | id: agentObj.id, |
| | | dsl:agentObj.dsl, |
| | | }), |
| | | }); |
| | | |
| | |
| | | if (code == 0) { |
| | | console.log(data, 'agent会话详情'); |
| | | Object.assign(chatObj, data); |
| | | sessionDetailList.value = data.dsl.messages; |
| | | // sessionDetailList.value = data.dsl.messages; |
| | | await updateAgentConversation({ |
| | | converson_id: conversation_id.value, |
| | | dsl:data.dsl, |
| | | }) |
| | | agentTitle.value = `${data.title}` || '未命名会话'; |
| | | from.name = `${data.title}` || '未命名会话'; |
| | | refreshScroll(); //刷新滚动条位置 |
| | | } |
| | | }; |
| | | |
| | | const copyText = (text) => { |
| | | inputMsg.value = text; |
| | | }; |
| | | |
| | | // 历史记录跳转获取agent会话详情 |
| | |
| | | } |
| | | }; |
| | | |
| | | let message_stop = []; |
| | | let message_id = ""; |
| | | const startChat = async (valMsg) => { |
| | | isStopChat = false; |
| | | displayedText.value = ''; |
| | | sessionDetailList.value.push({ |
| | | content: valMsg, |
| | | role: 'user', |
| | |
| | | refreshScroll(); |
| | | let chatStr = { |
| | | id: agentObj.id, |
| | | converson_id: conversation_id.value, |
| | | message: valMsg, |
| | | }; |
| | | if (isHistory.value) { |
| | |
| | | .getReader(); |
| | | currIndex.value = 0; |
| | | while (true) { |
| | | if (isStopChat) { |
| | | message_stop.push(message_id); |
| | | setChatDataMeg(chatDataMeg); |
| | | break; |
| | | } |
| | | const x = await reader?.read(); |
| | | if (x) { |
| | | const { done, value } = x; |
| | |
| | | try { |
| | | const val = JSON.parse(value?.data || ''); |
| | | const d = val?.data; |
| | | if (message_id != d.message_id) { |
| | | message_id = d.message_id; |
| | | message_stop = []; |
| | | } else { |
| | | //message_stop中查找message_id |
| | | const index = message_stop.findIndex(item => item === message_id); |
| | | if (index > -1) { |
| | | break; |
| | | } |
| | | } |
| | | if (typeof d !== 'boolean') { |
| | | console.info('data:', d); |
| | | streamStr.value = d.content; |
| | |
| | | console.warn(e); |
| | | } |
| | | if (done) { |
| | | console.info('done'); |
| | | displayedText.value = ''; |
| | | if (isStopChat.value) { |
| | | isStopChat.value = false; |
| | | setChatDataMeg(chatDataMeg); |
| | | } else { |
| | | queryAgentSessionDetail(agentObj.id); |
| | | EventBus.emit('queryAppUsageList'); |
| | | } |
| | | console.info("done"); |
| | | displayedText.value = ""; |
| | | queryAgentSessionDetail(agentObj.id); |
| | | EventBus.emit("queryAppUsageList"); |
| | | break; |
| | | } |
| | | } |
| | |
| | | }; |
| | | |
| | | const stopChat = async () => { |
| | | // const { code, data } = await stopChatApi(agentObj.id); |
| | | // if (code === 200) { |
| | | // Message.success("已停止"); |
| | | // } |
| | | loading.value = false; |
| | | chatDis.value = false; |
| | | isStopChat.value = true; |
| | | isStopChat = true; |
| | | console.log('stopChat'); |
| | | console.log(displayedText.value, 'displayedText'); |
| | | console.log(sessionDetailList.value, 'sessionDetailList'); |
| | |
| | | watch( |
| | | () => props.modalObj, |
| | | (newVal, oldVal) => { |
| | | // Object.assign(agentObj, newVal); |
| | | Object.assign(agentObj, newVal); |
| | | //调用agent初始化方法 |
| | | if (JSON.stringify(newVal) != '{}') { |
| | | // initPage(); |
| | |
| | | .chatItemAnswer { |
| | | box-sizing: border-box; |
| | | background: #f1f1f1; |
| | | border-radius: 14px; |
| | | border-radius: 10px; |
| | | padding: 5px; |
| | | .light { |
| | | box-sizing: border-box; |
| | | background: #f1f1f1; |
| | | border-radius: 14px; |
| | | border-radius: 10px; |
| | | } |
| | | } |
| | | .textItemAnswer { |
| | |
| | | .icon-user-jpg { |
| | | border: 1px solid #d9d9d9; |
| | | } |
| | | .prompt { |
| | | ul { |
| | | margin: 0; |
| | | padding: 0; |
| | | display: flex; |
| | | } |
| | | ul > li { |
| | | list-style-type: none; |
| | | } |
| | | .prompt-item { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | background-color: #fff; |
| | | cursor: pointer; |
| | | border-radius: 8px; |
| | | padding: 10px; |
| | | border: #e5e5e5; |
| | | &:hover { |
| | | background-color: #eee; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | .header___lEPyH { |