| | |
| | | <span class="ywifont ywicon-loading1 animate-spin !text-[24px]"></span> |
| | | </template> |
| | | <template #title> |
| | | <span class="text-sm">{{ subItem.title }}</span> |
| | | <span class="text-sm">{{ subItem.title }}<span v-if="subItem.ms" class="text-green-600">{{ `(${subItem.ms})` }}</span></span> |
| | | </template> |
| | | </el-step> |
| | | </el-steps> |
| | |
| | | import { ErrorCode } from '/@/utils/request'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import useClipboard from 'vue-clipboard3'; |
| | | import { toMyFixed, toPercent } from '/@/utils/util'; |
| | | const chatWidth = '75%'; |
| | | const voicePageIsShow = ref(false); |
| | | let isTalking = ref(false); |
| | |
| | | const computedMessageList = computed(() => { |
| | | return messageList.value.filter((v) => !!v); |
| | | }); |
| | | const parseContent = (res) => { |
| | | const parseContent = (res, reportIsShow = false) => { |
| | | if (!res) return null; |
| | | let content: ChatContent = { |
| | | type: AnswerType.Text, |
| | |
| | | case AnswerType.Summary: |
| | | content = { |
| | | type: AnswerType.Summary, |
| | | values: res.summary, |
| | | values: res.summary?.map((item) => { |
| | | item.reportIsShow = reportIsShow; |
| | | return item; |
| | | }), |
| | | }; |
| | | break; |
| | | case AnswerType.Url: |
| | |
| | | // queryProcess(); |
| | | resetStep(); |
| | | let res = null; |
| | | |
| | | let lastTimestamp = new Date().getTime(); |
| | | const resultP = new Promise(async (resolve, reject) => { |
| | | await questionStreamByPost(params, (chunkRes) => { |
| | | Logger.info('chunk response:\n\n' + JSON.stringify(chunkRes)); |
| | |
| | | computedMessageList.value.at(-1).conclusion = chunkRes.value; |
| | | chunkRes.value = '分析结束'; |
| | | } |
| | | |
| | | const stepList = computedMessageList.value.at(-1).stepList; |
| | | const currentTimeStamp = new Date().getTime(); |
| | | const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms'; |
| | | if (chunkRes.mode === 'finish') { |
| | | const title = stepList.at(-1).title; |
| | | // stepList.at(-1).title = `${title}(${ms})`; |
| | | stepList.at(-1).ms = ms; |
| | | |
| | | isTalking.value = false; |
| | | return; |
| | | } |
| | | |
| | | if (stepList?.length >= 1) { |
| | | const title = stepList.at(-1).title; |
| | | // stepList.at(-1).title = `${title}(${ms})`; |
| | | stepList.at(-1).ms = ms; |
| | | |
| | | } |
| | | lastTimestamp = currentTimeStamp; |
| | | |
| | | const stepItem = convertProcessItem(chunkRes); |
| | | computedMessageList.value.at(-1).stepList.push(stepItem); |
| | | stepList.push(stepItem); |
| | | scrollToBottom(); |
| | | }) |
| | | .catch((err) => { |
| | |
| | | }); |
| | | |
| | | questionRes = await resultP; |
| | | const content = parseContent(res); |
| | | const content = parseContent(res, true); |
| | | return content; |
| | | }; |
| | | |
| | |
| | | if (isCallExtParams) { |
| | | const extRes = await extCallQuery(isCallExtParams); |
| | | questionRes = extRes; |
| | | resMsgContent = parseContent(extRes); |
| | | resMsgContent = parseContent(extRes, true); |
| | | } else { |
| | | resMsgContent = await questionAi(content.values); |
| | | } |