| | |
| | | <div class="chatHeaderBox"> |
| | | <!-- <span class="title">{{ agentTitle }}</span>--> |
| | | |
| | | <a-popover |
| | | position="bottom" |
| | | trigger="click" |
| | | > |
| | | <a-popover position="bottom" trigger="click"> |
| | | <a-button border |
| | | >{{agentTitle}} |
| | | <icon-down style="margin-left: 4px" /> |
| | |
| | | <!-- <a-divider style="margin: 10px 0" />--> |
| | | </template> |
| | | </a-popover> |
| | | |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | margin: 0px auto 20px; |
| | | " |
| | | > |
| | | <div class="chat-item" v-for="(sessionDetail,index) in sessionDetailList"> |
| | | <div |
| | | class="chat-item" |
| | | v-for="(sessionDetail, index) in sessionDetailList" |
| | | > |
| | | <a-comment v-if="sessionDetail.role === 'user'"> |
| | | <template #avatar> |
| | | <img |
| | |
| | | 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> |
| | | </template> |
| | | <!-- <div>{{ sessionDetail.role === 'assistant' }}</div> --> |
| | | <template #actions> |
| | | <span class="action" v-if="index != 0" @click="copy(sessionDetail.content)"> |
| | | <!-- <div |
| | | v-for="(item, leng) in messagenList.reference" |
| | | :key="leng" |
| | | > --> |
| | | <div> |
| | | <div> |
| | | <template |
| | | v-for="(v, lix) in getTxt( |
| | | messagenList.reference, |
| | | sessionDetail.role, |
| | | sessionDetail.content, |
| | | index |
| | | )" |
| | | :key="lix" |
| | | > |
| | | <div class="icon-box"> |
| | | <div> |
| | | <img :src="getIconByExtension(v.doc_name)" alt="" /> |
| | | </div> |
| | | <div class="icon-text"> {{ v.doc_name }} </div> |
| | | </div> |
| | | </template> |
| | | </div> |
| | | </div> |
| | | |
| | | <span |
| | | class="action" |
| | | v-if="index != 0" |
| | | @click="copy(sessionDetail.content)" |
| | | > |
| | | <icon-copy /> å¤å¶ |
| | | </span> |
| | | <span class="action" v-if="index != 0 && index == sessionDetailList.length - 1" @click="reGenerate()"> |
| | | <span |
| | | class="action" |
| | | v-if="index != 0 && index == sessionDetailList.length - 1" |
| | | @click="reGenerate()" |
| | | > |
| | | <icon-refresh /> éæ°çæ |
| | | </span> |
| | | </template> |
| | |
| | | auto-size |
| | | v-model="displayedText" |
| | | :class="{ chatItemAnswer: theme === 'light' }" |
| | | :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}" |
| | | :style="{ |
| | | backgroundColor: |
| | | theme === 'light' ? '#ffffff' : '#000000', |
| | | }" |
| | | style="border: none" |
| | | > |
| | | </a-textarea> |
| | | </template> |
| | | |
| | | <template #actions> |
| | | <div class="action" |
| | | <!-- <div class="icon-box"> |
| | | <div> |
| | | <img :src="getIconByExtension('pdf')" alt="" /> |
| | | </div> |
| | | <div class="icon-text"> æä»¶ç±»å </div> |
| | | </div> --> |
| | | <div |
| | | class="action" |
| | | @click="stopChat" |
| | | style="background: var(--color-bg-2);color: var(--color-primary-light-4);" |
| | | v-if="displayedText != ''"> |
| | | style=" |
| | | background: var(--color-bg-2); |
| | | color: var(--color-primary-light-4); |
| | | " |
| | | v-if="displayedText != ''" |
| | | > |
| | | <icon-record-stop /> |
| | | åæ¢çæ |
| | | </div> |
| | |
| | | show-word-limit |
| | | :disabled="chatDis" |
| | | :class="{ textItemAnswer: theme === 'dark' }" |
| | | :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}" |
| | | :style="{ |
| | | backgroundColor: theme === 'light' ? '#ffffff' : '#000000', |
| | | }" |
| | | style="border: none" |
| | | :auto-size="{ |
| | | minRows: 12, |
| | |
| | | <!-- </template>--> |
| | | <!-- </a-upload>--> |
| | | <!-- </div>--> |
| | | <span style="position: absolute;top:94px;left: 20px;z-index: 999;cursor: pointer"> |
| | | <icon-attachment size="28" @click="selectFile" style="color: #0960bd;" /> |
| | | <span |
| | | style=" |
| | | position: absolute; |
| | | top: 94px; |
| | | left: 20px; |
| | | z-index: 999; |
| | | cursor: pointer; |
| | | " |
| | | > |
| | | <icon-attachment |
| | | size="28" |
| | | @click="selectFile" |
| | | style="color: #0960bd" |
| | | /> |
| | | <input |
| | | ref="fileInput" |
| | | type="file" |
| | | style="display: none;" |
| | | style="display: none" |
| | | @change="onFileSelected" |
| | | /> |
| | | </span> |
| | | <div class="uploadFileList"> |
| | | <div class="files" v-for="(item,index) in uploaditemList" :key="index" |
| | | style="position: relative;width: 200px;margin-top: 10px;"> |
| | | <div |
| | | class="files" |
| | | v-for="(item, index) in uploaditemList" |
| | | :key="index" |
| | | style="position: relative; width: 200px; margin-top: 10px" |
| | | > |
| | | <a-comment |
| | | :author="item.name" |
| | | :content="item.size +''" |
| | | style="background: var(--color-bg-2);padding:10px;border-radius: 10px" |
| | | style=" |
| | | background: var(--color-bg-2); |
| | | padding: 10px; |
| | | border-radius: 10px; |
| | | " |
| | | > |
| | | <template #avatar> |
| | | <a-spin :loading="onFileSelectedLoading" v-if="onFileSelectedLoading"> |
| | | <a-spin |
| | | :loading="onFileSelectedLoading" |
| | | v-if="onFileSelectedLoading" |
| | | > |
| | | <template #icon> |
| | | <icon-sync /> |
| | | </template> |
| | |
| | | </a-avatar> |
| | | </template> |
| | | </a-comment> |
| | | <icon-close-circle-fill size="18px" |
| | | <icon-close-circle-fill |
| | | size="18px" |
| | | @click="deleteFile(item)" |
| | | style="position: absolute;right: -4px;top: -4px;color: red;cursor: pointer"/> |
| | | style=" |
| | | position: absolute; |
| | | right: -4px; |
| | | top: -4px; |
| | | color: red; |
| | | cursor: pointer; |
| | | " |
| | | /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </a-col> |
| | | </a-row> |
| | | <a-modal v-model:visible="visible" title="ä¿®æ¹åç§°" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start"> |
| | | <a-form ref="formRef" :rules="rules" :model="chatObj" @submit="handleSubmit" > |
| | | <a-modal |
| | | v-model:visible="visible" |
| | | title="ä¿®æ¹åç§°" |
| | | @before-open="handleOpened" |
| | | @cancel="handleCancel" |
| | | :footer="false" |
| | | title-align="start" |
| | | > |
| | | <a-form |
| | | ref="formRef" |
| | | :rules="rules" |
| | | :model="chatObj" |
| | | @submit="handleSubmit" |
| | | > |
| | | <a-form-item field="name" label="åç§°"> |
| | | <a-input v-model="agentTitle" placeholder="请è¾å
¥åç§°"/> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <div style="width: 100%;text-align: right"> |
| | | <a-button @click="visible = false">åæ¶</a-button> |
| | | <a-button style="margin-left: 10px" type="primary" html-type="submit">ç¡®å®</a-button> |
| | | <a-button |
| | | style="margin-left: 10px" |
| | | type="primary" |
| | | html-type="submit" |
| | | >ç¡®å®</a-button |
| | | > |
| | | </div> |
| | | </a-form-item> |
| | | </a-form> |
| | |
| | | import { |
| | | IconClose, |
| | | IconSearch, |
| | | IconTiktokColor |
| | | } from "@arco-design/web-vue/es/icon"; |
| | | import { useAppStore, useUserStore } from "@/store"; |
| | | IconTiktokColor, |
| | | } from '@arco-design/web-vue/es/icon'; |
| | | import { useAppStore, useUserStore } from '@/store'; |
| | | import { |
| | | computed, |
| | | nextTick, |
| | |
| | | reactive, |
| | | ref, |
| | | onBeforeMount, |
| | | onBeforeUnmount |
| | | } from "vue"; |
| | | onBeforeUnmount, |
| | | } from 'vue'; |
| | | |
| | | import { Message } from "@arco-design/web-vue"; |
| | | import { EventSourceParserStream } from "eventsource-parser/stream"; |
| | | import moment from "moment"; |
| | | import chatMenu from "@/views/sessionManager/components/chatMenu.vue"; |
| | | import AddSession from "@/views/sessionManager/components/addSession.vue"; |
| | | import agentSession from "@/views/sessionManager/components/agentSession.vue"; |
| | | import historySession from "@/views/sessionManager/components/historySession.vue"; |
| | | import smartAi from "@/views/sessionManager/components/smartAi.vue"; |
| | | import setName from "@/views/sessionManager/components/setName.vue"; |
| | | import EventBus from "@/utils/EventBus"; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | import { EventSourceParserStream } from 'eventsource-parser/stream'; |
| | | import moment from 'moment'; |
| | | import chatMenu from '@/views/sessionManager/components/chatMenu.vue'; |
| | | import AddSession from '@/views/sessionManager/components/addSession.vue'; |
| | | import agentSession from '@/views/sessionManager/components/agentSession.vue'; |
| | | import historySession from '@/views/sessionManager/components/historySession.vue'; |
| | | import smartAi from '@/views/sessionManager/components/smartAi.vue'; |
| | | import setName from '@/views/sessionManager/components/setName.vue'; |
| | | import EventBus from '@/utils/EventBus'; |
| | | import { |
| | | addSessionApi, |
| | | chatApi, |
| | | getDialogListApi, |
| | | getSessionDetailsApi, |
| | | sessionListApi, uploadWithoutKb |
| | | } from "@/api/session"; |
| | | import { getAuthorization } from "@/utils/auth"; |
| | | import { queryCanvasList } from "@/api/Agent"; |
| | | import { getAgentSessionDetailsApi } from "@/api/agentSession"; |
| | | import useClipboard from "vue-clipboard3"; |
| | | sessionListApi, |
| | | uploadWithoutKb, |
| | | } from '@/api/session'; |
| | | import { getAuthorization } from '@/utils/auth'; |
| | | import { queryCanvasList } from '@/api/Agent'; |
| | | import { getAgentSessionDetailsApi } from '@/api/agentSession'; |
| | | import useClipboard from 'vue-clipboard3'; |
| | | import pdfImg1 from '@/assets/session/PDF.png'; |
| | | import pdfImg2 from '@/assets/session/wps-write.png'; |
| | | import pdfImg3 from '@/assets/session/execl.png'; |
| | | import pdfImg4 from '@/assets/session/icon-txt.png'; |
| | | import pdfImg5 from '@/assets/session/txt.png'; |
| | | |
| | | // const url = ref('../../assets/session/PDF.png'); |
| | | |
| | | const sessionDetailList = ref([]); //æ ¹æ®ä¼è¯idåºæ¥çä¼è¯è¯¦æ
|
| | | const messagenList = ref({}); |
| | | const sessionList = ref([]); //ä¼è¯å表 |
| | | const modalObj = reactive({ add: false }); |
| | | const dialogId = ref(""); |
| | | const dialogId = ref(''); |
| | | const chatDis = ref(false); |
| | | const loading = ref(false); |
| | | const agentType = ref("1"); |
| | | const agentTitle = ref("æªå½åä¼è¯"); |
| | | const agentType = ref('1'); |
| | | const agentTitle = ref('æªå½åä¼è¯'); |
| | | let chatObj = reactive({}); |
| | | const isStopChat = ref(false); |
| | | const currIndex = ref(0); |
| | | const displayedText = ref(""); // æ£å¨æ¾ç¤ºçæå |
| | | const displayedText = ref(''); // æ£å¨æ¾ç¤ºçæå |
| | | let timer: number | null = null; |
| | | const streamStr = ref(""); |
| | | const inputMsg = ref(""); |
| | | const activeSessionId = ref(""); |
| | | const fieldNames = { value: "id", label: "name" }; |
| | | const streamStr = ref(''); |
| | | const inputMsg = ref(''); |
| | | const activeSessionId = ref(''); |
| | | const fieldNames = { value: 'id', label: 'name' }; |
| | | const dialogs = ref([]); |
| | | const dialogObj = reactive({}); |
| | | const agentObj = reactive({}); |
| | | const agentList = ref([]); |
| | | const selectValue = ref(""); |
| | | const selectValue = ref(''); |
| | | const sectionList = ref({}); |
| | | const uploadList = ref([]); |
| | | const uploaditemList = ref([]); |
| | |
| | | const files = ref([]); |
| | | const file = ref(''); |
| | | const fileInput = ref(null); |
| | | const chatDataMeg = reactive({}) |
| | | const chatDataMeg = reactive({}); |
| | | const visible = ref(false); |
| | | |
| | | |
| | | |
| | | const rules = { |
| | | name: [ |
| | |
| | | message:'åç§°ä¸å
许为空', |
| | | }, |
| | | ], |
| | | } |
| | | }; |
| | | |
| | | const handleSubmit = async({values, errors}) => { |
| | | if(errors) return; |
| | |
| | | let chatData = { |
| | | id:chatObj.id, |
| | | conversation_id:chatObj.id, |
| | | name: agentTitle.value |
| | | } |
| | | name: agentTitle.value, |
| | | }; |
| | | const { code, data } = await addSessionApi(chatData); |
| | | if (data) { |
| | | Message.success("ä¿®æ¹æå"); |
| | | handleCancel() |
| | | Message.success('ä¿®æ¹æå'); |
| | | handleCancel(); |
| | | queryNewSessionDetail(activeSessionId.value); |
| | | } |
| | | }; |
| | | let dataItem = []; |
| | | const getTxt = (data, role, message, index) => { |
| | | if (/##0\$\$/.test(message)) { |
| | | if (role == 'assistant' && index) { |
| | | data.forEach((item) => { |
| | | if (Object.keys(item).length !== 0 && item?.doc_aggs.length > 0) { |
| | | dataItem = item.doc_aggs; |
| | | console.log(dataItem, 999); |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | dataItem = []; |
| | | } |
| | | |
| | | return dataItem; |
| | | }; |
| | | |
| | | const getIconByExtension = computed(() => (extension) => { |
| | | const fileExtension = ref(''); |
| | | fileExtension.value = extension.split('.').pop(); |
| | | switch (fileExtension.value) { |
| | | case 'pptx': |
| | | case 'ppt': |
| | | case 'pdf': |
| | | return pdfImg1; // PDF徿 çURL |
| | | case 'docx': |
| | | case 'doc': |
| | | return pdfImg2; // Word徿 çURL |
| | | case 'xlsx': |
| | | case 'xls': |
| | | return pdfImg3; // Excel徿 çURL |
| | | case 'txt': |
| | | return pdfImg4; // ææ¬ææ¡£å¾æ çURL |
| | | default: |
| | | return pdfImg5; // é»è®¤å¾æ |
| | | } |
| | | }); |
| | | |
| | | const handleClick = () => { |
| | | visible.value = true; |
| | | }; |
| | | const handleCancel = () => { |
| | | visible.value = false; |
| | | } |
| | | }; |
| | | |
| | | const handleOpened =(el) => { |
| | | // Object.assign(form,{ |
| | | // name: '',// ç¨æ·å |
| | | // }); |
| | | // formRef.value.resetFields(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | }; |
| | | |
| | | const selectFile = () => { |
| | | fileInput.value.click(); |
| | | }; |
| | | |
| | | |
| | | let onFileSelectedLoading = ref(false); |
| | | const onFileSelected = (event) => { |
| | | const file = event.target.files[0]; |
| | | uploaditemList.value = [{ |
| | | uploaditemList.value = [ |
| | | { |
| | | name: file.name, |
| | | size: file.size, |
| | | }]; |
| | | }, |
| | | ]; |
| | | if (file) { |
| | | onFileSelectedLoading.value = true; |
| | | const formData = new FormData(); |
| | | formData.append("file", file); |
| | | formData.append("conversation_id", activeSessionId.value); |
| | | formData.append('file', file); |
| | | formData.append('conversation_id', activeSessionId.value); |
| | | uploadWithoutKb(formData).then((res) => { |
| | | // console.log(res); |
| | | if (res.code == 200) { |
| | | console.log(res); |
| | | console.log(uploaditemList.value); |
| | | onFileSelectedLoading.value = false; |
| | | fileInput.value.value = ""; |
| | | fileInput.value.value = ''; |
| | | uploaditemList.value = []; |
| | | Message.success("ä¸ä¼ æå"); |
| | | Message.success('ä¸ä¼ æå'); |
| | | } else { |
| | | Message.error("ä¸ä¼ 失败"); |
| | | Message.error('ä¸ä¼ 失败'); |
| | | } |
| | | }); |
| | | } |
| | |
| | | // ä¸ä¼ æä»¶ |
| | | const customRequest = async (option) => { |
| | | const { onProgress, onError, onSuccess, fileItem, name } = option; |
| | | fileItem.status = "ready"; |
| | | fileItem.status = 'ready'; |
| | | if (fileItem.file) { |
| | | const formData = new FormData(); |
| | | formData.append("file", fileItem.file); |
| | | formData.append("conversation_id", activeSessionId.value); |
| | | formData.append('file', fileItem.file); |
| | | formData.append('conversation_id', activeSessionId.value); |
| | | uploadWithoutKb(formData).then((res) => { |
| | | // console.log(res); |
| | | if (res.code == 200) { |
| | | console.log(res); |
| | | console.log(uploadList.value); |
| | | fileItem.status = "done"; |
| | | fileItem.status = 'done'; |
| | | // uploadList.value = []; |
| | | } else { |
| | | fileItem.status = "error"; |
| | | fileItem.status = 'error'; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | | const DialogList = async () => { |
| | | const { code, data } = await getDialogListApi(); |
| | |
| | | dialogs.value = data.map((item) => { |
| | | return { |
| | | ...item, |
| | | type: 1 //æºè½ä½ |
| | | type: 1, //æºè½ä½ |
| | | }; |
| | | }); |
| | | console.log(data, "dialogs"); |
| | | console.log(data, 'dialogs'); |
| | | queryCanvas(); |
| | | } |
| | | } |
| | |
| | | const queryCanvas = async (params = {}) => { |
| | | try { |
| | | const { data } = await queryCanvasList(params); |
| | | console.log(data, "agent"); |
| | | console.log(data, 'agent'); |
| | | agentList.value = data.map((item) => { |
| | | return { |
| | | ...item, |
| | | name: item.title, |
| | | type: 2 //agent |
| | | type: 2, //agent |
| | | }; |
| | | }); |
| | | // åå¹¶æ°ç» |
| | |
| | | } |
| | | }; |
| | | // æ°å»ºä¼è¯ |
| | | const createSession = async (id, name = "æªå½åä¼è¯") => { |
| | | const createSession = async (id, name = 'æªå½åä¼è¯') => { |
| | | // 妿æä¼è¯id |
| | | console.log(name, "æ°å»ºä¼è¯åç§°"); |
| | | console.log(name, 'æ°å»ºä¼è¯åç§°'); |
| | | |
| | | const res = await addSessionApi({ |
| | | dialog_id: id, |
| | | conversation_desc: name |
| | | conversation_desc: name, |
| | | }); |
| | | // console.log(res, "res"); |
| | | if (res.code == 200) { |
| | |
| | | activeSessionId.value = res.data?.conversation_id; |
| | | queryNewSessionDetail(res.data?.conversation_id); |
| | | } else { |
| | | Message.error("å建ä¼è¯å¤±è´¥ï¼è¯·éè¯"); |
| | | Message.error('å建ä¼è¯å¤±è´¥ï¼è¯·éè¯'); |
| | | } |
| | | }; |
| | | |
| | | const handleShiftEnter = (event) => { |
| | | event.preventDefault(); |
| | | inputMsg.value += "\n"; |
| | | inputMsg.value += '\n'; |
| | | }; |
| | | const dialogChange = (val) => { |
| | | // 夿å½åæ¯æºè½ä½æagent |
| | |
| | | Object.assign(dialogObj, item); |
| | | } |
| | | }); |
| | | console.log(dialogObj.type, "dialogObj"); |
| | | console.log(dialogObj.type, 'dialogObj'); |
| | | if (dialogObj.type == 1) { |
| | | agentType.value = "1"; |
| | | agentType.value = '1'; |
| | | querySessionList(); |
| | | } else { |
| | | agentType.value = "2"; |
| | | agentType.value = '2'; |
| | | queryAgentSessionList(); |
| | | } |
| | | |
| | |
| | | |
| | | // åé |
| | | const sentClick = () => { |
| | | sendMessage("click"); |
| | | sendMessage('click'); |
| | | }; |
| | | // éæ°çæ |
| | | const reGenerate = () => { |
| | | let inputContent = sessionDetailList.value[sessionDetailList.value.length - 2].content; |
| | | let inputContent = |
| | | sessionDetailList.value[sessionDetailList.value.length - 2].content; |
| | | startChat(inputContent); |
| | | }; |
| | | |
| | | const sendMessage = async (event) => { |
| | | if (event.keyCode == 13 || event === "click") { |
| | | if (event.keyCode == 13 || event === 'click') { |
| | | if (!event.shiftKey) { |
| | | //åªæenter没æshiftï¼æè¿è¡ä½ çå
¶ä»é»è¾ |
| | | if (event !== "click") { |
| | | if (event !== 'click') { |
| | | event.preventDefault(); // 黿¢é»è®¤è¡ä¸ºï¼å³ä¸æ¢è¡ |
| | | } |
| | | |
| | | |
| | | // if (!activeSessionId.value) { |
| | | // Message.warning("è¯·éæ©ä¼è¯"); |
| | |
| | | // } |
| | | |
| | | if (inputMsg.value) { |
| | | |
| | | startChat(inputMsg.value); |
| | | |
| | | inputMsg.value = ""; |
| | | inputMsg.value = ''; |
| | | } else { |
| | | Message.warning("æ¶æ¯ä¸è½ä¸ºç©º"); |
| | | Message.warning('æ¶æ¯ä¸è½ä¸ºç©º'); |
| | | } |
| | | } |
| | | } |
| | |
| | | loading.value = true; |
| | | sessionDetailList.value.push({ |
| | | content: valMsg, |
| | | role: "user" |
| | | role: 'user', |
| | | }); |
| | | sessionDetailList.value.push({ role: "last" }); |
| | | sessionDetailList.value.push({ role: 'last' }); |
| | | refreshScroll(); |
| | | const response = await fetch( |
| | | "/api/tech/cloudminds/query?modeltype=localragflow", |
| | | '/api/tech/cloudminds/query?modeltype=localragflow', |
| | | { |
| | | method: "POST", |
| | | method: 'POST', |
| | | headers: { |
| | | "Authorization": getAuthorization(), |
| | | "Content-Type": "application/json" |
| | | 'Authorization': getAuthorization(), |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | body: JSON.stringify({ |
| | | conversation_id: activeSessionId.value, |
| | | messages: valMsg |
| | | }) |
| | | messages: valMsg, |
| | | }), |
| | | } |
| | | ); |
| | | |
| | |
| | | const { done, value } = x; |
| | | // console.log(x, 999); |
| | | try { |
| | | const val = JSON.parse(value?.data || ""); |
| | | const val = JSON.parse(value?.data || ''); |
| | | const d = val?.data; |
| | | if (typeof d !== "boolean") { |
| | | if (typeof d !== 'boolean') { |
| | | // console.info("data:", d); |
| | | streamStr.value = d.content; |
| | | startDisplayStr(); |
| | |
| | | console.warn(e); |
| | | } |
| | | if (done) { |
| | | console.info("done"); |
| | | displayedText.value = ""; |
| | | console.info('done'); |
| | | displayedText.value = ''; |
| | | if(isStopChat.value){ |
| | | setChatDataMeg(chatDataMeg); |
| | | }else{ |
| | | queryNewSessionDetail(activeSessionId.value); |
| | | EventBus.emit("queryAppUsageList"); |
| | | EventBus.emit('queryAppUsageList'); |
| | | } |
| | | break; |
| | | } |
| | |
| | | loading.value = false; |
| | | }; |
| | | |
| | | |
| | | |
| | | const stopChat = async () => { |
| | | // const { code, data } = await stopChatApi(activeSessionId.value); |
| | | // if (code === 200) { |
| | |
| | | loading.value = false; |
| | | chatDis.value = false; |
| | | isStopChat.value = true; |
| | | console.log("stopChat"); |
| | | console.log(displayedText.value, "displayedText"); |
| | | console.log(sessionDetailList.value, "sessionDetailList"); |
| | | let inputText = sessionDetailList.value[sessionDetailList.value.length - 2].content; |
| | | console.log('stopChat'); |
| | | console.log(displayedText.value, 'displayedText'); |
| | | console.log(sessionDetailList.value, 'sessionDetailList'); |
| | | let inputText = |
| | | sessionDetailList.value[sessionDetailList.value.length - 2].content; |
| | | // æ°ç»åå¹¶ |
| | | let lastArr = [{ |
| | | let lastArr = [ |
| | | { |
| | | content: inputText, |
| | | role: "user" |
| | | }, { |
| | | role: 'user', |
| | | }, |
| | | { |
| | | content: displayedText.value, |
| | | role: "assistant" |
| | | }]; |
| | | sessionDetailList.value = sessionDetailList.value.splice(0, sessionDetailList.value.length - 2).concat(lastArr); |
| | | role: 'assistant', |
| | | }, |
| | | ]; |
| | | sessionDetailList.value = sessionDetailList.value |
| | | .splice(0, sessionDetailList.value.length - 2) |
| | | .concat(lastArr); |
| | | |
| | | console.log(sessionDetailList.value, "sessionDetailList2"); |
| | | console.log(chatObj, "chatObj对象"); |
| | | console.log(sessionDetailList.value, 'sessionDetailList2'); |
| | | console.log(chatObj, 'chatObj对象'); |
| | | chatObj.message = chatObj.message.concat(lastArr); |
| | | Object.assign(chatDataMeg,{ |
| | | id:chatObj.id, |
| | | conversation_id:chatObj.id, |
| | | message: sessionDetailList.value |
| | | message: sessionDetailList.value, |
| | | }); |
| | | |
| | | }; |
| | | |
| | | const setChatDataMeg = async(chatData) => { |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | const queryNewSessionDetail = async (id) => { |
| | | activeSessionId.value = id; |
| | | const { code, data } = await getSessionDetailsApi(id); |
| | | if (code === 200) { |
| | | console.log(data, "æ°å»ºä¼è¯è¯¦æ
"); |
| | | console.log(data, 'æ°å»ºä¼è¯è¯¦æ
'); |
| | | Object.assign(chatObj, data); |
| | | sessionDetailList.value = data.message; |
| | | messagenList.value = data; |
| | | agentTitle.value = data.name; |
| | | refreshScroll(); //å·æ°æ»å¨æ¡ä½ç½® |
| | | isStopChat.value = false; |
| | |
| | | |
| | | const changeAgentType = (val, session) => { |
| | | agentType.value = val; |
| | | console.log(val, "val"); |
| | | console.log(val, 'val'); |
| | | }; |
| | | |
| | | const querySessionDetail = async (session) => { |
| | |
| | | const { code, data } = await getSessionDetailsApi(session.id); |
| | | if (code === 200) { |
| | | sessionDetailList.value = data.message; |
| | | messagenList.value = data; |
| | | refreshScroll(); //å·æ°æ»å¨æ¡ä½ç½® |
| | | } |
| | | }; |
| | |
| | | const scrollbar = ref(null); |
| | | const refreshScroll = () => { |
| | | nextTick(() => { |
| | | const container = document.getElementById("home"); |
| | | const container = document.getElementById('home'); |
| | | scrollbar.value.scrollTop(container.scrollHeight); |
| | | }); |
| | | }; |
| | |
| | | activeSessionId.value = data[0].id; //é»è®¤éæ©ç¬¬ä¸ä¸ª |
| | | querySessionDetail(data[0]); |
| | | } else { |
| | | Message.warning("æ¥è¯¢å¤±è´¥"); |
| | | Message.warning('æ¥è¯¢å¤±è´¥'); |
| | | } |
| | | }; |
| | | |
| | |
| | | onBeforeMount(() => { |
| | | // DialogList(); |
| | | //æ°å»ºä¼è¯ |
| | | createSession(""); |
| | | createSession(''); |
| | | }); |
| | | onMounted(() => { |
| | | EventBus.on("newChat", () => { |
| | | agentType.value = "1"; |
| | | createSession(""); |
| | | EventBus.on('newChat', () => { |
| | | agentType.value = '1'; |
| | | createSession(''); |
| | | }); |
| | | }); |
| | | onBeforeUnmount(() => { |
| | | EventBus.off("newChat"); |
| | | EventBus.off('newChat'); |
| | | }); |
| | | |
| | | const appStore = useAppStore(); |
| | |
| | | .icon-user-jpg { |
| | | border: 1px solid #d9d9d9; |
| | | } |
| | | .icon-box { |
| | | display: flex; |
| | | align-items: center; |
| | | box-sizing: border-box; |
| | | background: var(--color-bg-1); |
| | | border: 1px solid var(--color-border-2); |
| | | padding: 10px; |
| | | border-radius: 14px; |
| | | min-width: 200px; |
| | | .icon-text { |
| | | margin-left: 10px; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .right { |