From 4925c00420508426d7d8fc0d73e8f51f0eea9cf2 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 20 八月 2024 11:50:17 +0800 Subject: [PATCH] 修复bug --- src/components/chat/Chat.vue | 39 +++++++++++++++++++++++++++------------ 1 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 90e770b..caf5748 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -50,13 +50,13 @@ v-if="item.role === RoleEnum.assistant && item.content.origin?.ext_call_list" class="flex font-bold items-center mt-6" > - <div class="flex-0 mr-1.5">鍏宠仈鍔熻兘锛�</div> - <div class="flex-0 space-x-5 flex"> + <div class="flex-0 mb-auto -mr-4">鍏宠仈鍔熻兘锛�</div> + <div class="space-x-5 flex flex-wrap"> <div v-for="callItem in item.content.origin?.ext_call_list" :key="callItem.call_ext_id" @click="relativeQueryClick(callItem)" - class="flex-0 cursor-pointer hover:underline" + class="cursor-pointer hover:underline first-of-type:ml-5" > {{ callItem.question }} </div> @@ -119,7 +119,7 @@ </div> </div> - <Loding v-else class="w-fit" :process="process" /> + <Loding v-if="isTalking && index === messageList.length - 1" class="w-fit" :process="process" /> </div> </div> </div> @@ -257,11 +257,25 @@ ElMessage.warning('鍙戦�佸け璐ワ紝鏈‘瀹氬簲鐢ㄥ満鏅紒'); } processId.value = uuidv4(); - const judgeParams = !preQuestion.value - ? {} - : { - prev_question: preQuestion.value, - }; + let judgeParams = null; + if (!preQuestion.value) { + const aiContent = computedMessageList.value.filter((item) => item.role === RoleEnum.assistant); + const lastQuestion = aiContent[aiContent.length - 2]?.content?.origin?.question; + judgeParams = lastQuestion + ? { + prev_question: lastQuestion, + } + : {}; + } else { + judgeParams = { + prev_question: preQuestion.value, + }; + } + // const judgeParams = !preQuestion.value + // ? {} + // : { + // prev_question: preQuestion.value, + // }; const params = { process_id: processId.value, question: text, @@ -307,7 +321,7 @@ }; const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => { - if (!content?.values) return; + if (!content?.values || isTalking.value) return; const isNewChat = messageList.value.length === 0; if (isNewChat) { if (activeSampleId.value) { @@ -339,7 +353,6 @@ const extRes = await extCallQuery(isCallExtParams); questionRes = extRes; resMsgContent = parseContent(extRes); - } else { resMsgContent = await questionAi(content.values); } @@ -351,6 +364,7 @@ cb?.(resMsgContent); } userItem.historyId = questionRes.history_id; + userItem.content.values = questionRes?.question; assistantItem.historyId = questionRes.history_id; appendLastMessageContent(resMsgContent); } catch (error: any) { @@ -391,9 +405,10 @@ currentSampleId = res?.details?.[0]?.sample_id; const resList = await Promise.all((res.details ?? []).map((item) => getAnswerById(item.history_id))); let i = 0; - resList.map((item, index) => { const insertIndex = index + 1 + i; + const userMsg = messageList.value[insertIndex - 1]; + userMsg.content.values = item?.answer?.question; messageList.value.splice( insertIndex, 0, -- Gitblit v1.9.3