From a2a8c3914578ac2ef849d4a67e69a117d22e5261 Mon Sep 17 00:00:00 2001 From: v-zhangjc9 Date: Mon, 21 Jul 2025 18:33:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(ai-web):=20=E8=BE=93=E5=87=BA=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=94=B9=E4=B8=BA=E5=A4=9A=E5=8F=98=E9=87=8F=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/web/engine/node/OutputNode.java | 7 ++++--- .../src/components/flow/node/OutputNode.tsx | 19 ++----------------- service-web/client/src/pages/Test.tsx | 3 +-- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/engine/node/OutputNode.java b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/engine/node/OutputNode.java index eee76f5..91afb98 100644 --- a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/engine/node/OutputNode.java +++ b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/engine/node/OutputNode.java @@ -10,10 +10,11 @@ import lombok.extern.slf4j.Slf4j; */ @Slf4j public class OutputNode extends FlowNodeRunner { + private static final String KEY = "flow_outputs"; + @Override public void run() { - String expression = getData("output"); - var targetVariable = FlowHelper.generateVariable(expression, getContext()); - log.info("Target: {}", targetVariable); + var variableMap = FlowHelper.generateInputVariablesMap(getNodeId(), getContext()); + getContext().getData().put(KEY, variableMap.toMap()); } } diff --git a/service-web/client/src/components/flow/node/OutputNode.tsx b/service-web/client/src/components/flow/node/OutputNode.tsx index c1c1965..d935a72 100644 --- a/service-web/client/src/components/flow/node/OutputNode.tsx +++ b/service-web/client/src/components/flow/node/OutputNode.tsx @@ -1,31 +1,16 @@ import type {NodeProps} from '@xyflow/react' import React, {useCallback} from 'react' -import {generateAllIncomerOutputVariablesFormOptions} from '../Helper.tsx' import {useDataStore} from '../store/DataStore.ts' import {useFlowStore} from '../store/FlowStore.ts' -import AmisNode, {EndNodeHandler, nodeClassName} from './AmisNode.tsx' import type {FormSchema} from '../types.ts' +import AmisNode, {EndNodeHandler, inputsFormColumns, nodeClassName} from './AmisNode.tsx' const OutputNode = (props: NodeProps) => { const {getNodes, getEdges} = useFlowStore() const {getData} = useDataStore() const formSchema: () => FormSchema = useCallback(() => ({ - columns: [ - { - type: 'select', - name: 'output', - label: '输出变量', - required: true, - selectMode: 'group', - options: generateAllIncomerOutputVariablesFormOptions( - props.id, - getNodes(), - getEdges(), - getData(), - ), - }, - ] + columns: inputsFormColumns(props.id, getNodes(), getEdges(), getData()), }), [props.id]) return ( diff --git a/service-web/client/src/pages/Test.tsx b/service-web/client/src/pages/Test.tsx index 81a2b52..42f7447 100644 --- a/service-web/client/src/pages/Test.tsx +++ b/service-web/client/src/pages/Test.tsx @@ -4,12 +4,11 @@ import type {GraphData} from '../components/flow/types.ts' function Test() { // language=JSON - const [graphData] = useState(JSON.parse('{"nodes":[{"id":"QxNrkChBWQ","type":"loop-node","position":{"x":890,"y":119},"data":{},"measured":{"width":1049,"height":382},"selected":false,"dragging":false,"width":1049,"height":382,"resizing":false},{"id":"MzEitlOusl","type":"llm-node","position":{"x":52.27803164309171,"y":130},"data":{},"measured":{"width":256,"height":108},"selected":false,"dragging":false,"extent":"parent","parentId":"QxNrkChBWQ"},{"id":"bivXSpiLaI","type":"code-node","position":{"x":100,"y":188},"data":{},"measured":{"width":256,"height":108},"selected":false,"dragging":false},{"id":"JsUwvjkJCW","type":"switch-node","position":{"x":495,"y":219},"data":{},"measured":{"width":256,"height":134},"selected":true,"dragging":false},{"id":"sRWQqqshAE","type":"llm-node","position":{"x":938,"y":551},"data":{},"measured":{"width":256,"height":108},"selected":false,"dragging":false},{"id":"bDgwRcxgHo","type":"code-node","position":{"x":397.0305805332712,"y":169.58523732318685},"data":{},"parentId":"QxNrkChBWQ","extent":"parent","measured":{"width":256,"height":108},"selected":false,"dragging":false},{"id":"fzmjIpcUsy","type":"output-node","position":{"x":721.6295265834033,"y":238.19964868337735},"data":{},"parentId":"QxNrkChBWQ","extent":"parent","measured":{"width":256,"height":79},"selected":false,"dragging":false},{"id":"nutuhaTLel","type":"llm-node","position":{"x":2075.444643036393,"y":334.5237261697987},"data":{},"measured":{"width":256,"height":108},"selected":false,"dragging":false}],"edges":[{"source":"bivXSpiLaI","sourceHandle":"source","target":"JsUwvjkJCW","id":"xy-edge__bivXSpiLaIsource-JsUwvjkJCW"},{"source":"JsUwvjkJCW","sourceHandle":"736a724a5de4","target":"QxNrkChBWQ","targetHandle":"target","id":"xy-edge__JsUwvjkJCW736a724a5de4-QxNrkChBWQtarget"},{"source":"JsUwvjkJCW","sourceHandle":"406bf6637c64","target":"sRWQqqshAE","targetHandle":"target","id":"xy-edge__JsUwvjkJCW406bf6637c64-sRWQqqshAEtarget"},{"source":"MzEitlOusl","sourceHandle":"source","target":"bDgwRcxgHo","targetHandle":"target","id":"xy-edge__MzEitlOuslsource-bDgwRcxgHotarget"},{"source":"bDgwRcxgHo","sourceHandle":"source","target":"fzmjIpcUsy","targetHandle":"target","id":"xy-edge__bDgwRcxgHosource-fzmjIpcUsytarget"},{"source":"QxNrkChBWQ","sourceHandle":"source","target":"nutuhaTLel","targetHandle":"target","id":"xy-edge__QxNrkChBWQsource-nutuhaTLeltarget"}],"data":{"MzEitlOusl":{"node":{"name":"大模型","description":"使用大模型对话"},"outputs":{"text":{"type":"text"}},"model":"qwen3","systemPrompt":"你是个好人","finished":true},"bivXSpiLaI":{"node":{"name":"代码执行","description":"执行自定义的处理代码"},"outputs":{"text":{"type":"text"},"condition":{"type":"boolean"},"count":{"type":"number"},"person":{"type":"object"},"words":{"type":"array-text"},"people":{"type":"array-object"}},"type":"javascript","content":"console.log(\'hello\')","inputs":{},"finished":true},"QxNrkChBWQ":{"node":{"name":"循环","description":"实现循环执行流程"},"finished":true,"outputs":{"output":{"type":"array-object"}}},"JsUwvjkJCW":{"node":{"name":"分支","description":"根据不同的情况前往不同的分支"},"conditions":[{"condition":{"id":"736a724a5de4","conjunction":"and","children":[{"id":"1cbccc438a64","left":{"type":"field","field":"bivXSpiLaI.text"},"op":"equal","right":"2"},{"id":"7bf51315dd05","left":{"type":"field","field":"bivXSpiLaI.condition"},"op":"not_equal","right":true}]}},{"condition":{"id":"406bf6637c64","conjunction":"and","children":[{"id":"ea37e95e6d1b","left":{"type":"field","field":"bivXSpiLaI.text"},"op":"equal","right":"3"}]}}],"finished":true},"sRWQqqshAE":{"node":{"name":"大模型","description":"使用大模型对话"},"outputs":{"text":{"type":"text"}},"model":"deepseek","systemPrompt":"Hello","finished":true},"bDgwRcxgHo":{"node":{"name":"代码执行","description":"执行自定义的处理代码"},"type":"javascript","content":"console.log(\'hello\')","outputs":{"ok":{"type":"boolean"}},"finished":true},"fzmjIpcUsy":{"node":{"name":"输出","description":"定义输出变量"},"output":"loopItem","finished":true},"nutuhaTLel":{"node":{"name":"大模型","description":"使用大模型对话"},"outputs":{"text":{"type":"text"}},"model":"qwen3","systemPrompt":"你是个好人","finished":true}}}')) + const [graphData] = useState(JSON.parse('{"nodes":[{"id":"QxNrkChBWQ","type":"loop-node","position":{"x":890,"y":119},"data":{},"measured":{"width":1049,"height":382},"selected":false,"dragging":false,"width":1049,"height":382,"resizing":false},{"id":"MzEitlOusl","type":"llm-node","position":{"x":52.27803164309171,"y":130},"data":{},"measured":{"width":256,"height":110},"selected":false,"dragging":false,"extent":"parent","parentId":"QxNrkChBWQ"},{"id":"bivXSpiLaI","type":"code-node","position":{"x":100,"y":188},"data":{},"measured":{"width":256,"height":110},"selected":false,"dragging":false},{"id":"JsUwvjkJCW","type":"switch-node","position":{"x":495,"y":219},"data":{},"measured":{"width":256,"height":136},"selected":false,"dragging":false},{"id":"sRWQqqshAE","type":"llm-node","position":{"x":938,"y":551},"data":{},"measured":{"width":256,"height":110},"selected":false,"dragging":false},{"id":"bDgwRcxgHo","type":"code-node","position":{"x":397.0305805332712,"y":169.58523732318685},"data":{},"parentId":"QxNrkChBWQ","extent":"parent","measured":{"width":256,"height":110},"selected":false,"dragging":false},{"id":"nutuhaTLel","type":"llm-node","position":{"x":2075.444643036393,"y":334.5237261697987},"data":{},"measured":{"width":256,"height":110},"selected":false,"dragging":false},{"id":"aYShKQcGfh","type":"output-node","position":{"x":1358.9776572890726,"y":600.0027945802063},"data":{},"measured":{"width":256,"height":80},"selected":false,"dragging":false},{"id":"DpQUEMLvWW","type":"output-node","position":{"x":765,"y":233.5125686455669},"data":{},"parentId":"QxNrkChBWQ","extent":"parent","measured":{"width":256,"height":80},"selected":true,"dragging":false}],"edges":[{"source":"bivXSpiLaI","sourceHandle":"source","target":"JsUwvjkJCW","id":"xy-edge__bivXSpiLaIsource-JsUwvjkJCW"},{"source":"JsUwvjkJCW","sourceHandle":"736a724a5de4","target":"QxNrkChBWQ","targetHandle":"target","id":"xy-edge__JsUwvjkJCW736a724a5de4-QxNrkChBWQtarget"},{"source":"JsUwvjkJCW","sourceHandle":"406bf6637c64","target":"sRWQqqshAE","targetHandle":"target","id":"xy-edge__JsUwvjkJCW406bf6637c64-sRWQqqshAEtarget"},{"source":"MzEitlOusl","sourceHandle":"source","target":"bDgwRcxgHo","targetHandle":"target","id":"xy-edge__MzEitlOuslsource-bDgwRcxgHotarget"},{"source":"bDgwRcxgHo","sourceHandle":"source","target":"fzmjIpcUsy","targetHandle":"target","id":"xy-edge__bDgwRcxgHosource-fzmjIpcUsytarget"},{"source":"QxNrkChBWQ","sourceHandle":"source","target":"nutuhaTLel","targetHandle":"target","id":"xy-edge__QxNrkChBWQsource-nutuhaTLeltarget"},{"source":"sRWQqqshAE","sourceHandle":"source","target":"aYShKQcGfh","targetHandle":"target","id":"xy-edge__sRWQqqshAEsource-aYShKQcGfhtarget"},{"source":"bDgwRcxgHo","sourceHandle":"source","target":"DpQUEMLvWW","targetHandle":"target","id":"xy-edge__bDgwRcxgHosource-DpQUEMLvWWtarget"}],"data":{"MzEitlOusl":{"node":{"name":"大模型","description":"使用大模型对话"},"outputs":{"text":{"type":"text"}},"model":"qwen3","systemPrompt":"你是个好人","finished":true},"bivXSpiLaI":{"node":{"name":"代码执行","description":"执行自定义的处理代码"},"outputs":{"text":{"type":"text"},"condition":{"type":"boolean"},"count":{"type":"number"},"person":{"type":"object"},"words":{"type":"array-text"},"people":{"type":"array-object"}},"type":"javascript","content":"console.log(\'hello\')","inputs":{},"finished":true},"QxNrkChBWQ":{"node":{"name":"循环","description":"实现循环执行流程"},"finished":true,"outputs":{"output":{"type":"array-object"}},"failFast":true,"parallel":false,"type":"for","count":1},"JsUwvjkJCW":{"node":{"name":"分支","description":"根据不同的情况前往不同的分支"},"conditions":[{"condition":{"id":"736a724a5de4","conjunction":"and","children":[{"id":"1cbccc438a64","left":{"type":"field","field":"bivXSpiLaI.text"},"op":"equal","right":"2"},{"id":"7bf51315dd05","left":{"type":"field","field":"bivXSpiLaI.condition"},"op":"not_equal","right":true}]}},{"condition":{"id":"406bf6637c64","conjunction":"and","children":[{"id":"ea37e95e6d1b","left":{"type":"field","field":"bivXSpiLaI.text"},"op":"equal","right":"3"}]}}],"finished":true},"sRWQqqshAE":{"node":{"name":"大模型","description":"使用大模型对话"},"outputs":{"text":{"type":"text"}},"model":"deepseek","systemPrompt":"Hello","finished":true},"bDgwRcxgHo":{"node":{"name":"代码执行","description":"执行自定义的处理代码"},"type":"javascript","content":"console.log(\'hello\')","outputs":{"ok":{"type":"boolean"}},"finished":true},"nutuhaTLel":{"node":{"name":"大模型","description":"使用大模型对话"},"outputs":{"text":{"type":"text"}},"model":"qwen3","systemPrompt":"你是个好人","finished":true},"aYShKQcGfh":{"node":{"name":"输出","description":"定义流程输出变量"},"inputs":{"result":{"variable":"sRWQqqshAE.text"}},"finished":true},"DpQUEMLvWW":{"node":{"name":"输出","description":"定义流程输出变量"},"inputs":{"index":{"variable":"loopIndex"}},"finished":true}}}')) return (
console.log(data)} />