| | |
| | | </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> |
| | |
| | | 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) => { |
| | |
| | | }; |
| | | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | 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, |
| | |
| | | ); |
| | | i++; |
| | | }); |
| | | |
| | | |
| | | if (messageList.value.length === 0) { |
| | | messageContent.value = { |