diff --git a/service-web/client/src/components/flow/FlowEditor.tsx b/service-web/client/src/components/flow/FlowEditor.tsx index 27a1b9c..ded628a 100644 --- a/service-web/client/src/components/flow/FlowEditor.tsx +++ b/service-web/client/src/components/flow/FlowEditor.tsx @@ -109,6 +109,7 @@ function FlowEditor(props: FlowEditorProps) { onNodeDrag={onNodeDrag} onNodeDragStop={onNodeDragEnd} onEdgesDelete={() => console.info('delete')} + fitView > diff --git a/service-web/client/src/components/flow/Helper.tsx b/service-web/client/src/components/flow/Helper.tsx index a28da32..597a4ce 100644 --- a/service-web/client/src/components/flow/Helper.tsx +++ b/service-web/client/src/components/flow/Helper.tsx @@ -103,11 +103,8 @@ export const generateAllIncomerOutputVariablesFormOptions: (id: string, inputSch type ConditionOperator = string | { label: string, value: string } const textOperators: ConditionOperator[] = ['equal', 'not_equal', 'is_empty', 'is_not_empty', 'like', 'not_like', 'starts_with', 'ends_with'] const textDefaultOperator: string = 'equal' -const booleanOperators: ConditionOperator[] = [ - {label: '为真', value: 'is_true'}, - {label: '为假', value: 'is_false'}, -] -const booleanDefaultOperator: string = 'is_true' +const booleanOperators: ConditionOperator[] = ['equal', 'not_equal'] +const booleanDefaultOperator: string = 'equal' const numberOperators: ConditionOperator[] = [ 'equal', 'not_equal', @@ -139,8 +136,13 @@ export const generateAllIncomerOutputVariablesConditions: (id: string, inputSche } : {}), ...(item.type === 'boolean' ? { value: { - type: 'wrapper', - size: 'none', + type: 'select', + required: true, + selectFirst: true, + options: [ + {label: '真', value: true}, + {label: '假', value: false}, + ] }, defaultOp: booleanDefaultOperator, operators: booleanOperators, diff --git a/service-web/client/src/components/flow/node/SwitchNode.tsx b/service-web/client/src/components/flow/node/SwitchNode.tsx index 610380f..f0d1b61 100644 --- a/service-web/client/src/components/flow/node/SwitchNode.tsx +++ b/service-web/client/src/components/flow/node/SwitchNode.tsx @@ -31,6 +31,8 @@ const SwitchNode = (props: NodeProps) => { name: 'condition', label: '条件', required: true, + builderMode: 'simple', + showANDOR: true, fields: generateAllIncomerOutputVariablesConditions( props.id, getInputSchema(), diff --git a/service-web/client/src/pages/Test.tsx b/service-web/client/src/pages/Test.tsx index e7bd8f3..81a2b52 100644 --- a/service-web/client/src/pages/Test.tsx +++ b/service-web/client/src/pages/Test.tsx @@ -4,7 +4,7 @@ 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":false,"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":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"}],"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":"1db9e7a90aae","left":{"type":"field","field":"bivXSpiLaI.text"},"op":"equal","right":"1"},{"id":"98cc5c39eed4","left":{"type":"field","field":"bivXSpiLaI.condition"},"op":"is_true"},{"id":"1cbccc438a64","left":{"type":"field","field":"bivXSpiLaI.text"},"op":"equal","right":"2"}]}},{"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":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}}}')) return (
diff --git a/service-web/client/src/pages/ai/Conversation.tsx b/service-web/client/src/pages/ai/Conversation.tsx index 7c10409..b0186f6 100644 --- a/service-web/client/src/pages/ai/Conversation.tsx +++ b/service-web/client/src/pages/ai/Conversation.tsx @@ -42,7 +42,6 @@ function Conversation() { const [input, setInput] = useState('') useUnmount(() => { - console.log('Page Unmount') abortController.current?.abort() }) diff --git a/service-web/client/src/pages/ai/task/FlowTaskAdd.tsx b/service-web/client/src/pages/ai/task/FlowTaskAdd.tsx index d4b6cd7..e73729b 100644 --- a/service-web/client/src/pages/ai/task/FlowTaskAdd.tsx +++ b/service-web/client/src/pages/ai/task/FlowTaskAdd.tsx @@ -49,7 +49,6 @@ const FlowTaskAdd: React.FC = () => { actionType: 'custom', // @ts-ignore script: (context, doAction, event) => { - console.log(event) let selectedIds = (event?.data?.selectedItems ?? []).map((item: any) => item.id) if (!isEmpty(selectedIds)) { doAction({