From c61ac3dd641437191fc0c41a28a590b9c8921650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E9=B8=BF=E5=AE=87?= Date: Wed, 11 Jun 2025 11:23:10 +0800 Subject: [PATCH] chore: clean code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史鸿宇 --- electron/welcome/welcome.html | 47 ++-- package.json | 2 +- scripts/utils.ts | 54 ++-- src/App.vue | 3 +- src/apis/paths/conversation.ts | 2 +- src/apis/paths/knowledge.ts | 6 +- src/apis/paths/llm.ts | 2 +- src/apis/paths/model.ts | 1 - src/apis/paths/type.ts | 4 +- src/assets/base.css | 2 +- src/assets/styles/codePreview.scss | 62 +---- src/assets/styles/main.scss | 8 +- src/assets/styles/theme.scss | 116 +++++--- src/components/Upload/index.vue | 4 +- src/components/dialoguePanel/DialogueFlow.vue | 61 ++--- .../dialoguePanel/DialoguePanel.scss | 2 +- .../dialoguePanel/hooks/useDialogueActions.ts | 11 +- .../dialoguePanel/hooks/useDialogueWatch.ts | 32 +-- src/components/monaco/MonacoEditor.vue | 2 +- src/components/monaco/yaml.worker.js | 2 +- src/components/sessionCard/type.ts | 6 +- .../yamloutput/yamlContentOutput.jsx | 96 ++++--- .../yamloutput/yamlContentOutput.scss | 14 +- src/router/index.ts | 4 +- src/store/conversation.ts | 255 +++++++++--------- src/store/historySession.ts | 11 +- src/views/chat/Sender.vue | 2 +- src/views/chat/index.vue | 13 +- src/views/createapp/components/appConfig.vue | 44 ++- .../workFlowConfig/CustomSaENode.vue | 5 +- .../workFlowConfig/editFlowName.vue | 40 +-- .../workFlowConfig/workFlowDialog.vue | 8 +- .../dialogue/components/DialogueAside.vue | 4 +- .../dialogue/components/DialogueSession.vue | 192 ++++++------- src/views/dialogue/components/InitalPanel.vue | 6 +- .../dialogue/components/MultiSelectTags.vue | 31 ++- .../dialogue/components/ReportPopover.vue | 2 +- src/views/dialogue/constants.ts | 2 +- src/views/dialogue/types.ts | 11 +- src/views/styles/workFlowArrange.scss | 2 +- 40 files changed, 611 insertions(+), 560 deletions(-) diff --git a/electron/welcome/welcome.html b/electron/welcome/welcome.html index 27d05b0..e242357 100644 --- a/electron/welcome/welcome.html +++ b/electron/welcome/welcome.html @@ -1,25 +1,35 @@ - + - - - - + + + 欢迎使用 openEuler Intelligence - + - +
@@ -27,6 +37,5 @@ - - - \ No newline at end of file + + diff --git a/package.json b/package.json index 8ae6716..5e6b4e2 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build:micro": "vite build --mode micro", "preview": "vite preview", "lint": "eslint . --fix", - "format": "prettier --write src/", + "format": "prettier --write src/ electron/ scripts/", "type-check": "tsc --noEmit", "dev:render": "vite", "dev:preload": "node -r ts-node/register scripts/build-preload --env=development --watch", diff --git a/scripts/utils.ts b/scripts/utils.ts index e07752c..7bb4fb3 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,43 +1,45 @@ -import fs from 'node:fs' -import path from 'node:path' -import chalk from 'chalk' -import { get } from 'http' -import { builtinModules } from 'module' -import { parse as parseEnv } from 'dotenv' +import fs from 'node:fs'; +import path from 'node:path'; +import chalk from 'chalk'; +import { get } from 'http'; +import { builtinModules } from 'module'; +import { parse as parseEnv } from 'dotenv'; export function getEnv(): Record { try { if (getEnv.env) { - return getEnv.env + return getEnv.env; } - const env = parseEnv(fs.readFileSync(path.join(process.cwd(), '.env'))) - return (getEnv.env = env) - } - catch { - return {} + const env = parseEnv(fs.readFileSync(path.join(process.cwd(), '.env'))); + return (getEnv.env = env); + } catch { + return {}; } } -getEnv.env = undefined as Record | undefined +getEnv.env = undefined as Record | undefined; /** node.js builtins module */ export const builtins = () => - builtinModules.filter(x => !/^_|^(internal|v8|node-inspect)\/|\//.test(x)) + builtinModules.filter((x) => !/^_|^(internal|v8|node-inspect)\/|\//.test(x)); // 轮询监听vite启动 -export function waitOn(arg0: { port: string | number, interval?: number }) { +export function waitOn(arg0: { port: string | number; interval?: number }) { return new Promise((resolve) => { - const { port, interval = 149 } = arg0 - const url = `http://localhost:${port}` - let counter = 0 + const { port, interval = 149 } = arg0; + const url = `http://localhost:${port}`; + let counter = 0; const timer: NodeJS.Timer = setInterval(() => { get(url, (res) => { - clearInterval(timer as unknown as number) - console.log('[waitOn]', chalk.green(`"${url}" are already responsive.`)) - resolve(res.statusCode) + clearInterval(timer as unknown as number); + console.log( + '[waitOn]', + chalk.green(`"${url}" are already responsive.`), + ); + resolve(res.statusCode); }).on('error', (error) => { - console.log(error) - console.log('[waitOn]', `counter: ${counter++}`) - }) - }, interval) - }) + console.log(error); + console.log('[waitOn]', `counter: ${counter++}`); + }); + }, interval); + }); } diff --git a/src/App.vue b/src/App.vue index 46ea118..df8c6f2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,6 @@ onMounted(() => { if (window.electronProcess?.platform === 'linux') { isLinuxPlatform.value = true; } - }); @@ -26,7 +25,7 @@ onMounted(() => { - + diff --git a/src/components/dialoguePanel/DialoguePanel.scss b/src/components/dialoguePanel/DialoguePanel.scss index 0f8d6ca..deec3a7 100644 --- a/src/components/dialoguePanel/DialoguePanel.scss +++ b/src/components/dialoguePanel/DialoguePanel.scss @@ -563,4 +563,4 @@ padding: 0 8px; background-color: var(--o-time-text); border-radius: 12px; -} \ No newline at end of file +} diff --git a/src/components/dialoguePanel/hooks/useDialogueActions.ts b/src/components/dialoguePanel/hooks/useDialogueActions.ts index 367484f..a78e4aa 100644 --- a/src/components/dialoguePanel/hooks/useDialogueActions.ts +++ b/src/components/dialoguePanel/hooks/useDialogueActions.ts @@ -3,15 +3,18 @@ import { errorMsg, successMsg } from 'src/components/Message'; import { writeText } from 'src/utils'; import i18n from 'src/i18n'; -export function useDialogueActions(content: Ref, currentSelected: Ref) { +export function useDialogueActions( + content: Ref, + currentSelected: Ref, +) { // 复制文本 const handleCopy = () => { if (!content.value || !Array.isArray(content.value)) { errorMsg(i18n.global.t('feedback.copied_failed')); return; } - if(currentSelected.value) { - writeText(content.value[currentSelected.value]); + if (currentSelected.value) { + writeText(content.value[currentSelected.value]); } successMsg(i18n.global.t('feedback.copied_successfully')); }; @@ -26,4 +29,4 @@ export function useDialogueActions(content: Ref, handleCopy, handleFeedback, }; -} \ No newline at end of file +} diff --git a/src/components/dialoguePanel/hooks/useDialogueWatch.ts b/src/components/dialoguePanel/hooks/useDialogueWatch.ts index 36f8ab6..4ce5d30 100644 --- a/src/components/dialoguePanel/hooks/useDialogueWatch.ts +++ b/src/components/dialoguePanel/hooks/useDialogueWatch.ts @@ -14,20 +14,20 @@ export function useIslikeList(isLikeList: Ref) { isSupport.value = false; isAgainst.value = true; } - }; + }; /** - * 反对 - * @param reason - * @param reasionLink - * @param reasonDescription - */ - watch( - () => isLikeList, - (val, oldVal) => { - handleIsLike(); - }, - ); - return { - isLike, - } -} \ No newline at end of file + * 反对 + * @param reason + * @param reasionLink + * @param reasonDescription + */ + watch( + () => isLikeList, + (val, oldVal) => { + handleIsLike(); + }, + ); + return { + isLike, + }; +} diff --git a/src/components/monaco/MonacoEditor.vue b/src/components/monaco/MonacoEditor.vue index 82dc559..4dc682c 100644 --- a/src/components/monaco/MonacoEditor.vue +++ b/src/components/monaco/MonacoEditor.vue @@ -63,7 +63,7 @@ onMounted(() => { enableSchemaRequest: true, isKubernetes: true, }); - + editor.value = monaco.editor.create(editorContainer.value, { value: props.yamlContent || '', language: 'yaml', diff --git a/src/components/monaco/yaml.worker.js b/src/components/monaco/yaml.worker.js index 36d88a4..33c5d1a 100644 --- a/src/components/monaco/yaml.worker.js +++ b/src/components/monaco/yaml.worker.js @@ -1 +1 @@ -import 'monaco-yaml/yaml.worker.js' \ No newline at end of file +import 'monaco-yaml/yaml.worker.js'; diff --git a/src/components/sessionCard/type.ts b/src/components/sessionCard/type.ts index 825c809..2e5df49 100644 --- a/src/components/sessionCard/type.ts +++ b/src/components/sessionCard/type.ts @@ -19,14 +19,14 @@ export interface SessionItem { appId?: string; debug?: boolean; model?: AddedModalList; - llm?:{ + llm?: { icon: string; modelName: string; - } + }; kbList?: teamKnowledgeList[]; } // 新增接口 -export interface modelItem { +export interface modelItem { icon: string; modelName: string; } diff --git a/src/components/yamloutput/yamlContentOutput.jsx b/src/components/yamloutput/yamlContentOutput.jsx index 3f4541c..fca4b49 100644 --- a/src/components/yamloutput/yamlContentOutput.jsx +++ b/src/components/yamloutput/yamlContentOutput.jsx @@ -1,52 +1,60 @@ import { defineComponent, ref } from 'vue'; import { IconCaretRight } from '@computing/opendesign-icons'; -import './yamlContentOutput.scss' +import './yamlContentOutput.scss'; export default defineComponent({ - name: 'YamlContentOutput', - props:{ - yamlOutPutContent:'' - }, - setup(props) { - const yamlContent = ref(props.yamlOutPutContent); - const handelOpsData = (data) => { - const yamlOutPut = Object.keys(data).map((item) => { - if (typeof data[item] === 'object' && item !== 'items') { - return -
- - - -
-
{item}
-
{data[item].type}
-
-
, - }}> -
{data[item].description}
- {Object.keys(data[item].items || {}).length ? handelOpsData(data[item].items) : null} + name: 'YamlContentOutput', + props: { + yamlOutPutContent: '', + }, + setup(props) { + const yamlContent = ref(props.yamlOutPutContent); + const handelOpsData = (data) => { + const yamlOutPut = Object.keys(data).map((item) => { + if (typeof data[item] === 'object' && item !== 'items') { + return ( + + ( +
+ + + +
+
{item}
+
{data[item].type}
+
+
+ ), + }} + > +
{data[item].description}
+ {Object.keys(data[item].items || {}).length + ? handelOpsData(data[item].items) + : null} +
+
+ ); + } -
-
- } + if (typeof data[item] === 'object' && item === 'items') { + return handelOpsData(data[item]); + } + }); - if (typeof data[item] === 'object' && item === 'items') { - return handelOpsData(data[item]) - } - }); + return yamlOutPut; + }; + return { + handelOpsData: handelOpsData, + yamlContent: yamlContent.value, + }; + }, - return yamlOutPut; - }; - return { - handelOpsData: handelOpsData, - yamlContent: yamlContent.value - }; - }, - - render() { - return
{this.handelOpsData(this.yamlContent)}
; - }, + render() { + return ( +
{this.handelOpsData(this.yamlContent)}
+ ); + }, }); diff --git a/src/components/yamloutput/yamlContentOutput.scss b/src/components/yamloutput/yamlContentOutput.scss index eb194e6..f7b4f00 100644 --- a/src/components/yamloutput/yamlContentOutput.scss +++ b/src/components/yamloutput/yamlContentOutput.scss @@ -1,7 +1,7 @@ .outputContainer { - display: flex; - flex-direction: column; - gap: 8px; + display: flex; + flex-direction: column; + gap: 8px; .el-collapse-item__header { width: fit-content !important; @@ -40,10 +40,10 @@ .yamlTitle { display: flex; align-items: center; - } - .yamlBox,.yamlTitle{ + .yamlBox, + .yamlTitle { padding: 0 !important; height: 16px; display: flex; @@ -56,7 +56,7 @@ align-items: center; } - .yamlKey{ + .yamlKey { height: 16px; line-height: 16px; } @@ -73,7 +73,7 @@ color: var(--o-text-color-secondary); background-color: var(--o-border-color-lighter); } - .el-collapse-item__content{ + .el-collapse-item__content { margin-bottom: 0 !important; } } diff --git a/src/router/index.ts b/src/router/index.ts index 6f2bae5..0cc1a10 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -46,7 +46,7 @@ const staticRoutes: Array = [ { path: '/witchainD', name: 'witchainD', - children:[], // 这里不要添加component内容,否则会导致iframe重复渲染 + children: [], // 这里不要添加component内容,否则会导致iframe重复渲染 }, { path: '/settings', @@ -82,4 +82,4 @@ const router = createRouter({ routes, }); -export default router; \ No newline at end of file +export default router; diff --git a/src/store/conversation.ts b/src/store/conversation.ts index a1bcf30..4dcfa12 100644 --- a/src/store/conversation.ts +++ b/src/store/conversation.ts @@ -11,17 +11,15 @@ import { defineStore } from 'pinia'; import { ref } from 'vue'; import { fetchEventSource } from '@microsoft/fetch-event-source'; -import { - useHistorySessionStore, - useLangStore, -} from 'src/store'; +import { useHistorySessionStore, useLangStore } from 'src/store'; import { AppShowType, FlowDataType, MessageArray, type ConversationItem, type RobotConversationItem, - type UserConversationItem, FlowType, + type UserConversationItem, + FlowType, } from 'src/views/dialogue/types'; import { api } from 'src/apis'; import { successMsg } from 'src/components/Message'; @@ -30,7 +28,7 @@ import { Application } from 'src/apis/paths/type'; import { handleAuthorize } from 'src/apis/tools'; import $bus from 'src/bus/index'; import { useScrollBottom } from '@/hooks/useScrollBottom'; -import { getCookie } from "@/apis/tools"; +import { getCookie } from '@/apis/tools'; import { getBaseProxyUrl } from 'src/utils/tools'; export const echartsObj = ref({}); @@ -72,7 +70,7 @@ export const useSessionStore = defineStore('conversation', () => { const dataTransfers = { textAdd: ( conversationItem: RobotConversationItem, - message: Record + message: Record, ) => { scrollToBottom(); const content = (message.content || {}) as Record; @@ -85,31 +83,24 @@ export const useSessionStore = defineStore('conversation', () => { }, documentAdd: ( conversationItem: RobotConversationItem, - message: Record + message: Record, ) => { conversationItem.message[conversationItem.currentInd] += message.content; - conversationItem.files = [ - ...conversationItem.files, - message.content - ]; + conversationItem.files = [...conversationItem.files, message.content]; }, suggestionFunc: ( conversationItem: RobotConversationItem, - message: Record + message: Record, ) => { if (conversationItem.search_suggestions) { - conversationItem.search_suggestions.push( - Object(message.content), - ); + conversationItem.search_suggestions.push(Object(message.content)); } else { - conversationItem.search_suggestions = [ - Object(message.content), - ]; + conversationItem.search_suggestions = [Object(message.content)]; } }, flowStart: ( conversationItem: RobotConversationItem, - message: Record + message: Record, ) => { const flow = (message.flow || {}) as Record; conversationItem.flowdata = { @@ -125,7 +116,7 @@ export const useSessionStore = defineStore('conversation', () => { }, stepInput: ( conversationItem: RobotConversationItem, - message: Record + message: Record, ) => { const flow = (message.flow || {}) as Record; conversationItem.flowdata?.data[0].push({ @@ -143,7 +134,7 @@ export const useSessionStore = defineStore('conversation', () => { }, stepOutput: ( conversationItem: RobotConversationItem, - message: Record + message: Record, ) => { const flow = (message.flow || {}) as Record; const metadata = (message.metadata || {}) as Record; @@ -155,10 +146,7 @@ export const useSessionStore = defineStore('conversation', () => { target.status = flow.stepStatus; // 工作流添加每阶段的时间耗时 target['costTime'] = metadata.timeCost; - if ( - flow.step_status === 'error' && - conversationItem.flowdata - ) { + if (flow.step_status === 'error' && conversationItem.flowdata) { conversationItem.flowdata.status = flow.stepStatus; } } @@ -166,7 +154,7 @@ export const useSessionStore = defineStore('conversation', () => { flowStop: ( conversationItem: RobotConversationItem, message: Record, - isFlowDebug: boolean + isFlowDebug: boolean, ) => { const content = (message.content || {}) as Record; const contentFlow = (content.flow || {}) as Record; @@ -204,7 +192,7 @@ export const useSessionStore = defineStore('conversation', () => { }, dataDone: ( conversationItem: RobotConversationItem, - isFlowDebug: boolean + isFlowDebug: boolean, ) => { if (excelPath.value.length > 0) { conversationItem.message[conversationItem.currentInd] += @@ -216,14 +204,14 @@ export const useSessionStore = defineStore('conversation', () => { if (isFlowDebug) { $bus.emit('debugChatEnd'); } - } - } + }, + }; // chat message回调 const handleMsgDataShow = ( params: Record, msgData: Record, - conversationItem: RobotConversationItem + conversationItem: RobotConversationItem, ) => { if (isPaused.value) { // 手动暂停输出 @@ -296,108 +284,96 @@ export const useSessionStore = defineStore('conversation', () => { url: string, params: Record, innerParams: Record, - fetchParams: Record + fetchParams: Record, ) => { if (!params.type) { - await fetchEventSource( - url, - { - ...fetchParams, - body: JSON.stringify({ - app: { - appId: params.user_selected_app, - auth: {}, - flowId: params.user_selected_flow, - params: innerParams || {}, - }, - conversationId: params.conversationId, - features: features, - groupId: params.groupId, - language, - question: params.question, - // record_id: params.qaRecordId, - }), - openWhenHidden: true, - }, - ); - return; - } - // 新的工作流调试记录 - await fetchEventSource( - url, - { + await fetchEventSource(url, { ...fetchParams, body: JSON.stringify({ app: { appId: params.user_selected_app, + auth: {}, flowId: params.user_selected_flow, - params: {}, + params: innerParams || {}, }, conversationId: params.conversationId, - debug: true, + features: features, + groupId: params.groupId, + language, question: params.question, + // record_id: params.qaRecordId, }), openWhenHidden: true, - } - ); + }); + return; + } + // 新的工作流调试记录 + await fetchEventSource(url, { + ...fetchParams, + body: JSON.stringify({ + app: { + appId: params.user_selected_app, + flowId: params.user_selected_flow, + params: {}, + }, + conversationId: params.conversationId, + debug: true, + question: params.question, + }), + openWhenHidden: true, + }); }, fetchAppNew: async ( url: string, params: Record, innerParams: Record, - fetchParams: Record + fetchParams: Record, ) => { - await fetchEventSource( - url, - { - ...fetchParams, - body: JSON.stringify({ - app: { - appId: params.user_selected_app, - auth: {}, - flowId: '', - params: innerParams || {}, - }, - conversationId: params.conversationId, - features: features, - language, - groupId: params.groupId, - question: params.question, - record_id: params.qaRecordId, - }), - openWhenHidden: true, - } - ); + await fetchEventSource(url, { + ...fetchParams, + body: JSON.stringify({ + app: { + appId: params.user_selected_app, + auth: {}, + flowId: '', + params: innerParams || {}, + }, + conversationId: params.conversationId, + features: features, + language, + groupId: params.groupId, + question: params.question, + record_id: params.qaRecordId, + }), + openWhenHidden: true, + }); }, fetchDefault: async ( url: string, params: Record, innerParams: Record, - fetchParams: Record + fetchParams: Record, ) => { - await fetchEventSource( - url, - { - ...fetchParams, - body: JSON.stringify({ - app: { - appId: '', - flowId: '', - params: {}, - auth: {}, - }, - conversationId: params.conversationId, - features: features, - groupId: params.groupId, - language, - question: params.question, - record_id: params.qaRecordId, - }), - openWhenHidden: true, - } - ); - } - } + await fetchEventSource(url, { + ...fetchParams, + body: JSON.stringify({ + app: { + appId: '', + flowId: '', + params: {}, + auth: {}, + }, + conversationId: params.conversationId, + features: features, + groupId: params.groupId, + language, + question: params.question, + record_id: params.qaRecordId, + }), + openWhenHidden: true, + }); + }, + }; const judgeResp = async (resp) => { const isServiceOk = await handleServiceStatus(resp.status); @@ -411,7 +387,7 @@ export const useSessionStore = defineStore('conversation', () => { throw new Error(`HTTP error, body not exits`); } return true; - } + }; /** * 请求流式数据 @@ -429,13 +405,13 @@ export const useSessionStore = defineStore('conversation', () => { }, ind?: number, ): Promise => { - const { currentSelectedSession } = useHistorySessionStore(); params.conversationId = currentSelectedSession; // 当前问答在整个问答记录中的索引 openEuler有什么ai特性 const answerIndex = ind ?? conversationList.value.length - 1; - const conversationItem = - conversationList.value[answerIndex] as RobotConversationItem; + const conversationItem = conversationList.value[ + answerIndex + ] as RobotConversationItem; controller = new AbortController(); try { @@ -463,7 +439,7 @@ export const useSessionStore = defineStore('conversation', () => { 'Content-Type': 'application/json; charset=UTF-8', 'X-CSRF-Token': getCookie('_csrf_tk') || '', // 从 localStorage 获取 ECSESSION 并设置 Authorization - ...(localEc ? {'Authorization': `Bearer ${localEc}`} : {}) + ...(localEc ? { Authorization: `Bearer ${localEc}` } : {}), }, body: {}, onopen: async (response) => { @@ -471,8 +447,8 @@ export const useSessionStore = defineStore('conversation', () => { }, onmessage: async (ev) => { handleMsgDataShow(params, ev, conversationItem); - } - } + }, + }; if (params.user_selected_flow) { // 之前的对话历史记录 @@ -490,13 +466,17 @@ export const useSessionStore = defineStore('conversation', () => { } catch (err: any) { isPaused.value = true; isAnswerGenerating.value = false; - const targetItem = conversationList.value[answerIndex] as RobotConversationItem; + const targetItem = conversationList.value[ + answerIndex + ] as RobotConversationItem; targetItem.isFinish = true; if (err.name === 'AbortError') { successMsg(i18n.global.t('feedback.stopSuccessful')); // targetItem.isFinish = true; } else { - targetItem.message[targetItem.currentInd] += i18n.global.t('feedback.systemBusy'); + targetItem.message[targetItem.currentInd] += i18n.global.t( + 'feedback.systemBusy', + ); } } }; @@ -548,7 +528,9 @@ export const useSessionStore = defineStore('conversation', () => { }); } if (regenerateInd) { - const targetItem = conversationList.value[regenerateInd] as RobotConversationItem; + const targetItem = conversationList.value[ + regenerateInd + ] as RobotConversationItem; // 重新生成,指定某个回答,修改默认索引 targetItem.message.push(''); //123 // 重新生成,指定某个回答,修改默认索引 @@ -590,7 +572,7 @@ export const useSessionStore = defineStore('conversation', () => { let getStreamParams: Parameters[0] = { question, qaRecordId, - groupId + groupId, }; if (user_selected_flow && user_selected_app) { getStreamParams = { @@ -598,19 +580,16 @@ export const useSessionStore = defineStore('conversation', () => { user_selected_app: user_selected_app, user_selected_flow, params: params || undefined, - type: type - } + type: type, + }; } else if (user_selected_app?.length) { getStreamParams = { ...getStreamParams, user_selected_app: user_selected_app, params: params || undefined, - } + }; } - await getStream( - getStreamParams, - regenerateInd ?? undefined, - ); + await getStream(getStreamParams, regenerateInd ?? undefined); }; /** @@ -623,7 +602,9 @@ export const useSessionStore = defineStore('conversation', () => { } isPaused.value = true; - const targetItem = conversationList.value[answerIdx] as RobotConversationItem; + const targetItem = conversationList.value[ + answerIdx + ] as RobotConversationItem; targetItem.message[0] += '暂停生成'; targetItem.isFinish = true; cancel(); @@ -644,7 +625,9 @@ export const useSessionStore = defineStore('conversation', () => { const answerInd = conversationList.value.findIndex( (val) => val.cid === cid, ); - const answerItem = conversationList.value[answerInd] as RobotConversationItem; + const answerItem = conversationList.value[ + answerInd + ] as RobotConversationItem; const question = ( conversationList.value[answerInd - 1] as UserConversationItem ).message; @@ -705,7 +688,7 @@ export const useSessionStore = defineStore('conversation', () => { conversationList.value = []; const cList = conversationList.value as RobotConversationItem[]; res.result.records.forEach((record) => { - const targetRecord = cList.find(i => i.groupId === record.groupId); + const targetRecord = cList.find((i) => i.groupId === record.groupId); if (targetRecord) { // 这里用groupId找到的targetRecord中的message必为array(为string的情况不存在groupId) targetRecord.message.push(record.content.answer); @@ -716,7 +699,7 @@ export const useSessionStore = defineStore('conversation', () => { record.comment, ); if (targetRecord.currentInd !== undefined) { - targetRecord.currentInd ++; + targetRecord.currentInd++; } return; } @@ -747,7 +730,9 @@ export const useSessionStore = defineStore('conversation', () => { conversationId: record.conversationId, groupId: record.groupId, metadata: record.metadata, - flowdata: record?.flow ? (generateFlowData(record.flow) as FlowType) : undefined, + flowdata: record?.flow + ? (generateFlowData(record.flow) as FlowType) + : undefined, }, ); scrollToBottom(); @@ -786,8 +771,8 @@ export const useSessionStore = defineStore('conversation', () => { isPaused.value = true; ( conversationList.value[ - conversationList.value.length - 1 - ] as RobotConversationItem + conversationList.value.length - 1 + ] as RobotConversationItem ).isFinish = true; cancel(); const resp = await api.stopGeneration(); @@ -814,6 +799,6 @@ export const useSessionStore = defineStore('conversation', () => { nextPage, reGenerateAnswer, getConversation, - cancel + cancel, }; }); diff --git a/src/store/historySession.ts b/src/store/historySession.ts index 4538cc9..7db254a 100644 --- a/src/store/historySession.ts +++ b/src/store/historySession.ts @@ -24,11 +24,11 @@ export interface HistorySessionItem { appId: string; debug: boolean; kbList: string[]; - llm:{ + llm: { icon: string; modelName: string; llmId: string; - } + }; } export const useHistorySessionStore = defineStore( @@ -96,7 +96,7 @@ export const useHistorySessionStore = defineStore( historySession.value.forEach((item) => { if (item.conversationId === currentSelectedSession.value) { selectLLM.value = item.llm; - if(item.appId){ + if (item.appId) { app.value.appId = item.appId; } } @@ -135,7 +135,7 @@ export const useHistorySessionStore = defineStore( * @returns */ const getHistorySession = async (): Promise => { - const conversationId = localStorage.getItem("conversationId"); + const conversationId = localStorage.getItem('conversationId'); const [err, res] = await api.getSessionRecord(); const { conversationList } = storeToRefs(useSessionStore()); if (!err && res) { @@ -147,7 +147,8 @@ export const useHistorySessionStore = defineStore( title: item.title, docCount: item.docCount || 0, llm: item.llm || {}, - })).filter((item) => item.conversationId !== conversationId); + })) + .filter((item) => item.conversationId !== conversationId); if (res.result.conversations.length === 0) { await generateSession(); return; diff --git a/src/views/chat/Sender.vue b/src/views/chat/Sender.vue index fc54c09..2735e43 100644 --- a/src/views/chat/Sender.vue +++ b/src/views/chat/Sender.vue @@ -32,7 +32,7 @@ function onSendClick() {