| | |
| | | configArcoResolverPlugin(), |
| | | configImageminPlugin(), |
| | | ], |
| | | server: { |
| | | open: true, // 项目启动后,自动打开 |
| | | fs: { |
| | | strict: true, |
| | | }, |
| | | proxy: { |
| | | '/base': { |
| | | target: 'http://192.168.20.116:8089', |
| | | changeOrigin: true, |
| | | ws: true, |
| | | }, |
| | | '/api': { |
| | | target: 'http://192.168.20.116:8089', |
| | | changeOrigin: true, |
| | | ws: true, |
| | | }, |
| | | '/api/v1': { |
| | | target: 'http://192.168.20.116:8089', |
| | | changeOrigin: true, |
| | | ws: true, |
| | | }, |
| | | }, |
| | | }, |
| | | build: { |
| | | rollupOptions: { |
| | | output: { |
| | |
| | | "prepare": "husky install" |
| | | }, |
| | | "lint-staged": { |
| | | "*.{js,ts,jsx,tsx}": [ |
| | | |
| | | |
| | | ], |
| | | "*.vue": [ |
| | | |
| | | |
| | | ], |
| | | "*.{less,css}": [ |
| | | |
| | | ] |
| | | "*.{js,ts,jsx,tsx}": [], |
| | | "*.vue": [], |
| | | "*.{less,css}": [] |
| | | }, |
| | | "pnpm": { |
| | | "overrides": { |
| | |
| | | "axios": "^0.24.0", |
| | | "dayjs": "^1.11.5", |
| | | "echarts": "^5.4.0", |
| | | "eventsource-parser": "^2.0.1", |
| | | "js-base64": "^3.7.5", |
| | | "jsencrypt": "^3.3.2", |
| | | "lodash": "^4.17.21", |
| | |
| | | import { useAppStore } from '@/store'; |
| | | import { computed, nextTick, onMounted, reactive, ref } from 'vue'; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | import { EventSourceParserStream } from 'eventsource-parser/stream'; |
| | | import moment from 'moment'; |
| | | import AddSession from '@/views/session/sessionManager/components/addSession.vue'; |
| | | import { |
| | |
| | | getSessionDetailsApi, |
| | | sessionListApi, |
| | | } from '@/api/session'; |
| | | import { getAuthorization } from "@/utils/auth"; |
| | | |
| | | |
| | | const sessionDetailList = ref([]); //根据会话id出来的会话详情 |
| | | const sessionList = ref([]); //会话列表 |
| | |
| | | return; |
| | | } |
| | | if (inputMsg.value) { |
| | | const data = await chatApi({ |
| | | conversation_id: activeSessionId.value, |
| | | messages: inputMsg.value, |
| | | sessionDetailList.value.push({ "content": inputMsg.value, "role": "user" }); |
| | | sessionDetailList.value.push({ "role": "last" }); |
| | | refreshScroll(); |
| | | const response = await fetch("/api/tech/cloudminds/query?modeltype=localragflow", { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Authorization': getAuthorization(), |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | body: JSON.stringify({ |
| | | conversation_id: activeSessionId.value, |
| | | messages: inputMsg.value, |
| | | }), |
| | | }); |
| | | if (data) { |
| | | chatDis.value = false; |
| | | |
| | | // inputMsg.value = ''; |
| | | // querySessionDetail({ id: activeSessionId.value }); |
| | | } |
| | | const res = await getSessionDetailsApi(activeSessionId.value); |
| | | if (res.code === 200) { |
| | | sessionDetailList.value = res.data.message.map((item, index) => { |
| | | if (index === res.data.message.length - 1) { |
| | | item.role = 'last'; |
| | | displayedText.value = ''; |
| | | currIndex.value = 0; |
| | | streamStr.value = item.content; |
| | | startDisplayStr(); |
| | | const reader = response?.body |
| | | ?.pipeThrough(new TextDecoderStream()) |
| | | .pipeThrough(new EventSourceParserStream()) |
| | | .getReader(); |
| | | currIndex.value = 0; |
| | | while (true) { |
| | | const x = await reader?.read(); |
| | | if (x) { |
| | | const { done, value } = x; |
| | | try { |
| | | const val = JSON.parse(value?.data || ''); |
| | | const d = val?.data; |
| | | if (typeof d !== "boolean") { |
| | | |
| | | console.info("data:", d); |
| | | streamStr.value = d.content; |
| | | startDisplayStr(); |
| | | } |
| | | } catch (e) { |
| | | console.warn(e); |
| | | } |
| | | return item; |
| | | }); |
| | | refreshScroll(); |
| | | if (done) { |
| | | console.info('done'); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | chatDis.value=false; |
| | | inputMsg.value = ''; |
| | | } else { |
| | | Message.warning('消息不能为空'); |
| | |
| | | displayedText.value += res[currIndex.value]; |
| | | currIndex.value++; |
| | | setTimeout(startDisplayStr, 100); |
| | | refreshScroll(); |
| | | } else { |
| | | clearTimeout(timer!); |
| | | timer = null; |
| | |
| | | resolved "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-5.0.1.tgz" |
| | | integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== |
| | | |
| | | eventsource-parser@^2.0.1: |
| | | version "2.0.1" |
| | | resolved "https://registry.npmmirror.com/eventsource-parser/-/eventsource-parser-2.0.1.tgz#6464341d64de5bea9f31d8063dd312b616146c7a" |
| | | integrity sha512-gMaRLm5zejEH9mNXC54AnIteFI9YwL/q5JKMdBnoG+lEI1JWVGFVk0Taaj9Xb5SKgzIBDZoQX5IzMe44ILWODg== |
| | | |
| | | exec-buffer@^3.0.0: |
| | | version "3.2.0" |
| | | resolved "https://registry.npmmirror.com/exec-buffer/-/exec-buffer-3.2.0.tgz" |