| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { computed, nextTick, onMounted, ref, watch } from 'vue'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { computed, nextTick, ref, watch } from 'vue'; |
| | | import useClipboard from 'vue-clipboard3'; |
| | | import Loding from './components/Loding.vue'; |
| | | import { RecordSet } from './model/Record'; |
| | | import type { ChatContent } from './model/types'; |
| | | import { AnswerType, RoleEnum, answerTypeMapCom, roleImageMap, type ChatMessage } from './model/types'; |
| | | import { GetHistoryAnswer, QueryHistoryDetail, QuestionAi } from '/@/api/ai/chat'; |
| | | import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; |
| | | import router from '/@/router'; |
| | | import { activeChatRoom, activeRoomId } from '/@/stores/chatRoom'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { content } from 'html2canvas/dist/types/css/property-descriptors/content'; |
| | | import { activeChatRoom, activeLLMId, activeRoomId, activeSampleId, activeSectionAId } from '/@/stores/chatRoom'; |
| | | |
| | | let isTalking = ref(false); |
| | | let messageContent = ref<ChatContent>({ |
| | |
| | | }; |
| | | |
| | | const questionAi = async (text) => { |
| | | const res = await QuestionAi({ |
| | | if (!currentSectionId) { |
| | | ElMessage.warning('发送失败,未确定应用场景!'); |
| | | } |
| | | |
| | | const params = { |
| | | question: text, |
| | | // FIXME: 暂时这样 |
| | | section_a_id: 'undefined', |
| | | section_a_id: currentSectionId, |
| | | history_group_id: activeRoomId.value, |
| | | }); |
| | | } as any; |
| | | |
| | | if (currentSampleId) { |
| | | params.sample_id = currentSampleId; |
| | | } |
| | | |
| | | if (currentLLMId) { |
| | | params.llm_id = currentLLMId; |
| | | } |
| | | |
| | | const res = await QuestionAi(params); |
| | | // const res = { |
| | | // json_ok: true, |
| | | // question: '昨日五一广场压力', |
| | |
| | | if (!chatListDom.value) return; |
| | | chatListDom.value.lastElementChild?.scrollIntoView(); |
| | | }; |
| | | let currentSectionId = null; |
| | | let currentSampleId = null; |
| | | |
| | | let currentLLMId = null; |
| | | const getAnswerById = async (historyId: string) => { |
| | | return await GetHistoryAnswer({ |
| | | history_id: historyId, |
| | |
| | | if (activeChatRoom.value.isInitial) { |
| | | activeChatRoom.value.title = messageContent.value.values; |
| | | activeChatRoom.value.isInitial = false; |
| | | if (activeSampleId.value) { |
| | | currentSampleId = activeSampleId.value; |
| | | } |
| | | |
| | | if (activeLLMId.value) { |
| | | currentLLMId = activeLLMId.value; |
| | | } |
| | | |
| | | if (activeSectionAId.value) { |
| | | currentSectionId = activeSectionAId.value; |
| | | } |
| | | } |
| | | try { |
| | | isTalking.value = true; |
| | |
| | | } |
| | | }; |
| | | const appendLastMessageContent = (content: ChatContent) => { |
| | | if(messageList.value.at(-1)){ |
| | | if (messageList.value.at(-1)) { |
| | | messageList.value.at(-1).content = content; |
| | | |
| | | } |
| | | }; |
| | | let currentSectionId = ''; |
| | | |
| | | watch( |
| | | () => activeRoomId.value, |
| | | async (val) => { |
| | |
| | | type: AnswerType.Text, |
| | | values: activeChatRoom.value.title, |
| | | }; |
| | | console.log("🚀 ~ activeChatRoom.value.title:", activeChatRoom.value.title) |
| | | sendChatMessage(); |
| | | } else { |
| | | const res = await QueryHistoryDetail({ |
| | |
| | | } as ChatMessage; |
| | | }); |
| | | currentSectionId = res?.details?.[0]?.section_a_id; |
| | | currentSampleId = res?.details?.[0]?.sample_id; |
| | | const resList = await Promise.all((res.details ?? []).map((item) => getAnswerById(item.history_id))); |
| | | let i = 0; |
| | | |