yangyin
2024-07-15 78137be892b6810b54ba70f27c28a69a7179e603
src/components/chat/Chat.vue
@@ -8,7 +8,7 @@
               <div class="flex">
                  <div class="relative" v-if="item.content?.values">
                     <div class="text-sm rounded-[6px] p-4 leading-relaxed max-w-[100ch] bg-white">
                        <component class="max-w-[100ch]" :is="answerTypeMapCom[item.content.type]" :data="item.content.values" />
                        <component class="max-w-[100ch]" :is="answerTypeMapCom[item.content.type]" :data="item.content.values" :error="item.content.error"/>
                     </div>
                     <div v-if="item.role === RoleEnum.assistant" class="absolute flex items-center right-0 mr-2 mt-2 space-x-2">
@@ -57,7 +57,7 @@
import { GetHistoryAnswer, QueryHistoryDetail, QuestionAi, SetHistoryAnswerState, getQuestionProcess } from '/@/api/ai/chat';
import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue';
import router from '/@/router';
import { activeChatRoom, activeLLMId, activeRoomId, activeSampleId, activeSectionAId } from '/@/stores/chatRoom';
import { activeChatRoom, activeLLMId, activeRoomId, activeSampleId, activeSectionAId, roomConfig } from '/@/stores/chatRoom';
import { v4 as uuidv4 } from 'uuid';
let isTalking = ref(false);
@@ -103,6 +103,7 @@
         content = {
            type: AnswerType.Summary,
            values: res.summary,
            error: res.error,
         };
         break;
      default:
@@ -159,6 +160,7 @@
      // FIXME: 暂时这样
      section_a_id: currentSectionId,
      history_group_id: currentRouteId,
      raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false,
   } as any;
   if (currentSampleId) {
@@ -191,14 +193,16 @@
let currentSampleId = null;
let currentLLMId = null;
const getAnswerById = async (historyId: string) => {
   return await GetHistoryAnswer({
      history_id: historyId,
   });
};
const sendChatMessage = async (content: ChatContent = messageContent.value) => {
   if (!messageContent.value?.values) return;
   if (messageList.value.length===0) {
   if (messageList.value.length === 0) {
      if (activeSampleId.value) {
         currentSampleId = activeSampleId.value;
      }
@@ -243,7 +247,6 @@
      messageList.value.at(-1).content = content;
   }
};
onMounted(async () => {
   const res = await QueryHistoryDetail({
@@ -297,10 +300,10 @@
   }
);
onActivated(()=>{
onActivated(() => {
   if (forbidScroll) return;
   nextTick(() => scrollToBottom());
})
});
//#region ====================== 聊天内容操作 ======================