From 13673d798b6bf9cda5f4949fd76867b7488b76df Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Thu, 3 Jul 2025 19:06:55 +0800 Subject: [PATCH] support self-check --- .../auto-detector/diagram-item-record.vue | 50 +++++-- .../main-panel/tool/auto-detector/diagram.ts | 34 ++++- .../main-panel/tool/auto-detector/diagram.vue | 130 ++++++++++++++---- .../main-panel/tool/auto-detector/index.vue | 67 +++++---- .../src/components/main-panel/tool/tools.ts | 6 + 5 files changed, 211 insertions(+), 76 deletions(-) diff --git a/renderer/src/components/main-panel/tool/auto-detector/diagram-item-record.vue b/renderer/src/components/main-panel/tool/auto-detector/diagram-item-record.vue index 6f2b50e..5b860d9 100644 --- a/renderer/src/components/main-panel/tool/auto-detector/diagram-item-record.vue +++ b/renderer/src/components/main-panel/tool/auto-detector/diagram-item-record.vue @@ -5,21 +5,36 @@ {{ props.dataView.status }}
{{ props.dataView.tool.description }}
-
- Input Schema: -
{{ formatJson(props.dataView.tool.inputSchema) }}
-
-
- Result: -
{{ formatJson(props.dataView.result) }}
+ +
+ Function +
{{ props.dataView.function.name }}
+ Arguments +
{{ formatJson(props.dataView.function.arguments) }}
+ +
+ Result + +
{{ props.dataView.result }}
+
{{ formatJson(props.dataView.result) }}
+
+
+
+
+ No Tool Selected +
+
Please select a tool to view its details.
-
-
- No Tool Selected -
-
Please select a tool to view its details.
-
@@ -556,7 +633,6 @@ function getNodePopupStyle(node: any): any { position: absolute; background: var(--background); border: 1px solid var(--main-color); - width: 240px; border-radius: 8px; padding: 8px 12px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); diff --git a/renderer/src/components/main-panel/tool/auto-detector/index.vue b/renderer/src/components/main-panel/tool/auto-detector/index.vue index 5414f4c..1578360 100644 --- a/renderer/src/components/main-panel/tool/auto-detector/index.vue +++ b/renderer/src/components/main-panel/tool/auto-detector/index.vue @@ -17,12 +17,10 @@ placeholder="请输入 prompt" />
- XML + XML
{{ t("cancel") }} @@ -34,7 +32,7 @@
- +
@@ -49,10 +47,10 @@ import { nextTick, provide, ref } from 'vue'; import Diagram from './diagram.vue'; import { makeNodeTest, topoSortParallel, type DiagramContext, type DiagramState } from './diagram'; import { ElMessage } from 'element-plus'; -import { tabs } from '../../panel'; -import type { ToolStorage } from '../tools'; import { useI18n } from 'vue-i18n'; +import type { ToolStorage } from '../tools'; +import { tabs } from '../../panel'; const showDiagram = ref(true); const { t } = useI18n(); @@ -67,14 +65,6 @@ const props = defineProps({ } }); - -const tab = tabs.content[props.tabId]; -const tabStorage = tab.storage as ToolStorage; - -if (!tabStorage.formData) { - tabStorage.formData = {}; -} - function setCaption(text: string) { caption.value = text; if (caption.value) { @@ -89,14 +79,27 @@ function setCaption(text: string) { } const context: DiagramContext = { - reset: () => {}, - render: () => {}, + reset: () => { }, + render: () => { }, state: undefined, setCaption }; provide('context', context); +const tab = tabs.content[props.tabId]; +const tabStorage = tab.storage as ToolStorage; +const autoDetectDiagram = tabStorage.autoDetectDiagram; + +if (autoDetectDiagram) { + // ... +} else { + tabStorage.autoDetectDiagram = { + edges: [], + views: [] + }; +} + // 新增:自检参数表单相关 const testFormVisible = ref(false); const enableXmlWrapper = ref(false); @@ -106,21 +109,31 @@ async function onTestConfirm() { testFormVisible.value = false; // 这里可以将 enableXmlWrapper.value 和 testPrompt.value 传递给自检逻辑 const state = context.state; + + + tabStorage.autoDetectDiagram!.views = []; + if (state) { const dispatches = topoSortParallel(state); for (const nodeIds of dispatches) { - await Promise.all( - nodeIds.map(id => { - const node = state.dataView.get(id); - if (node) { - return makeNodeTest(node, enableXmlWrapper.value, testPrompt.value, context) - } - }) - ) + for (const id of nodeIds) { + const view = state.dataView.get(id); + if (view) { + await makeNodeTest(view, enableXmlWrapper.value, testPrompt.value, context) + tabStorage.autoDetectDiagram!.views!.push({ + tool: view.tool, + status: view.status, + function: view.function, + result: view.result + }); + } + } } } else { ElMessage.error('error'); } + + } diff --git a/renderer/src/components/main-panel/tool/tools.ts b/renderer/src/components/main-panel/tool/tools.ts index 030200b..53106f9 100644 --- a/renderer/src/components/main-panel/tool/tools.ts +++ b/renderer/src/components/main-panel/tool/tools.ts @@ -1,8 +1,14 @@ import type { ToolCallResponse } from '@/hook/type'; +import type { Edge, Node, NodeDataView } from './auto-detector/diagram'; export interface ToolStorage { activeNames: any[]; currentToolName: string; lastToolCallResponse?: ToolCallResponse | string; formData: Record; + autoDetectDiagram?: { + edges?: Edge[]; + views?: NodeDataView[]; + [key: string]: any; + } }