From 5b29175507ba6bb9a0f29573aebc6e6dd8fe6eef Mon Sep 17 00:00:00 2001 From: gerson <1405270578@qq.com> Date: 星期日, 21 七月 2024 16:59:28 +0800 Subject: [PATCH] fix_question --- vite.config.ts | 2 +- src/components/chat/Chat.vue | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 0824dbf..8e52c0c 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -23,7 +23,29 @@ class="text-sm rounded-[6px] p-4 leading-relaxed" :style="{ backgroundColor: item.role === RoleEnum.user ? 'rgb(197 224 255)' : 'white' }" > - <div v-if="item.content.errCode === ErrorCode.Message" class="text-red-500 w-full">{{ item.content.msg }}</div> + <div v-if="item.content.errCode === ErrorCode.Message" class="flex-column w-full"> + <p class="text-red-500"> + {{ item.content.msg }} + </p> + <div + class="mt-3 flex w-2/3 self-end items-center" + v-if="showFixQuestion && index === computedMessageList.length - 1" + > + <div class="text-gray-600 ml-auto flex-0"> + {{ computedMessageList.at(-1).content.origin.err_json.fix_question.title + '锛�' }} + </div> + <div class="ml-1 space-x-2 inline-flex flex-wrap"> + <div + v-for="item in computedMessageList.at(-1).content.origin.err_json.fix_question?.values" + :key="item" + class="bg-gray-200 p-3 hover:bg-[#c5e0ff] hover:text-[#1c86ff] cursor-pointer rounded-lg" + @click="fixQuestionClick(item)" + > + {{ item.title }} + </div> + </div> + </div> + </div> <component v-else :is="answerTypeMapCom[item.content.type]" :data="item.content.values" :originData="item" /> </div> @@ -156,6 +178,12 @@ return isShow; }); +const showFixQuestion = computed(() => { + if (!computedMessageList.value || computedMessageList.value.length === 0) return false; + const last = computedMessageList.value.at(-1); + const isShow = last?.role === RoleEnum.assistant && last?.content?.values && last.content?.origin?.err_json?.fix_question; + return isShow; +}); const parseContent = (res) => { if (!res) return null; let content: ChatContent = { @@ -248,6 +276,7 @@ //#endregion +let isNextChat = false; let questionRes = null; const questionAi = async (text) => { if (!currentSectionId) { @@ -261,6 +290,7 @@ section_a_id: currentSectionId, history_group_id: currentRouteId, raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, + next_chat: isNextChat, } as any; if (currentSampleId) { @@ -365,6 +395,19 @@ sendChatMessage({ type: AnswerType.Text, values: item.question }); }; +const fixQuestionClick = (item) => { + if (!item.question) return; + isNextChat = true; + try { + sendChatMessage({ + type: AnswerType.Text, + values: item.question, + }); + } finally { + isNextChat = false; + } +}; + onMounted(async () => { const res = await QueryHistoryDetail({ history_group_id: currentRouteId, diff --git a/vite.config.ts b/vite.config.ts index 3cdb41a..e9c23f4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,7 +35,7 @@ host: '0.0.0.0', port: env.VITE_PORT as unknown as number, open: JSON.parse(env.VITE_OPEN), - hmr: false, + hmr: true, }, build: { // outDir: 'dist/' + mode.mode, -- Gitblit v1.9.3