From 6a5241422cc24911ae94c82f138e385e26b4bc81 Mon Sep 17 00:00:00 2001 From: li-shengren-123456 Date: Fri, 21 Feb 2025 18:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AF=B9=E8=AF=9D=E6=8E=A5=E5=8F=A3=E5=92=8C?= =?UTF-8?q?=E8=80=97=E6=97=B6=E5=B1=95=E7=A4=BA=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=A4=8D=E5=88=B6=E7=AD=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dialoguePanel/DialogueFlow.vue | 260 +++++++++++------- .../dialoguePanel/DialoguePanel.vue | 72 ++++- src/store/conversation.ts | 14 +- src/views/app/index.vue | 2 +- .../components/codeMirror/nodeMirrorText.vue | 20 +- src/views/createapp/components/types.ts | 8 + src/views/createapp/components/workFlow.vue | 45 +-- .../components/workFlowConfig/BranchNode.vue | 2 +- .../workFlowConfig/CustomSaENode.vue | 2 +- .../createapp/components/workFlowDebug.vue | 34 ++- src/views/createapp/index.vue | 2 +- .../dialogue/components/DialogueSession.vue | 1 + src/views/styles/createApp.scss | 9 + 13 files changed, 328 insertions(+), 143 deletions(-) diff --git a/src/components/dialoguePanel/DialogueFlow.vue b/src/components/dialoguePanel/DialogueFlow.vue index 8ad097e..0aec7d1 100644 --- a/src/components/dialoguePanel/DialogueFlow.vue +++ b/src/components/dialoguePanel/DialogueFlow.vue @@ -1,19 +1,25 @@ diff --git a/src/components/dialoguePanel/DialoguePanel.vue b/src/components/dialoguePanel/DialoguePanel.vue index 751cf80..e50b9f4 100644 --- a/src/components/dialoguePanel/DialoguePanel.vue +++ b/src/components/dialoguePanel/DialoguePanel.vue @@ -469,7 +469,7 @@ const handleSendMessage = async (question, user_selected_flow, user_selected_app
- +
补充参数 @@ -1152,6 +1152,76 @@ const handleSendMessage = async (question, user_selected_flow, user_selected_app padding-left: 64px; .dialogue-panel__robot-content { border-radius: 8px; + // 工作流调试时控制显示 + .dialogue-thought { + // ai思考无需显示 + display: none; + } + ::v-deep(.demo-collapse) { + border-radius: 4px; + .title.el-collapse-item { + .loading-text { + display: flex; + text-align: left; + align-items: center; + .textTitle { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .totalTime { + min-width: 54px; + width: fit-content; + padding: 0px 8px; + height: 16px; + line-height: 16px; + font-size: 12px; + border-radius: 4px; + } + .totalTime.errorBg { + background-color: rgba(227, 32, 32, 0.2); + } + } + } + .normal.el-collapse-item { + border-bottom: 1px dashed #dfe5ef; + .el-collapse-item__header { + background-color: var(--o-bg-color-base) !important; + color: var(--o-text-color-primary); + padding-right: 0px; + .o-collapse-icon { + width: 16px; + height: 16px; + } + .title { + flex: 1; + text-align: left; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .time { + min-width: 54px; + width: fit-content; + padding: 0px 8px; + height: 16px; + line-height: 16px; + border-radius: 4px; + font-size: 12px; + } + &::after { + background-color: transparent; + } + } + &:last-child { + border-bottom: 1px solid transparent; + } + } + .el-collapse-item__content { + margin:0px 16px; + } + } // 调试抽屉中echarts无需显示 .answer_img { display: none; diff --git a/src/store/conversation.ts b/src/store/conversation.ts index a962de8..9057a9d 100644 --- a/src/store/conversation.ts +++ b/src/store/conversation.ts @@ -314,6 +314,8 @@ export const useSessionStore = defineStore('conversation', () => { if (target) { target.data.output = message.content target.status = message.flow?.stepStatus; + // 工作流添加每阶段的时间耗时 + target['costTime'] = message.time_cost; if(message.flow.step_status === "error"){ conversationItem.flowdata.status = message.flow?.stepStatus; } @@ -322,7 +324,17 @@ export const useSessionStore = defineStore('conversation', () => { else if(message["event"] === "flow.stop") { //时间流结束 let flow = message.content.flow; - if(message.content.type !== "schema"){ + if (params.type) { + // 如果是工作流的调试功能-添加status/data + conversationItem.flowdata = { + id: flow?.stepName, + title: i18n.global.t('flow.flow_end'), + progress: flow?.stepProgress, + status: message.flow?.stepStatus, + display:true, + data:conversationItem?.flowdata?.data, + }; + }else if(message.content.type !== "schema"){ conversationItem.flowdata?.data[0].push({ id:"end", title:"end", diff --git a/src/views/app/index.vue b/src/views/app/index.vue index 5d2fece..f7d212a 100644 --- a/src/views/app/index.vue +++ b/src/views/app/index.vue @@ -136,7 +136,7 @@ const handleCreateApp = () => { }; const routerToDetail = appItem => { - if (!appItem.published && appType.value === 'createdByMe') { + if (!appItem.published) { return; } //获取appItem.id & appItem.name diff --git a/src/views/createapp/components/codeMirror/nodeMirrorText.vue b/src/views/createapp/components/codeMirror/nodeMirrorText.vue index a9a24d1..e72724d 100644 --- a/src/views/createapp/components/codeMirror/nodeMirrorText.vue +++ b/src/views/createapp/components/codeMirror/nodeMirrorText.vue @@ -36,6 +36,7 @@ import { useChangeThemeStore } from 'src/store/conversation'; import yaml from 'js-yaml'; import { writeText } from 'src/utils'; import { errorMsg, successMsg } from 'src/components/Message'; +import { StatusInfoTitle } from '../types'; const props = defineProps({ status: { default: 'default', @@ -69,19 +70,12 @@ const resultInfo = ref({ ], }); -const statusInfoTitle = ref({ - default: '', - success: '运行成功', - error: '运行失败', - running: '运行中', -}); - watch( () => props, () => { resultInfo.value.status = props.status; // 目前props.status只有success、error、running三种 - resultInfo.value.infoList[0].title = statusInfoTitle.value[props.status]; + resultInfo.value.infoList[0].title = StatusInfoTitle[props.status]; if (props?.inputAndOutput) { resultInfo.value.time = props.inputAndOutput.input_parameters.timeout ?? 0; @@ -104,7 +98,7 @@ const handleCopy = code => { errorMsg('无可复制的信息'); return; } - writeText(code); + writeText(yaml.dump(code)); successMsg('复制成功'); }; @@ -157,14 +151,6 @@ const handleCopy = code => { padding: 0px 8px; border-radius: 4px; } - .successBg { - background-color: rgba(36, 171, 54, 0.2); - color: #24ab36; - } - .errorBg { - background-color: #fbdede; - color: #e32020; - } .flexRight { margin-left: auto; margin-right: -4px; diff --git a/src/views/createapp/components/types.ts b/src/views/createapp/components/types.ts index cfa0953..3319152 100644 --- a/src/views/createapp/components/types.ts +++ b/src/views/createapp/components/types.ts @@ -17,6 +17,14 @@ export enum BranchSourceIdType { SOURCEB = "source_b", } +export const StatusInfoTitle = { + default: '', + success: '运行成功', + error: '运行失败', + running: '运行中', + pending: '运行中', +}; + export interface LinkItem { key: string; label: string; diff --git a/src/views/createapp/components/workFlow.vue b/src/views/createapp/components/workFlow.vue index 344e332..e684e12 100644 --- a/src/views/createapp/components/workFlow.vue +++ b/src/views/createapp/components/workFlow.vue @@ -18,7 +18,7 @@ import { useLayout } from './workFlowConfig/useLayout'; import { IconSearch, IconCaretRight, IconCaretDown, IconPlusCircle } from '@computing/opendesign-icons'; import EditYamlDrawer from './workFlowConfig/yamlEditDrawer.vue'; import { api } from 'src/apis'; -import { BranchSourceIdType } from './types'; +import { BranchSourceIdType, StatusInfoTitle } from './types'; import { useRoute } from 'vue-router'; import yaml from 'js-yaml'; import $bus from 'src/bus/index'; @@ -48,7 +48,9 @@ const workFlowList = ref([]); const props = defineProps(['flowList']); const flowObj = ref({}); const nodes = ref([]); -const debugResult = ref('success'); +const debugResult = ref(''); +const debugTime = ref(''); +const totalTime = ref(0); const hanleAsideVisible = () => { if (!copilotAside.value) return; if (isCopilotAsideVisible.value) { @@ -264,8 +266,10 @@ const searchApiList = () => { }); }; -const handleDebugDialogOps = visible => { +const handleDebugDialogOps = (visible) => { debugDialogVisible.value = visible; + // 调试弹窗关闭时---结果清空 + debugResult.value = ''; }; const edgesChange = edges => { @@ -329,7 +333,6 @@ const queryFlow = (deal: string) => { }); } }; - // 点击编辑工作流--查询当前工作流数据-后续添加回显 const editFlow = item => { api @@ -424,11 +427,22 @@ $bus.on('getNodesStatue', lines => { const newLines = yaml.load(item); // step.input和step.output对应的节点状态需要修改 if (newLines?.data?.event === 'step.input' || newLines?.data?.event === 'step.output') { - if (newLines?.data?.flow?.stepId) { // output-节点运行结束时,获取节点运行的耗时 - const constTime = newLines.data.event === 'step.output' ? `${newLines.data?.time_cost?.toFixed(3)}s` : ''; + let constTime = ''; + if (newLines.data.event === 'step.output') { + totalTime.value += newLines.data?.time_cost; + constTime = `${newLines.data?.time_cost?.toFixed(3)}s` + } updateNodeFunc(newLines.data.flow.stepId, newLines.data.flow?.stepStatus, constTime); - } + } else if (newLines?.data?.event === 'flow.stop') { + debugResult.value = newLines.data.flow?.stepStatus; + debugTime.value = `${totalTime.value.toFixed(3)}s` + } else if (newLines?.data?.event === 'flow.start'){ + totalTime.value = 0; + debugTime.value = ''; + debugResult.value = newLines.data.flow?.stepStatus; + } else { + // do nothing } }); } catch (error) { @@ -711,10 +725,11 @@ defineExpose({
- @@ -765,7 +780,7 @@ defineExpose({ background: url(@/assets/images/flow_fail.png) center center no-repeat; } - .runningIcon { + .runningIcon, .pendingIcon { background: url(@/assets/images/loading.png) center center no-repeat; } .time { @@ -774,14 +789,6 @@ defineExpose({ padding: 0px 8px; border-radius: 4px; } - .successBg { - background-color: rgba(36, 171, 54, 0.2); - color: #24ab36; - } - .errorBg { - background-color: #fbdede; - color: #e32020; - } .flexRight { margin-left: auto; margin-right: -4px; diff --git a/src/views/createapp/components/workFlowConfig/BranchNode.vue b/src/views/createapp/components/workFlowConfig/BranchNode.vue index 96dcb38..318542c 100644 --- a/src/views/createapp/components/workFlowConfig/BranchNode.vue +++ b/src/views/createapp/components/workFlowConfig/BranchNode.vue @@ -23,7 +23,7 @@ const props = defineProps({ }); const emits = defineEmits(['delNode', 'editYamlDrawer']); -const statusList = ref(['pending', 'success', 'error']); +const statusList = ref(['running', 'success', 'error']); const branchIdList = ref([]); diff --git a/src/views/createapp/components/workFlowConfig/CustomSaENode.vue b/src/views/createapp/components/workFlowConfig/CustomSaENode.vue index 45722b4..17902c5 100644 --- a/src/views/createapp/components/workFlowConfig/CustomSaENode.vue +++ b/src/views/createapp/components/workFlowConfig/CustomSaENode.vue @@ -24,7 +24,7 @@ const props = defineProps({ }, }); -const statusList = ref(['waiting', 'success', 'error', 'default']); +const statusList = ref(['running', 'success', 'error']); const curStatus = ref(''); diff --git a/src/views/createapp/components/workFlowDebug.vue b/src/views/createapp/components/workFlowDebug.vue index 9e94fd9..0abe336 100644 --- a/src/views/createapp/components/workFlowDebug.vue +++ b/src/views/createapp/components/workFlowDebug.vue @@ -6,7 +6,7 @@
-
+
(''); - /** * * @param item @@ -134,6 +137,31 @@ const handleKeydown = (event: KeyboardEvent) => { }; const handleCloseDebugDialog = () => { + testFlag.value = false + delChat(); props.handleDebugDialogOps(false); }; + +// 关闭或者跳转前需要将会话删除 +const delChat = async () => { + if (!currentSelectedSession.value) { + // 如果还没生成会话Id, 无需调用接口删除 + return; + } else { + // 调用接口,删除当前对话 + const res = await api.deleteSession({ conversationList: [currentSelectedSession.value] }); + if (res[1]?.result) { + // 删除成功 + conversationList.value = []; + selectedSessionIds.value = []; + currentSelectedSession.value = ''; + historySession.value = [];= + } + } +} + +onBeforeRouteLeave((to, from ,next) => { + handleCloseDebugDialog(); + next(); +}) diff --git a/src/views/createapp/index.vue b/src/views/createapp/index.vue index e21a293..7f46c0a 100644 --- a/src/views/createapp/index.vue +++ b/src/views/createapp/index.vue @@ -139,7 +139,7 @@ const handleJumperAppCenter = () => {
- 取消 + 取消 保存 预览 发布 diff --git a/src/views/dialogue/components/DialogueSession.vue b/src/views/dialogue/components/DialogueSession.vue index ee8decb..d96e759 100644 --- a/src/views/dialogue/components/DialogueSession.vue +++ b/src/views/dialogue/components/DialogueSession.vue @@ -411,6 +411,7 @@ const isAllowToSend = computed(() => { // 会话切换时 watch(currentSelectedSession, async newVal => { + if (!newVal) return; const newExistList = existUploadMap.get(newVal); const newFileView = uploadViewsMap.get(newVal); let curPolling = pollingMap.get(newVal); diff --git a/src/views/styles/createApp.scss b/src/views/styles/createApp.scss index b737cb8..c0ee53e 100644 --- a/src/views/styles/createApp.scss +++ b/src/views/styles/createApp.scss @@ -337,6 +337,15 @@ border-color: var(--o-color-primary) !important; color: var(--o-color-white) !important; } + // 成功失败样式 + .successBg { + background-color: rgba(36, 171, 54, 0.2); + color: #24ab36; + } + .errorBg { + background-color: #fbdede; + color: #e32020; + } } .w320 { -- Gitee