From a656cfbcd0fea1048a633434f1e530fe40d4e3a0 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期三, 25 九月 2024 11:07:10 +0800 Subject: [PATCH] Merge branch 'test' of http://47.103.154.90:83/r/WI/Web.V1.0 into test --- src/components/chat/Chat.vue | 46 +++++++++++++++++++++++++++++++--------------- 1 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 6cc5deb..1a85964 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -250,12 +250,13 @@ }; const { clearQueryProcess, process, processId, queryProcess } = useQueryProcess(); +const DEFAULT_SECTION_A_ID = 'knowledge_base'; let questionRes = null; + +let finalCalcSectionAId = null; const questionAi = async (text) => { - if (!currentSectionId) { - ElMessage.warning('鍙戦�佸け璐ワ紝鏈‘瀹氬簲鐢ㄥ満鏅紒'); - } + processId.value = uuidv4(); let judgeParams = null; if (!preQuestion.value) { @@ -273,12 +274,21 @@ prev_question: preQuestion.value, }; } + let currentSectionAId = ''; + if (activeSectionAId.value) { + currentSectionAId = activeSectionAId.value; + activeSectionAId.value = ''; + } else { + const lastSectionAItem = _.findLast(computedMessageList.value as any, (item) => item.role === RoleEnum.assistant && !!item.sectionAId); + currentSectionAId = lastSectionAItem?.sectionAId ?? DEFAULT_SECTION_A_ID; + } + finalCalcSectionAId = currentSectionAId; const params = { process_id: processId.value, question: text, // FIXME: 鏆傛椂杩欐牱 - section_a_id: currentSectionId, + section_a_id: currentSectionAId, history_group_id: currentRouteId, raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, ...judgeParams, @@ -286,11 +296,12 @@ if (currentSampleId) { params.sample_id = currentSampleId; + currentSampleId = ''; } - if (currentLLMId) { - params.llm_id = currentLLMId; - } + // if (currentLLMId) { + // params.llm_id = currentLLMId; + // } clearQueryProcess(); queryProcess(); const res = await QuestionAi(params).finally(() => { @@ -307,8 +318,7 @@ values: '', }); -let currentSectionId = null; -let currentSampleId = null; +let currentSampleId = ''; let currentLLMId = null; @@ -330,9 +340,7 @@ currentLLMId = activeLLMId.value; } - if (activeSectionAId.value) { - currentSectionId = activeSectionAId.value; - } + } let resMsgContent: ChatContent = null; @@ -364,6 +372,7 @@ userItem.historyId = questionRes.history_id; userItem.content.values = questionRes?.question ?? userItem.content.values; assistantItem.historyId = questionRes.history_id; + assistantItem.sectionAId = finalCalcSectionAId; appendLastMessageContent(resMsgContent); } catch (error: any) { // appendLastMessageContent({ @@ -399,9 +408,14 @@ }, } as ChatMessage; }); - currentSectionId = res?.details?.[0]?.section_a_id; - currentSampleId = res?.details?.[0]?.sample_id; - const resList = await Promise.all((res.details ?? []).map((item) => getAnswerById(item.history_id))); + const sectionAIdMap = new Map(); + + const resList = await Promise.all( + (res.details ?? []).map((item) => { + sectionAIdMap.set(item.history_id, item.section_a_id); + return getAnswerById(item.history_id); + }) + ); let i = 0; resList.map((item, index) => { const insertIndex = index + 1 + i; @@ -417,6 +431,8 @@ role: RoleEnum.assistant, content: parseContent(item.answer), state: item.answer_state, + sectionAId: sectionAIdMap.get(item.answer.history_id), + } ); i++; -- Gitblit v1.9.3