wujingjing
2024-08-21 fc9588232496a15bc0ee754d0d3ffe54103928e0
src/components/chat/Chat.vue
@@ -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>
@@ -186,18 +186,7 @@
const chatListDom = ref<HTMLDivElement>();
const messageList = ref<ChatMessage[]>([]);
const computedMessageList = computed(() => {
   for (let index = 0; index < messageList.value.length; index++) {
      const item = messageList.value[index];
      if(item.role===RoleEnum.assistant){
         continue
      }
      item.content.values = messageList.value[index+1]?.content?.origin?.question;
   }
   const filterList =  messageList.value.filter((v) => !!v);
   return filterList;
   return messageList.value.filter((v) => !!v);
});
const parseContent = (res) => {
@@ -332,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) {
@@ -375,6 +364,7 @@
         cb?.(resMsgContent);
      }
      userItem.historyId = questionRes.history_id;
      userItem.content.values = questionRes?.question ?? userItem.content.values;
      assistantItem.historyId = questionRes.history_id;
      appendLastMessageContent(resMsgContent);
   } catch (error: any) {
@@ -415,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 ??userMsg.content.values;
      messageList.value.splice(
         insertIndex,
         0,
@@ -432,7 +423,6 @@
      );
      i++;
   });
   if (messageList.value.length === 0) {
      messageContent.value = {