From 87b406130294a375e3d5042b1d3e3ddb5fd261f3 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Tue, 22 Oct 2024 14:51:15 +0800 Subject: [PATCH] System plugin adapt reference type in plugin input (#2965) * perf: plugin input support reference * perf: system plugin adapt plugin input reference --- .../src/databaseConnection/template.json | 144 +++++------------- .../src/drawing/baseChart/template.json | 91 ++++++----- .../src/duckduckgo/search/template.json | 2 +- .../src/duckduckgo/searchImg/template.json | 2 +- .../src/duckduckgo/searchNews/template.json | 2 +- .../src/duckduckgo/searchVideo/template.json | 2 +- packages/plugins/src/duckduckgo/template.json | 4 +- packages/plugins/src/google/template.json | 11 +- packages/plugins/src/wiki/template.json | 7 +- .../common/Textarea/PromptEditor/Editor.tsx | 4 +- .../Textarea/PromptEditor/index.module.scss | 19 --- .../common/Textarea/PromptEditor/index.tsx | 3 - .../nodes/NodePluginIO/InputEditModal.tsx | 51 +++---- .../nodes/NodePluginIO/InputTypeConfig.tsx | 34 ++--- .../RenderInput/templates/TextInput.tsx | 3 +- .../render/RenderInput/templates/Textarea.tsx | 1 - 16 files changed, 145 insertions(+), 235 deletions(-) diff --git a/packages/plugins/src/databaseConnection/template.json b/packages/plugins/src/databaseConnection/template.json index 30cc57c83..c4561019d 100644 --- a/packages/plugins/src/databaseConnection/template.json +++ b/packages/plugins/src/databaseConnection/template.json @@ -20,15 +20,13 @@ "flowNodeType": "pluginInput", "showStatus": false, "position": { - "x": 335.8310044079668, + "x": 334.24111198705634, "y": -260.8285440670886 }, "version": "481", "inputs": [ { - "renderTypeList": [ - "select" - ], + "renderTypeList": ["select", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -49,9 +47,7 @@ "required": true }, { - "renderTypeList": [ - "input" - ], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -68,11 +64,9 @@ ] }, { - "renderTypeList": [ - "input" - ], + "renderTypeList": ["numberInput", "reference"], "selectedTypeIndex": 0, - "valueType": "string", + "valueType": "number", "canEdit": true, "key": "port", "label": "port", @@ -87,9 +81,7 @@ ] }, { - "renderTypeList": [ - "input" - ], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -106,9 +98,7 @@ ] }, { - "renderTypeList": [ - "input" - ], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -125,9 +115,7 @@ "required": true }, { - "renderTypeList": [ - "input" - ], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -144,9 +132,7 @@ "required": true }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -181,7 +167,7 @@ }, { "id": "port", - "valueType": "string", + "valueType": "number", "key": "port", "label": "port", "type": "hidden" @@ -230,19 +216,14 @@ "version": "481", "inputs": [ { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "result", "label": "result", "isToolOutput": true, "description": "数据库连接结果", - "value": [ - "zBeXy7YZEiXe", - "httpRawResponse" - ] + "value": ["zBeXy7YZEiXe", "httpRawResponse"] } ], "outputs": [] @@ -276,9 +257,7 @@ "inputs": [ { "key": "system_addInputParam", - "renderTypeList": [ - "addInputParam" - ], + "renderTypeList": ["addInputParam"], "valueType": "dynamic", "label": "", "required": false, @@ -310,9 +289,7 @@ }, { "key": "system_httpMethod", - "renderTypeList": [ - "custom" - ], + "renderTypeList": ["custom"], "valueType": "string", "label": "", "value": "POST", @@ -324,9 +301,7 @@ }, { "key": "system_httpTimeout", - "renderTypeList": [ - "custom" - ], + "renderTypeList": ["custom"], "valueType": "number", "label": "", "value": 30, @@ -340,9 +315,7 @@ }, { "key": "system_httpReqUrl", - "renderTypeList": [ - "hidden" - ], + "renderTypeList": ["hidden"], "valueType": "string", "label": "", "description": "common:core.module.input.description.Http Request Url", @@ -355,9 +328,7 @@ }, { "key": "system_httpHeader", - "renderTypeList": [ - "custom" - ], + "renderTypeList": ["custom"], "valueType": "any", "value": [], "label": "", @@ -370,9 +341,7 @@ }, { "key": "system_httpParams", - "renderTypeList": [ - "hidden" - ], + "renderTypeList": ["hidden"], "valueType": "any", "value": [], "label": "", @@ -384,9 +353,7 @@ }, { "key": "system_httpJsonBody", - "renderTypeList": [ - "hidden" - ], + "renderTypeList": ["hidden"], "valueType": "any", "value": "{\r\n \"databaseType\":\"{{databaseType-H}}\",\r\n \"host\":\"{{host-H}}\",\r\n \"port\":\"{{port-H}}\",\r\n \"databaseName\":\"{{databaseName-H}}\",\r\n \"user\":\"{{databaseUser-H}}\",\r\n \"password\":\"{{databasePwd-H}}\",\r\n \"sql\":\"{{sql-H}}\"\r\n}", "label": "", @@ -398,9 +365,7 @@ }, { "key": "system_httpFormBody", - "renderTypeList": [ - "hidden" - ], + "renderTypeList": ["hidden"], "valueType": "any", "value": [], "label": "", @@ -412,9 +377,7 @@ }, { "key": "system_httpContentType", - "renderTypeList": [ - "hidden" - ], + "renderTypeList": ["hidden"], "valueType": "string", "value": "json", "label": "", @@ -425,9 +388,7 @@ "toolDescription": "" }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "databaseType-H", @@ -454,15 +415,10 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "databaseType" - ] + "value": ["pluginInput", "databaseType"] }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "host-H", @@ -489,16 +445,11 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "host" - ] + "value": ["pluginInput", "host"] }, { - "renderTypeList": [ - "reference" - ], - "valueType": "string", + "renderTypeList": ["reference"], + "valueType": "number", "canEdit": true, "key": "port-H", "label": "port-H", @@ -524,15 +475,10 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "port" - ] + "value": ["pluginInput", "port"] }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "databaseName-H", @@ -559,15 +505,10 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "dataBaseName" - ] + "value": ["pluginInput", "dataBaseName"] }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "databasePwd-H", @@ -594,15 +535,10 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "dataBasePwd" - ] + "value": ["pluginInput", "dataBasePwd"] }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "databaseUser-H", @@ -629,15 +565,10 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "user" - ] + "value": ["pluginInput", "user"] }, { - "renderTypeList": [ - "reference" - ], + "renderTypeList": ["reference"], "valueType": "string", "canEdit": true, "key": "sql-H", @@ -664,10 +595,7 @@ "showDefaultValue": true }, "required": true, - "value": [ - "pluginInput", - "sql" - ] + "value": ["pluginInput", "sql"] } ], "outputs": [ diff --git a/packages/plugins/src/drawing/baseChart/template.json b/packages/plugins/src/drawing/baseChart/template.json index 09b63e0a5..3f58be5c6 100644 --- a/packages/plugins/src/drawing/baseChart/template.json +++ b/packages/plugins/src/drawing/baseChart/template.json @@ -1,6 +1,6 @@ { "author": "", - "version": "486", + "version": "4812", "name": "基础图表", "avatar": "core/workflow/template/baseChart", "intro": "根据数据生成图表,可根据chartType生成柱状图,折线图,饼图", @@ -8,7 +8,7 @@ "weight": 10, "isTool": true, - "templateType": "search", + "templateType": "tools", "workflow": { "nodes": [ @@ -21,12 +21,12 @@ "showStatus": false, "position": { "x": 613.7921798611637, - "y": -124.66724109717275 + "y": -123.07734867626235 }, "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -44,13 +44,13 @@ "toolDescription": "BI图表的标题" }, { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, "key": "xAxis", "label": "xAxis", - "description": "x轴数据", + "description": "x轴数据,例如:['A', 'B', 'C']", "defaultValue": "", "required": true, "toolDescription": "x轴数据,例如:['A', 'B', 'C']", @@ -62,13 +62,13 @@ ] }, { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, "key": "yAxis", "label": "yAxis", - "description": "y轴数据", + "description": "y轴数据,例如:['1', '2', '3']", "defaultValue": "", "list": [ { @@ -77,10 +77,10 @@ } ], "required": true, - "toolDescription": "y轴数据,例如:['A', 'B', 'C']" + "toolDescription": "y轴数据,例如:['1', '2', '3']" }, { - "renderTypeList": ["select"], + "renderTypeList": ["select", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -103,7 +103,7 @@ "value": "饼图" } ], - "toolDescription": "图表类型,目前支持三种: 柱状图,折线图,饼图" + "toolDescription": "图表类型:柱状图,折线图,饼图" } ], "outputs": [ @@ -181,7 +181,7 @@ "valueType": "dynamic", "label": "", "required": false, - "description": "接收前方节点的输出值作为变量,这些变量可以被 HTTP 请求参数使用。", + "description": "common:core.module.input.description.HTTP Dynamic Input", "customInputConfig": { "selectValueTypeList": [ "string", @@ -192,6 +192,7 @@ "arrayNumber", "arrayBoolean", "arrayObject", + "arrayAny", "any", "chatHistory", "datasetQuote", @@ -237,7 +238,7 @@ "renderTypeList": ["hidden"], "valueType": "string", "label": "", - "description": "新的 HTTP 请求地址。如果出现两个“请求地址”,可以删除该模块重新加入,会拉取最新的模块配置。", + "description": "common:core.module.input.description.Http Request Url", "placeholder": "https://api.ai.com/getInventory", "required": false, "valueDesc": "", @@ -251,7 +252,7 @@ "valueType": "any", "value": [], "label": "", - "description": "自定义请求头,请严格填入 JSON 字符串。\n1. 确保最后一个属性没有逗号\n2. 确保 key 包含双引号\n例如:{\"Authorization\":\"Bearer xxx\"}", + "description": "common:core.module.input.description.Http Request Header", "placeholder": "common:core.module.input.description.Http Request Header", "required": false, "valueDesc": "", @@ -322,6 +323,7 @@ "arrayNumber", "arrayBoolean", "arrayObject", + "arrayAny", "any", "chatHistory", "datasetQuote", @@ -351,6 +353,7 @@ "arrayNumber", "arrayBoolean", "arrayObject", + "arrayAny", "any", "chatHistory", "datasetQuote", @@ -380,6 +383,7 @@ "arrayNumber", "arrayBoolean", "arrayObject", + "arrayAny", "any", "chatHistory", "datasetQuote", @@ -409,6 +413,7 @@ "arrayNumber", "arrayBoolean", "arrayObject", + "arrayAny", "any", "chatHistory", "datasetQuote", @@ -424,6 +429,23 @@ } ], "outputs": [ + { + "id": "error", + "key": "error", + "label": "workflow:request_error", + "description": "HTTP请求错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "httpRawResponse", + "key": "httpRawResponse", + "required": true, + "label": "workflow:raw_response", + "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。", + "valueType": "any", + "type": "static" + }, { "id": "system_addOutputParam", "key": "system_addOutputParam", @@ -453,25 +475,6 @@ "valueDesc": "", "description": "" }, - { - "id": "error", - "key": "error", - "label": "请求错误", - "description": "HTTP请求错误信息,成功时返回空", - "valueType": "object", - "type": "static", - "valueDesc": "" - }, - { - "id": "httpRawResponse", - "key": "httpRawResponse", - "required": true, - "label": "原始响应", - "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。", - "valueType": "any", - "type": "static", - "valueDesc": "" - }, { "id": "bzaYjKyQFOw2", "valueType": "string", @@ -495,6 +498,26 @@ "sourceHandle": "ws0DFKJnCPhk-source-right", "targetHandle": "pluginOutput-target-left" } - ] + ], + "chatConfig": { + "welcomeText": "", + "variables": [], + "questionGuide": false, + "ttsConfig": { + "type": "web" + }, + "whisperConfig": { + "open": false, + "autoSend": false, + "autoTTSResponse": false + }, + "chatInputGuide": { + "open": false, + "textList": [], + "customUrl": "" + }, + "instruction": "数据源配置,支持主流数据库配置", + "_id": "670a23b31957c5b9899b4a4d" + } } } diff --git a/packages/plugins/src/duckduckgo/search/template.json b/packages/plugins/src/duckduckgo/search/template.json index 6176d5569..d3ef2c3f7 100644 --- a/packages/plugins/src/duckduckgo/search/template.json +++ b/packages/plugins/src/duckduckgo/search/template.json @@ -26,7 +26,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, diff --git a/packages/plugins/src/duckduckgo/searchImg/template.json b/packages/plugins/src/duckduckgo/searchImg/template.json index e3ef73f6e..6dc110d29 100644 --- a/packages/plugins/src/duckduckgo/searchImg/template.json +++ b/packages/plugins/src/duckduckgo/searchImg/template.json @@ -26,7 +26,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, diff --git a/packages/plugins/src/duckduckgo/searchNews/template.json b/packages/plugins/src/duckduckgo/searchNews/template.json index 83554adb6..0c2ef03ad 100644 --- a/packages/plugins/src/duckduckgo/searchNews/template.json +++ b/packages/plugins/src/duckduckgo/searchNews/template.json @@ -26,7 +26,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, diff --git a/packages/plugins/src/duckduckgo/searchVideo/template.json b/packages/plugins/src/duckduckgo/searchVideo/template.json index 4891144f3..4bb9ad0ec 100644 --- a/packages/plugins/src/duckduckgo/searchVideo/template.json +++ b/packages/plugins/src/duckduckgo/searchVideo/template.json @@ -26,7 +26,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, diff --git a/packages/plugins/src/duckduckgo/template.json b/packages/plugins/src/duckduckgo/template.json index d700a6c03..c3365694f 100644 --- a/packages/plugins/src/duckduckgo/template.json +++ b/packages/plugins/src/duckduckgo/template.json @@ -5,10 +5,10 @@ "avatar": "core/workflow/template/duckduckgo", "intro": "DuckDuckGo 服务,包含网络搜索、图片搜索、新闻搜索等。", "showStatus": false, - "weight": 100, + "weight": 11, "isTool": true, - "templateType": "tools", + "templateType": "search", "workflow": { "nodes": [], diff --git a/packages/plugins/src/google/template.json b/packages/plugins/src/google/template.json index 06ba584c4..15bc3e555 100644 --- a/packages/plugins/src/google/template.json +++ b/packages/plugins/src/google/template.json @@ -8,7 +8,7 @@ "weight": 10, "isTool": true, - "templateType": "tools", + "templateType": "search", "workflow": { "nodes": [ @@ -26,7 +26,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["input"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -43,7 +43,7 @@ "required": true }, { - "renderTypeList": ["input"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -51,10 +51,11 @@ "label": "key", "description": "Google搜索key", "defaultValue": "", - "required": true + "required": true, + "list": [] }, { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, diff --git a/packages/plugins/src/wiki/template.json b/packages/plugins/src/wiki/template.json index a5bfeb3d3..c9a98e427 100644 --- a/packages/plugins/src/wiki/template.json +++ b/packages/plugins/src/wiki/template.json @@ -8,7 +8,7 @@ "weight": 10, "isTool": true, - "templateType": "tools", + "templateType": "search", "workflow": { "nodes": [ @@ -26,7 +26,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -34,7 +34,8 @@ "label": "query", "description": "检索词", "required": true, - "toolDescription": "检索词" + "toolDescription": "检索词", + "list": [] } ], "outputs": [ diff --git a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx index c8923d681..322283400 100644 --- a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx +++ b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx @@ -43,7 +43,6 @@ export default function Editor({ onBlur, value, placeholder = '', - isFlow, bg = 'white' }: { minH?: number; @@ -57,7 +56,6 @@ export default function Editor({ onBlur?: (editor: LexicalEditor) => void; value?: string; placeholder?: string; - isFlow?: boolean; bg?: string; }) { const [key, setKey] = useState(getNanoid(6)); @@ -92,7 +90,7 @@ export default function Editor({ { const { isOpen, onOpen, onClose } = useDisclosure(); @@ -69,7 +67,6 @@ const PromptEditor = ({ onChange={onChangeInput} onBlur={onBlurInput} placeholder={placeholder} - isFlow={isFlow} bg={bg} /> diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/InputEditModal.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/InputEditModal.tsx index 42eb04459..adde36f66 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/InputEditModal.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/InputEditModal.tsx @@ -49,37 +49,37 @@ const FieldEditModal = ({ { icon: 'core/workflow/inputType/reference', label: t('common:core.workflow.inputType.Reference'), - value: FlowNodeInputTypeEnum.reference, + value: [FlowNodeInputTypeEnum.reference], defaultValueType: WorkflowIOValueTypeEnum.string }, { icon: 'core/workflow/inputType/input', label: t('common:core.workflow.inputType.textInput'), - value: FlowNodeInputTypeEnum.input, + value: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference], defaultValueType: WorkflowIOValueTypeEnum.string }, { icon: 'core/workflow/inputType/jsonEditor', label: t('common:core.workflow.inputType.JSON Editor'), - value: FlowNodeInputTypeEnum.JSONEditor, + value: [FlowNodeInputTypeEnum.JSONEditor, FlowNodeInputTypeEnum.reference], defaultValueType: WorkflowIOValueTypeEnum.string }, { icon: 'core/workflow/inputType/numberInput', label: t('common:core.workflow.inputType.number input'), - value: FlowNodeInputTypeEnum.numberInput, + value: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference], defaultValueType: WorkflowIOValueTypeEnum.number }, { icon: 'core/workflow/inputType/option', label: t('common:core.workflow.inputType.select'), - value: FlowNodeInputTypeEnum.select, + value: [FlowNodeInputTypeEnum.select, FlowNodeInputTypeEnum.reference], defaultValueType: WorkflowIOValueTypeEnum.string }, { icon: 'core/workflow/inputType/switch', label: t('common:core.workflow.inputType.switch'), - value: FlowNodeInputTypeEnum.switch, + value: [FlowNodeInputTypeEnum.switch, FlowNodeInputTypeEnum.reference], defaultValueType: WorkflowIOValueTypeEnum.boolean } ], @@ -87,13 +87,13 @@ const FieldEditModal = ({ { icon: 'core/workflow/inputType/selectLLM', label: t('common:core.workflow.inputType.selectLLMModel'), - value: FlowNodeInputTypeEnum.selectLLMModel, + value: [FlowNodeInputTypeEnum.selectLLMModel], defaultValueType: WorkflowIOValueTypeEnum.string }, { icon: 'core/workflow/inputType/selectDataset', label: t('common:core.workflow.inputType.selectDataset'), - value: FlowNodeInputTypeEnum.selectDataset, + value: [FlowNodeInputTypeEnum.selectDataset], defaultValueType: WorkflowIOValueTypeEnum.selectDataset }, ...(hasDynamicInput @@ -102,7 +102,7 @@ const FieldEditModal = ({ { icon: 'core/workflow/inputType/dynamic', label: t('common:core.workflow.inputType.dynamicTargetInput'), - value: FlowNodeInputTypeEnum.addInputParam, + value: [FlowNodeInputTypeEnum.addInputParam], defaultValueType: WorkflowIOValueTypeEnum.dynamic } ]) @@ -111,7 +111,7 @@ const FieldEditModal = ({ { icon: 'core/workflow/inputType/customVariable', label: t('common:core.workflow.inputType.custom'), - value: FlowNodeInputTypeEnum.customVariable, + value: [FlowNodeInputTypeEnum.customVariable], defaultValueType: WorkflowIOValueTypeEnum.string, description: t('app:variable.select type_desc') } @@ -119,7 +119,7 @@ const FieldEditModal = ({ ] as { icon: string; label: string; - value: FlowNodeInputTypeEnum; + value: FlowNodeInputTypeEnum[]; defaultValueType: WorkflowIOValueTypeEnum; description?: string; }[][], @@ -138,27 +138,18 @@ const FieldEditModal = ({ const [isToolInput, { toggle: setIsToolInput }] = useBoolean(!!getValues('toolDescription')); - const isRefrence = renderTypeList.includes(FlowNodeInputTypeEnum.reference); - const setIsRefrence = () => { - if (isRefrence) { - setValue( - 'renderTypeList', - renderTypeList.filter((item) => item !== FlowNodeInputTypeEnum.reference) - ); - } else { - setValue('renderTypeList', [...getValues('renderTypeList'), FlowNodeInputTypeEnum.reference]); - } - }; - const maxLength = watch('maxLength'); const max = watch('max'); const min = watch('min'); const selectValueTypeList = watch('customInputConfig.selectValueTypeList'); const defaultInputValue = watch('defaultValue'); - const defaultValueType = - inputTypeList.flat().find((item) => item.value === inputType)?.defaultValueType || - WorkflowIOValueTypeEnum.string; + const defaultValueType = useMemo( + () => + inputTypeList.flat().find((item) => item.value[0] === inputType)?.defaultValueType || + WorkflowIOValueTypeEnum.string, + [inputType, inputTypeList] + ); const onSubmitSuccess = useCallback( (data: FlowNodeInputItemType, action: 'confirm' | 'continue') => { @@ -171,6 +162,7 @@ const FieldEditModal = ({ }); } + // Auto set valueType if ( data.renderTypeList[0] !== FlowNodeInputTypeEnum.reference && data.renderTypeList[0] !== FlowNodeInputTypeEnum.customVariable @@ -178,6 +170,7 @@ const FieldEditModal = ({ data.valueType = defaultValueType; } + // Remove required if ( data.renderTypeList[0] === FlowNodeInputTypeEnum.addInputParam || data.renderTypeList[0] === FlowNodeInputTypeEnum.customVariable @@ -273,7 +266,7 @@ const FieldEditModal = ({ mt={5} > {list.map((item) => { - const isSelected = inputType === item.value; + const isSelected = inputType === item.value[0]; return ( { - setValue('renderTypeList.0', item.value); + setValue('renderTypeList', item.value); }} > void; - isRefrence?: boolean; - setIsRefrence?: () => void; valueType?: WorkflowIOValueTypeEnum; defaultValueType?: WorkflowIOValueTypeEnum; @@ -158,6 +154,18 @@ const InputTypeConfig = ({ return list.includes(inputType as FlowNodeInputTypeEnum); }, [inputType]); + const showIsToolInput = useMemo(() => { + const list = [ + FlowNodeInputTypeEnum.reference, + FlowNodeInputTypeEnum.JSONEditor, + FlowNodeInputTypeEnum.input, + FlowNodeInputTypeEnum.numberInput, + FlowNodeInputTypeEnum.switch, + FlowNodeInputTypeEnum.select + ]; + return type === 'plugin' && list.includes(inputType as FlowNodeInputTypeEnum); + }, [inputType, type]); + return ( @@ -218,24 +226,8 @@ const InputTypeConfig = ({ )} - - {inputType !== FlowNodeInputTypeEnum.reference && setIsRefrence && ( - <> - - - {t('workflow:field_used_as_reference')} - - { - setIsRefrence(); - }} - /> - - - )} {/* reference */} - {(inputType === FlowNodeInputTypeEnum.reference || isRefrence) && ( + {showIsToolInput && ( <> diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx index 66a90a554..2aeb00e58 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx @@ -47,12 +47,11 @@ const TextInputRender = ({ inputs = [], item, nodeId }: RenderInputProps) => { variables={variables} title={t(item.label as any)} maxLength={item.maxLength} - minH={40} + minH={30} maxH={120} placeholder={t(item.placeholder as any)} value={item.value} onChange={onChange} - isFlow={true} /> ); }, [item.label, item.maxLength, item.placeholder, item.value, onChange, t, variables]); diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/Textarea.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/Textarea.tsx index 78a6bcb91..102f9908a 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/Textarea.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/Textarea.tsx @@ -54,7 +54,6 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => { placeholder={t((item.placeholder as any) || '')} value={item.value} onChange={onChange} - isFlow={true} /> ); }, [item.label, item.maxLength, item.placeholder, item.value, onChange, t, variables]);