From c56ba92667b2b5dded272fb60ad0c2af4983cd43 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期三, 05 三月 2025 17:09:55 +0800 Subject: [PATCH] 修改意见 --- src/components/chat/Chat.vue | 42 ++++++++++++++++++++++++++++-------------- 1 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 1878d17..411f287 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -82,7 +82,6 @@ import { getCurrentPosition } from '/@/utils/brower'; const containerRef = useCompRef(ChatContainer); const chatListDom = computed(() => containerRef.value?.chatListDom); -const attachFileList = computed(() => playBarRef.value?.attachFileList ?? []); const scrollToBottom = () => { containerRef.value?.scrollToBottom(); }; @@ -92,6 +91,7 @@ parseExtraContent, convertProcessItem, convertProcessToStep, + convertAttach, formatShowTimeYear, getStepGroupList, } = useLoadData(); @@ -142,10 +142,11 @@ raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, ...judgeParams, } as any; - if(businessTableData.value?.length > 0) { - params.tables = JSON.stringify(businessTableData.value); + const tableList = attachList.value.filter((item) => item.type === 'table').map((item) => item.model); + if (tableList?.length > 0) { + params.tables = JSON.stringify(tableList); } - + // if (!position) { // const loadingInstance = ElLoadingService({ // text: '鑾峰彇浣嶇疆涓�...', @@ -171,9 +172,11 @@ currentSampleId = ''; } const formDataParams = toFormData(params); - for (const item of attachFileList.value) { + const fileList = attachList.value.filter((item) => item.type === 'file').map((item) => item.model); + for (const item of fileList) { formDataParams.append('files', item.file); } + // clearAttach(); let lastTimestamp = new Date().getTime(); questionRes = {}; let lastIsResult = false; @@ -273,9 +276,10 @@ if (chunkRes.mode === 'conclusion') { const lastReport = computedMessageList.value.at(-1)?.content?.values?.at(-1); + chunkRes.value = '鍒嗘瀽缁撴潫'; + if (lastReport) { lastReport.conclusion = chunkRes.value; - chunkRes.value = '鍒嗘瀽缁撴潫'; } } const getLastGroup = () => { @@ -348,7 +352,9 @@ stepList.push(stepItem); } else { const lastItem = stepList.at(-1); - lastItem.title += chunkRes.value ?? ''; + if (lastItem) { + lastItem.title += chunkRes.value ?? ''; + } } if (chunkRes.mode === 'begin_stream') { @@ -384,14 +390,13 @@ return content; }; const playBarRef = useCompRef(PlayBar); -const businessTableData = computed(() => playBarRef.value?.businessTableData ?? []); -const clearMessageContent = () => - (messageContent.value = { +const attachList = computed(() => playBarRef.value?.attachList ?? []); +const clearMessageContent = () => { + messageContent.value = { type: AnswerType.Text, values: '', - }); - playBarRef.value?.clearFileList(); - playBarRef.value?.clearBusinessTable(); + }; +}; let currentSampleId = ''; @@ -418,7 +423,7 @@ const addChatItem = (content: ChatContent) => { isTalking.value = true; - const userItem: ChatMessage = { role: RoleEnum.user, content, isChecked: false } as any; + const userItem: ChatMessage = { role: RoleEnum.user, content, isChecked: false, attachList: attachList.value } as any; const assistantItem: ChatMessage = { role: RoleEnum.assistant, content: { @@ -431,6 +436,7 @@ isShow: true, }, ], + isStopMsg: false, isChecked: false, } as any; @@ -440,6 +446,13 @@ messageList.value.push(assistantItem); scrollToBottom(); return [userItem, assistantItem]; +}; + +/** + * 娓呴櫎闄勪欢 + */ +const clearAttach = () => { + playBarRef.value?.clearAttach(); }; const sendChatMessage = async (content: ChatContent = messageContent.value) => { @@ -544,6 +557,7 @@ type: AnswerType.Text, values: msgValue.question, }, + attachList: convertAttach(msgValue), isChecked: false, }; -- Gitblit v1.9.3