From c6d8ea02ade42a78e9f4a2304e8e1c5f67853d91 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 06 三月 2025 16:17:06 +0800 Subject: [PATCH] 创建工单 --- src/components/chat/Chat.vue | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 86d78ed..60c0d18 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -80,9 +80,9 @@ import { useLoadData } from './hooks/useLoadData'; import { useSyncMsg } from './hooks/useSyncMsg'; import { getCurrentPosition } from '/@/utils/brower'; +import { deepClone } from '/@/utils/other'; const containerRef = useCompRef(ChatContainer); const chatListDom = computed(() => containerRef.value?.chatListDom); -const attachFileList = computed(() => playBarRef.value?.attachFileList ?? []); const scrollToBottom = () => { containerRef.value?.scrollToBottom(); }; @@ -92,6 +92,7 @@ parseExtraContent, convertProcessItem, convertProcessToStep, + convertAttach, formatShowTimeYear, getStepGroupList, } = useLoadData(); @@ -142,10 +143,11 @@ raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, ...judgeParams, } as any; - const formDataParams = toFormData(params); - for (const item of attachFileList.value) { - formDataParams.append('files', item.file); + 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: '鑾峰彇浣嶇疆涓�...', @@ -170,7 +172,12 @@ params.sample_id = currentSampleId; currentSampleId = ''; } - + const formDataParams = toFormData(params); + 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; @@ -190,7 +197,7 @@ return isEmpty; }; questionStreamByPost( - params, + formDataParams, (chunkRes) => { Logger.info('chunk response锛歕n\n' + JSON.stringify(chunkRes)); if (chunkRes.mode === 'result') { @@ -219,6 +226,13 @@ triggerRefresh(); return; // chunkRes.value = '鍑嗗鏁版嵁鍒嗘瀽'; + } + + if (chunkRes.mode === 'create_work_order') { + const lastMsg = computedMessageList.value.at(-1); + lastMsg.modeContent = chunkRes; + triggerRefresh(); + return; } if (chunkRes.mode === 'summary') { @@ -270,10 +284,12 @@ if (chunkRes.mode === 'conclusion') { const lastReport = computedMessageList.value.at(-1)?.content?.values?.at(-1); + if (lastReport) { lastReport.conclusion = chunkRes.value; - chunkRes.value = '鍒嗘瀽缁撴潫'; } + chunkRes.value = '鍒嗘瀽缁撴潫'; + } const getLastGroup = () => { const lastGroup = computedMessageList.value.at(-1).stepGroup[0]; @@ -345,7 +361,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') { @@ -380,12 +398,14 @@ const content = parseContent(questionRes, true); return content; }; - -const clearMessageContent = () => - (messageContent.value = { +const playBarRef = useCompRef(PlayBar); +const attachList = computed(() => playBarRef.value?.attachList ?? []); +const clearMessageContent = () => { + messageContent.value = { type: AnswerType.Text, values: '', - }); + }; +}; let currentSampleId = ''; @@ -412,7 +432,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: deepClone(attachList.value) } as any; const assistantItem: ChatMessage = { role: RoleEnum.assistant, content: { @@ -425,6 +445,7 @@ isShow: true, }, ], + isStopMsg: false, isChecked: false, } as any; @@ -434,6 +455,13 @@ messageList.value.push(assistantItem); scrollToBottom(); return [userItem, assistantItem]; +}; + +/** + * 娓呴櫎闄勪欢 + */ +const clearAttach = () => { + playBarRef.value?.clearAttach(); }; const sendChatMessage = async (content: ChatContent = messageContent.value) => { @@ -538,6 +566,7 @@ type: AnswerType.Text, values: msgValue.question, }, + attachList: convertAttach(msgValue), isChecked: false, }; @@ -595,7 +624,6 @@ messageContent.value.values = content; }; //#endregion -const playBarRef = useCompRef(PlayBar); //鐢ㄦ埛闂璁剧疆涓哄父鐢ㄨ const setCommonPhraseClick = (item) => { playBarRef.value.addPhrase(item); -- Gitblit v1.9.3