| | |
| | | import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; |
| | | import { Logger } from '/@/model/logger/Logger'; |
| | | import { triggerRef } from 'vue'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { ElLoadingService, ElMessage } from 'element-plus'; |
| | | import ChatContainer from './components/ChatContainer.vue'; |
| | | import ShareLinkDlg from './components/shareLink/index.vue'; |
| | | import router from '/@/router'; |
| | |
| | | }); |
| | | }; |
| | | |
| | | let streamOutputIsStart = false; |
| | | let position: Position = null; |
| | | const questionAi = async (text) => { |
| | | let judgeParams = null; |
| | | if (!preQuestion.value) { |
| | |
| | | raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, |
| | | ...judgeParams, |
| | | } as any; |
| | | // const position = await getCurrentPosition(); |
| | | |
| | | // if (!position) { |
| | | // const loadingInstance = ElLoadingService({ |
| | | // text: '获取位置中...', |
| | | // target: '.layout-parent', |
| | | // fullscreen:false, |
| | | // }); |
| | | // position = await getCurrentPosition().finally(() => { |
| | | // loadingInstance.close(); |
| | | // }); |
| | | // } |
| | | |
| | | // if (position) { |
| | | // const { latitude, longitude } = position; |
| | |
| | | params, |
| | | (chunkRes) => { |
| | | Logger.info('chunk response:\n\n' + JSON.stringify(chunkRes)); |
| | | |
| | | if (chunkRes.mode === 'result') { |
| | | lastIsResult = true; |
| | | const res = chunkRes.value; |
| | |
| | | const lastGroup = computedMessageList.value.at(-1).stepGroup[0]; |
| | | const stepList = lastGroup?.value ?? []; |
| | | const currentTimeStamp = new Date().getTime(); |
| | | const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms'; |
| | | if (chunkRes.mode === 'finish') { |
| | | const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms'; |
| | | stepList.at(-1).ms = ms; |
| | | isTalking.value = false; |
| | | streamOutputIsStart = false; |
| | | return; |
| | | } |
| | | |
| | | if (stepList?.length >= 1) { |
| | | if (stepList?.length >= 1 && !streamOutputIsStart) { |
| | | const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms'; |
| | | |
| | | stepList.at(-1).ms = ms; |
| | | } else { |
| | | const stepGroup = computedMessageList.value.at(-1).stepGroup; |
| | | if (stepGroup.length > 1) { |
| | | const lastStepList = stepGroup.at(-2).value; |
| | | const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms'; |
| | | |
| | | lastStepList.at(-1).ms = ms; |
| | | } |
| | | } |
| | | lastTimestamp = currentTimeStamp; |
| | | const stepItem = convertProcessItem(chunkRes); |
| | | |
| | | stepList.push(stepItem); |
| | | if (!streamOutputIsStart) { |
| | | lastTimestamp = currentTimeStamp; |
| | | } |
| | | if (!streamOutputIsStart) { |
| | | const stepItem = convertProcessItem(chunkRes); |
| | | stepList.push(stepItem); |
| | | } else { |
| | | const lastItem = stepList.at(-1); |
| | | lastItem.title += chunkRes.value ?? ''; |
| | | } |
| | | |
| | | if (chunkRes.mode === 'begin_stream') { |
| | | streamOutputIsStart = true; |
| | | lastTimestamp = currentTimeStamp; |
| | | } |
| | | if (chunkRes.mode === 'end_stream') { |
| | | streamOutputIsStart = false; |
| | | } |
| | | |
| | | // 强制触发更新 |
| | | |
| | | scrollToBottom(); |