diff --git a/packages/global/core/workflow/node/constant.ts b/packages/global/core/workflow/node/constant.ts index b7cad9839..79cdced16 100644 --- a/packages/global/core/workflow/node/constant.ts +++ b/packages/global/core/workflow/node/constant.ts @@ -15,6 +15,7 @@ export enum FlowNodeInputTypeEnum { // render ui // special input selectApp = 'selectApp', + customVariable = 'customVariable', // ai model select selectLLMModel = 'selectLLMModel', @@ -44,7 +45,7 @@ export const FlowNodeInputMap: Record< icon: 'core/workflow/inputType/numberInput' }, [FlowNodeInputTypeEnum.select]: { - icon: 'core/workflow/inputType/input' + icon: 'core/workflow/inputType/option' }, [FlowNodeInputTypeEnum.switch]: { icon: 'core/workflow/inputType/switch' @@ -79,8 +80,11 @@ export const FlowNodeInputMap: Record< [FlowNodeInputTypeEnum.hidden]: { icon: 'core/workflow/inputType/select' }, + [FlowNodeInputTypeEnum.customVariable]: { + icon: 'core/workflow/inputType/customVariable' + }, [FlowNodeInputTypeEnum.custom]: { - icon: 'core/workflow/inputType/select' + icon: 'core/workflow/inputType/custom' } }; diff --git a/packages/global/core/workflow/utils.ts b/packages/global/core/workflow/utils.ts index 7a12c570a..fbce7d5b7 100644 --- a/packages/global/core/workflow/utils.ts +++ b/packages/global/core/workflow/utils.ts @@ -173,14 +173,17 @@ export const pluginData2FlowNodeIO = ({ const pluginOutput = nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginOutput); return { - inputs: pluginInput - ? pluginInput.inputs.map((item) => ({ - ...item, - ...getModuleInputUiField(item), - value: getOrInitModuleInputValue(item), - canEdit: false - })) - : [], + inputs: + pluginInput?.inputs.map((item) => ({ + ...item, + ...getModuleInputUiField(item), + value: getOrInitModuleInputValue(item), + canEdit: false, + renderTypeList: + item.renderTypeList[0] === FlowNodeInputTypeEnum.customVariable + ? [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.input] + : item.renderTypeList + })) || [], outputs: pluginOutput ? [ ...pluginOutput.inputs.map((item) => ({ diff --git a/packages/web/components/common/Icon/constants.ts b/packages/web/components/common/Icon/constants.ts index 32b7d7fe9..7c307c635 100644 --- a/packages/web/components/common/Icon/constants.ts +++ b/packages/web/components/common/Icon/constants.ts @@ -8,12 +8,10 @@ export const iconPaths = { collectionLight: () => import('./icons/collectionLight.svg'), collectionSolid: () => import('./icons/collectionSolid.svg'), 'common/add2': () => import('./icons/common/add2.svg'), - 'common/setting': () => import('./icons/common/setting.svg'), - 'common/addUser': () => import('./icons/common/addUser.svg'), - 'common/monitor': () => import('./icons/common/monitor.svg'), - 'common/list': () => import('./icons/common/list.svg'), 'common/addCircleLight': () => import('./icons/common/addCircleLight.svg'), 'common/addLight': () => import('./icons/common/addLight.svg'), + 'common/addUser': () => import('./icons/common/addUser.svg'), + 'common/arrowLeft': () => import('./icons/common/arrowLeft.svg'), 'common/backFill': () => import('./icons/common/backFill.svg'), 'common/backLight': () => import('./icons/common/backLight.svg'), 'common/check': () => import('./icons/common/check.svg'), @@ -29,6 +27,7 @@ export const iconPaths = { 'common/errorFill': () => import('./icons/common/errorFill.svg'), 'common/file/move': () => import('./icons/common/file/move.svg'), 'common/folderFill': () => import('./icons/common/folderFill.svg'), + 'common/folderImport': () => import('./icons/common/folderImport.svg'), 'common/fullScreenLight': () => import('./icons/common/fullScreenLight.svg'), 'common/gitFill': () => import('./icons/common/gitFill.svg'), 'common/gitInlight': () => import('./icons/common/gitInlight.svg'), @@ -41,12 +40,12 @@ export const iconPaths = { 'common/language/en': () => import('./icons/common/language/en.svg'), 'common/language/zh': () => import('./icons/common/language/zh.svg'), 'common/leftArrowLight': () => import('./icons/common/leftArrowLight.svg'), - 'common/arrowLeft': () => import('./icons/common/arrowLeft.svg'), 'common/lineChange': () => import('./icons/common/lineChange.svg'), 'common/linkBlue': () => import('./icons/common/linkBlue.svg'), - 'common/folderImport': () => import('./icons/common/folderImport.svg'), + 'common/list': () => import('./icons/common/list.svg'), 'common/loading': () => import('./icons/common/loading.svg'), 'common/logLight': () => import('./icons/common/logLight.svg'), + 'common/monitor': () => import('./icons/common/monitor.svg'), 'common/navbar/pluginFill': () => import('./icons/common/navbar/pluginFill.svg'), 'common/navbar/pluginLight': () => import('./icons/common/navbar/pluginLight.svg'), 'common/openai': () => import('./icons/common/openai.svg'), @@ -67,6 +66,7 @@ export const iconPaths = { 'common/searchLight': () => import('./icons/common/searchLight.svg'), 'common/select': () => import('./icons/common/select.svg'), 'common/selectLight': () => import('./icons/common/selectLight.svg'), + 'common/setting': () => import('./icons/common/setting.svg'), 'common/settingLight': () => import('./icons/common/settingLight.svg'), 'common/subtract': () => import('./icons/common/subtract.svg'), 'common/text/t': () => import('./icons/common/text/t.svg'), @@ -176,12 +176,16 @@ export const iconPaths = { 'core/workflow/debugResult': () => import('./icons/core/workflow/debugResult.svg'), 'core/workflow/edgeArrow': () => import('./icons/core/workflow/edgeArrow.svg'), 'core/workflow/grout': () => import('./icons/core/workflow/grout.svg'), + 'core/workflow/inputType/customVariable': () => + import('./icons/core/workflow/inputType/customVariable.svg'), 'core/workflow/inputType/dynamic': () => import('./icons/core/workflow/inputType/dynamic.svg'), + 'core/workflow/inputType/file': () => import('./icons/core/workflow/inputType/file.svg'), 'core/workflow/inputType/input': () => import('./icons/core/workflow/inputType/input.svg'), 'core/workflow/inputType/jsonEditor': () => import('./icons/core/workflow/inputType/jsonEditor.svg'), 'core/workflow/inputType/numberInput': () => import('./icons/core/workflow/inputType/numberInput.svg'), + 'core/workflow/inputType/option': () => import('./icons/core/workflow/inputType/option.svg'), 'core/workflow/inputType/reference': () => import('./icons/core/workflow/inputType/reference.svg'), 'core/workflow/inputType/select': () => import('./icons/core/workflow/inputType/select.svg'), diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/customVariable.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/customVariable.svg new file mode 100644 index 000000000..01fc80f13 --- /dev/null +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/customVariable.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/dynamic.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/dynamic.svg index 169bf92de..14029e411 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/dynamic.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/dynamic.svg @@ -1,5 +1,3 @@ - - + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/file.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/file.svg new file mode 100644 index 000000000..3997a593c --- /dev/null +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/file.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/input.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/input.svg index 95a42d04c..0cbc64527 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/input.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/input.svg @@ -1,5 +1,5 @@ + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/jsonEditor.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/jsonEditor.svg index 88dd542f8..f64b2e599 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/jsonEditor.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/jsonEditor.svg @@ -1,5 +1,5 @@ + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/numberInput.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/numberInput.svg index 45dd6d134..038d109a7 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/numberInput.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/numberInput.svg @@ -1,5 +1,5 @@ - + + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/option.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/option.svg new file mode 100644 index 000000000..62c845c98 --- /dev/null +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/option.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/reference.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/reference.svg index 20c8b94b7..df4d07b2a 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/reference.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/reference.svg @@ -1,11 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/selectApp.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/selectApp.svg index f9c8dc540..492777a5a 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/selectApp.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/selectApp.svg @@ -1,14 +1,14 @@ + /> + /> + /> + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/selectDataset.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/selectDataset.svg index 8a8cd6301..7a68e2520 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/selectDataset.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/selectDataset.svg @@ -1,11 +1,11 @@ + /> + /> + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/selectLLM.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/selectLLM.svg index a256d6166..0077f66ec 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/selectLLM.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/selectLLM.svg @@ -1,5 +1,5 @@ + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/switch.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/switch.svg index 62655f8b1..2a041eab2 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/switch.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/switch.svg @@ -1,8 +1,8 @@ - + + /> + /> \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/core/workflow/inputType/textarea.svg b/packages/web/components/common/Icon/icons/core/workflow/inputType/textarea.svg index 2af94229c..c424e1a0e 100644 --- a/packages/web/components/common/Icon/icons/core/workflow/inputType/textarea.svg +++ b/packages/web/components/common/Icon/icons/core/workflow/inputType/textarea.svg @@ -1,5 +1,5 @@ - + + /> \ No newline at end of file diff --git a/packages/web/components/common/MySelect/MultipleSelect.tsx b/packages/web/components/common/MySelect/MultipleSelect.tsx index edd530c5c..7c9489612 100644 --- a/packages/web/components/common/MySelect/MultipleSelect.tsx +++ b/packages/web/components/common/MySelect/MultipleSelect.tsx @@ -76,6 +76,7 @@ const MultipleSelect = ({ as={Box} ref={ref} width={width} + minH={'40px'} px={3} py={2} borderRadius={'md'} diff --git a/packages/web/components/core/workflow/NodeInputSelect.tsx b/packages/web/components/core/workflow/NodeInputSelect.tsx index 50d29855e..044754a67 100644 --- a/packages/web/components/core/workflow/NodeInputSelect.tsx +++ b/packages/web/components/core/workflow/NodeInputSelect.tsx @@ -151,7 +151,7 @@ const NodeInputSelect = ({ Button={ } + leftIcon={} rightIcon={} variant={'grayBase'} border={theme.borders.base} diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index 4e61198a9..23aa62856 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -27,6 +27,7 @@ "Login": "Login", "Move": "Move", "Name": "Name", + "Not_selected": "Not selected", "Rename": "Rename", "Resume": "Resume", "Running": "Running", @@ -293,6 +294,9 @@ "zoomout_tip": "zoomOut ctrl +", "zoomout_tip_mac": "zoomOut ⌘ +" }, + "comon": { + "Continue_Adding": "Continue Adding" + }, "confirm_choice": "Confirm selection", "contribute_app_template": "Contribution template", "core": { @@ -982,9 +986,12 @@ "Manual input": "Manual input", "Manual select": "Manual select", "Reference": "Variable reference", + "custom": "Custom", "dynamicTargetInput": "Dynamic external data", + "file_link": "File link", "input": "Single line input box", "number input": "Number input box", + "select": "Select", "selectApp": "App selection", "selectDataset": "Knowledge base selection", "selectLLMModel": "Dialogue model selection", diff --git a/packages/web/i18n/zh/common.json b/packages/web/i18n/zh/common.json index 05ea15982..f0d9cf466 100644 --- a/packages/web/i18n/zh/common.json +++ b/packages/web/i18n/zh/common.json @@ -27,6 +27,7 @@ "Login": "登录", "Move": "移动", "Name": "名称", + "Not_selected": "未选择", "Rename": "重命名", "Resume": "恢复", "Running": "运行中", @@ -293,6 +294,9 @@ "zoomout_tip": "放大 ctrl +", "zoomout_tip_mac": "放大 ⌘ +" }, + "comon": { + "Continue_Adding": "继续添加" + }, "confirm_choice": "确认选择", "contribute_app_template": "贡献模板", "core": { @@ -638,8 +642,7 @@ "success": "开始同步" } }, - "training": { - } + "training": {} }, "data": { "Auxiliary Data": "辅助数据", @@ -982,9 +985,12 @@ "Manual input": "手动输入", "Manual select": "手动选择", "Reference": "变量引用", + "custom": "自定义变量", "dynamicTargetInput": "动态外部数据", + "file_link": "文件上传", "input": "单行输入框", "number input": "数字输入框", + "select": "单选框", "selectApp": "应用选择", "selectDataset": "知识库选择", "selectLLMModel": "对话模型选择", @@ -1130,10 +1136,10 @@ "package_tip": { "buy": "您购买的套餐等级低于当前套餐,该套餐将在当前套餐过期后生效。\n您可在账号—个人信息—套餐详情里,查看套餐使用情况。", "renewal": "您正在续费套餐。您可在账号—个人信息—套餐详情里,查看套餐使用情况。", - "upgrade": "您购买的套餐等级高于当前套餐,该套餐将即刻生效,当前套餐将延后生效。\n您可在账号—个人信息—套餐详情里,查看套餐使用情况。" + "upgrade": "您购买的套餐等级高于当前套餐,该套餐将即刻生效,当前套餐将延后生效。您可在账号—个人信息—套餐详情里,查看套餐使用情况。" }, "to_recharge": "余额不足,去充值", - "wechat": "微信扫码支付: {{price}}元\n请勿关闭页面", + "wechat": "请微信扫码支付: {{price}}元\n请勿关闭页面", "yuan": "{{amount}}元" }, "permission": { diff --git a/projects/app/public/appMarketTemplates/CQ/template.json b/projects/app/public/appMarketTemplates/CQ/template.json index a0018a01d..0d2019ed2 100644 --- a/projects/app/public/appMarketTemplates/CQ/template.json +++ b/projects/app/public/appMarketTemplates/CQ/template.json @@ -411,7 +411,7 @@ }, { "key": "userChatInput", - "renderTypeList": ["FlowNodeInputTypeEnum.reference", "FlowNodeInputTypeEnum.textarea"], + "renderTypeList": ["reference", "FlowNodeInputTypeEnum.textarea"], "valueType": "WorkflowIOValueTypeEnum.string", "label": "用户问题", "required": true, diff --git a/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json b/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json index dbaf47fb7..4f2e9e05b 100644 --- a/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json +++ b/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json @@ -258,7 +258,7 @@ }, { "key": "limit", - "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "renderTypeList": ["hidden"], "label": "", "value": 1500, "valueType": "WorkflowIOValueTypeEnum.number" diff --git a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx index 1655e1ea0..84a9b2289 100644 --- a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx @@ -108,15 +108,9 @@ const RenderInput = () => { ); }} diff --git a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx index 70e73757e..fb96f19a3 100644 --- a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx @@ -6,10 +6,14 @@ import { NumberInput, NumberInputField, NumberInputStepper, + Select, Switch, Textarea } from '@chakra-ui/react'; import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; +import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; +import { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; +import MySelect from '@fastgpt/web/components/common/MySelect'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import { useTranslation } from 'next-i18next'; import dynamic from 'next/dynamic'; @@ -18,58 +22,53 @@ const JsonEditor = dynamic(() => import('@fastgpt/web/components/common/Textarea const RenderPluginInput = ({ value, - defaultValue, onChange, - label, - description, isDisabled, - valueType, - placeholder, - required, - min, - max, - isInvalid + isInvalid, + input }: { value: any; - defaultValue?: any; onChange: () => void; - label: string; - description?: string; isDisabled?: boolean; - valueType: WorkflowIOValueTypeEnum | undefined; - placeholder?: string; - required?: boolean; - min?: number; - max?: number; isInvalid: boolean; + input: FlowNodeInputItemType; }) => { const { t } = useTranslation(); + const inputType = input.renderTypeList[0]; const render = (() => { - if (valueType === WorkflowIOValueTypeEnum.string) { + if (inputType === FlowNodeInputTypeEnum.customVariable) { + return null; + } + if (inputType === FlowNodeInputTypeEnum.select && input.list) { + return ( + + ); + } + if (input.valueType === WorkflowIOValueTypeEnum.string) { return ( ); } - if (valueType === WorkflowIOValueTypeEnum.number) { + if (input.valueType === WorkflowIOValueTypeEnum.number) { return ( - + @@ -77,14 +76,14 @@ const RenderPluginInput = ({ ); } - if (valueType === WorkflowIOValueTypeEnum.boolean) { + if (input.valueType === WorkflowIOValueTypeEnum.boolean) { return ( ); } @@ -92,12 +91,12 @@ const RenderPluginInput = ({ return ( ); })(); @@ -106,14 +105,14 @@ const RenderPluginInput = ({ - {required && ( + {input.required && ( * )} - {label} + {input.label} - {description && } + {input.description && } {render} diff --git a/projects/app/src/pages/app/detail/components/SimpleApp/components/ToolSelectModal.tsx b/projects/app/src/pages/app/detail/components/SimpleApp/components/ToolSelectModal.tsx index 10ca2e226..3e1b773a4 100644 --- a/projects/app/src/pages/app/detail/components/SimpleApp/components/ToolSelectModal.tsx +++ b/projects/app/src/pages/app/detail/components/SimpleApp/components/ToolSelectModal.tsx @@ -378,15 +378,9 @@ const RenderList = React.memo(function RenderList({ return ( ); }} diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeCode.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeCode.tsx index 9590f9f06..0bb269c23 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeCode.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeCode.tsx @@ -38,7 +38,7 @@ const NodeCode = ({ data, selected }: NodeProps) => { return ( - Javascript{workflowT('Code')} + {'Javascript ' + workflowT('Code')} void; }) => { const { t } = useTranslation(); - const { workflowT } = useI18n(); const { toast } = useToast(); const inputTypeList = useMemo( - () => [ - { - label: t('common:core.workflow.inputType.Reference'), - value: FlowNodeInputTypeEnum.reference, - defaultValueType: WorkflowIOValueTypeEnum.string - }, - { - label: t('common:core.workflow.inputType.input'), - value: FlowNodeInputTypeEnum.input, - defaultValueType: WorkflowIOValueTypeEnum.string - }, - { - label: t('common:core.workflow.inputType.textarea'), - value: FlowNodeInputTypeEnum.textarea, - defaultValueType: WorkflowIOValueTypeEnum.string - }, - { - label: t('common:core.workflow.inputType.JSON Editor'), - value: FlowNodeInputTypeEnum.JSONEditor, - defaultValueType: WorkflowIOValueTypeEnum.string - }, - { - label: t('common:core.workflow.inputType.number input'), - value: FlowNodeInputTypeEnum.numberInput, - defaultValueType: WorkflowIOValueTypeEnum.number - }, - { - label: t('common:core.workflow.inputType.switch'), - value: FlowNodeInputTypeEnum.switch, - defaultValueType: WorkflowIOValueTypeEnum.boolean - }, - { - label: t('common:core.workflow.inputType.selectApp'), - value: FlowNodeInputTypeEnum.selectApp, - defaultValueType: WorkflowIOValueTypeEnum.selectApp - }, - { - label: t('common:core.workflow.inputType.selectLLMModel'), - value: FlowNodeInputTypeEnum.selectLLMModel, - defaultValueType: WorkflowIOValueTypeEnum.string - }, - { - label: t('common:core.workflow.inputType.selectDataset'), - value: FlowNodeInputTypeEnum.selectDataset, - defaultValueType: WorkflowIOValueTypeEnum.selectDataset - }, - ...(hasDynamicInput - ? [] - : [ - { - label: t('common:core.workflow.inputType.dynamicTargetInput'), - value: FlowNodeInputTypeEnum.addInputParam, - defaultValueType: WorkflowIOValueTypeEnum.dynamic - } - ]) - ], + () => + [ + [ + { + icon: 'core/workflow/inputType/reference', + label: t('common:core.workflow.inputType.Reference'), + value: FlowNodeInputTypeEnum.reference, + defaultValueType: WorkflowIOValueTypeEnum.string + }, + { + icon: 'core/workflow/inputType/input', + label: t('common:core.workflow.inputType.input'), + value: FlowNodeInputTypeEnum.input, + defaultValueType: WorkflowIOValueTypeEnum.string + }, + { + icon: 'core/workflow/inputType/textarea', + label: t('common:core.workflow.inputType.textarea'), + value: FlowNodeInputTypeEnum.textarea, + defaultValueType: WorkflowIOValueTypeEnum.string + }, + { + icon: 'core/workflow/inputType/jsonEditor', + label: t('common:core.workflow.inputType.JSON Editor'), + value: FlowNodeInputTypeEnum.JSONEditor, + defaultValueType: WorkflowIOValueTypeEnum.string + }, + { + icon: 'core/workflow/inputType/numberInput', + label: t('common:core.workflow.inputType.number input'), + value: FlowNodeInputTypeEnum.numberInput, + defaultValueType: WorkflowIOValueTypeEnum.number + }, + { + icon: 'core/workflow/inputType/option', + label: t('common:core.workflow.inputType.select'), + value: FlowNodeInputTypeEnum.select, + defaultValueType: WorkflowIOValueTypeEnum.string + }, + { + icon: 'core/workflow/inputType/switch', + label: t('common:core.workflow.inputType.switch'), + value: FlowNodeInputTypeEnum.switch, + defaultValueType: WorkflowIOValueTypeEnum.boolean + } + ], + [ + { + icon: 'core/workflow/inputType/selectApp', + label: t('common:core.workflow.inputType.selectApp'), + value: FlowNodeInputTypeEnum.selectApp, + defaultValueType: WorkflowIOValueTypeEnum.selectApp + }, + { + icon: 'core/workflow/inputType/selectLLM', + label: t('common:core.workflow.inputType.selectLLMModel'), + value: FlowNodeInputTypeEnum.selectLLMModel, + defaultValueType: WorkflowIOValueTypeEnum.string + }, + { + icon: 'core/workflow/inputType/selectDataset', + label: t('common:core.workflow.inputType.selectDataset'), + value: FlowNodeInputTypeEnum.selectDataset, + defaultValueType: WorkflowIOValueTypeEnum.selectDataset + }, + ...(hasDynamicInput + ? [] + : [ + { + icon: 'core/workflow/inputType/dynamic', + label: t('common:core.workflow.inputType.dynamicTargetInput'), + value: FlowNodeInputTypeEnum.addInputParam, + defaultValueType: WorkflowIOValueTypeEnum.dynamic + } + ]) + ], + [ + { + icon: 'core/workflow/inputType/customVariable', + label: t('common:core.workflow.inputType.custom'), + value: FlowNodeInputTypeEnum.customVariable, + defaultValueType: WorkflowIOValueTypeEnum.string, + description: t('app:variable.select type_desc') + } + ] + ] as { + icon: string; + label: string; + value: FlowNodeInputTypeEnum; + defaultValueType: WorkflowIOValueTypeEnum; + description?: string; + }[][], [hasDynamicInput, t] ); const isEdit = !!defaultValue.key; - const { register, getValues, setValue, handleSubmit, watch } = useForm({ - defaultValues: defaultValue + const { register, getValues, setValue, handleSubmit, watch, control, reset } = useForm({ + defaultValues: { + ...defaultValue, + list: defaultValue.list?.length ? defaultValue.list : [{ label: '', value: '' }] + } + }); + const { + fields: selectEnums, + append: appendEnums, + remove: removeEnums + } = useFieldArray({ + control, + name: 'list' }); const inputType = watch('renderTypeList.0') || FlowNodeInputTypeEnum.reference; @@ -134,11 +181,13 @@ const FieldEditModal = ({ const min = watch('min'); const selectValueTypeList = watch('customInputConfig.selectValueTypeList'); - const showValueTypeSelect = inputType === FlowNodeInputTypeEnum.reference; + const showValueTypeSelect = + inputType === FlowNodeInputTypeEnum.reference || + inputType === FlowNodeInputTypeEnum.customVariable; // input type config const showRequired = useMemo(() => { - const list = [FlowNodeInputTypeEnum.addInputParam]; + const list = [FlowNodeInputTypeEnum.addInputParam, FlowNodeInputTypeEnum.customVariable]; return !list.includes(inputType); }, [inputType]); const showDefaultValue = useMemo(() => { @@ -167,11 +216,11 @@ const FieldEditModal = ({ value: item.value })); const defaultValueType = - inputTypeList.find((item) => item.value === inputType)?.defaultValueType || + inputTypeList.flat().find((item) => item.value === inputType)?.defaultValueType || WorkflowIOValueTypeEnum.string; const onSubmitSuccess = useCallback( - (data: FlowNodeInputItemType) => { + (data: FlowNodeInputItemType, action: 'confirm' | 'continue') => { data.key = data?.key?.trim(); if (!data.key) { @@ -181,17 +230,27 @@ const FieldEditModal = ({ }); } - if (data.renderTypeList[0] !== FlowNodeInputTypeEnum.reference) { + if ( + data.renderTypeList[0] !== FlowNodeInputTypeEnum.reference && + data.renderTypeList[0] !== FlowNodeInputTypeEnum.customVariable + ) { data.valueType = defaultValueType; } + if ( + data.renderTypeList[0] === FlowNodeInputTypeEnum.addInputParam || + data.renderTypeList[0] === FlowNodeInputTypeEnum.customVariable + ) { + data.required = false; + } + const isChangeKey = defaultValue.key !== data.key; // create check key if (keys.includes(data.key)) { if (!isEdit || isChangeKey) { toast({ status: 'warning', - title: workflowT('field_name_already_exists') + title: t('workflow:field_name_already_exists') }); return; } @@ -205,11 +264,23 @@ const FieldEditModal = ({ data.label = data.key; - onSubmit({ - data, - isChangeKey - }); - onClose(); + if (action === 'confirm') { + onSubmit({ + data, + isChangeKey + }); + onClose(); + } else if (action === 'continue') { + onSubmit({ + data, + isChangeKey + }); + toast({ + status: 'success', + title: t('common:common.Add Success') + }); + reset(defaultInput); + } }, [ defaultValue.key, @@ -217,11 +288,11 @@ const FieldEditModal = ({ isEdit, isToolInput, keys, - onClose, onSubmit, t, toast, - workflowT + onClose, + reset ] ); const onSubmitError = useCallback( @@ -242,206 +313,342 @@ const FieldEditModal = ({ return ( - - - - {t('common:core.module.Input Type')} - - - list={inputTypeList} - value={inputType} - onchange={(e) => { - setValue('renderTypeList.0', e); - }} - /> - - - - {t('common:core.module.Field Name')} - - - - - {workflowT('field_description')} + + + + + {t('common:core.module.Input Type')} - + + {inputTypeList.map((list, index) => { + return ( + + {list.map((item) => { + const isSelected = inputType === item.value; + return ( + svg': { + color: 'primary.600' + }, + '& > span': { + color: 'myGray.900' + }, + border: '1px solid #3370FF', + boxShadow: '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)' + }} + onClick={() => { + setValue('renderTypeList.0', item.value); + }} + > + + + {item.label} + + {item.description && } + + ); + })} + + ); + })} + {/* input type config */} - - {/* value type */} - - {t('common:core.module.Data Type')} - {showValueTypeSelect ? ( - - - list={valueTypeSelectList} - value={valueType} - onchange={(e) => { - setValue('valueType', e); + + + + + {t('common:core.module.Field Name')} + + + + + + {t('workflow:field_description')} + + + + + {/* value type */} + + + {t('common:core.module.Data Type')} + + {showValueTypeSelect ? ( + + + list={valueTypeSelectList} + value={valueType} + onchange={(e) => { + setValue('valueType', e); + }} + /> + + ) : ( + {defaultValueType} + )} + + + {showRequired && ( + + + {t('workflow:field_required')} + + + + )} + + {/* reference */} + {inputType === FlowNodeInputTypeEnum.reference && ( + <> + + + {t('workflow:field_used_as_tool_input')} + + { + setIsToolInput(); + console.log(isToolInput); + }} + /> + + + )} + + {showMaxLenInput && ( + + + {t('common:core.module.Max Length')} + + { + // @ts-ignore + setValue('maxLength', e || ''); }} /> - - ) : ( - defaultValueType + + )} + + {showMinMaxInput && ( + <> + + + {t('common:core.module.Max Value')} + + { + // @ts-ignore + setValue('max', e || ''); + }} + /> + + + + {t('common:core.module.Min Value')} + + { + // @ts-ignore + setValue('min', e || ''); + }} + /> + + + )} + + {showDefaultValue && ( + + + {t('common:core.module.Default Value')} + + {inputType === FlowNodeInputTypeEnum.numberInput && ( + + )} + {inputType === FlowNodeInputTypeEnum.input && ( + + )} + {inputType === FlowNodeInputTypeEnum.textarea && ( + + )} + {inputType === FlowNodeInputTypeEnum.JSONEditor && ( + { + setValue('defaultValue', e); + }} + defaultValue={String(getValues('defaultValue'))} + /> + )} + {inputType === FlowNodeInputTypeEnum.switch && ( + + )} + + )} + + {inputType === FlowNodeInputTypeEnum.addInputParam && ( + <> + + + {t('common:core.module.Input Type')} + + {t('workflow:only_the_reference_type_is_supported')} + + + + {t('workflow:optional_value_type')} + + + + list={valueTypeSelectList} + bg={'myGray.50'} + value={selectValueTypeList || []} + onSelect={(e) => { + setValue('customInputConfig.selectValueTypeList', e); + }} + /> + + + )} + + {inputType === FlowNodeInputTypeEnum.select && ( + <> + + {selectEnums.map((item, i) => ( + + + {`${t('common:core.module.variable.variable options')} ${i + 1}`} + + + + {selectEnums.length > 1 && ( + removeEnums(i)} + /> + )} + + ))} + + } + onClick={() => appendEnums({ label: '', value: '' })} + fontWeight={'medium'} + fontSize={'12px'} + w={'24'} + py={2} + > + {t('common:core.module.variable add option')} + + )} - {showRequired && ( - - {workflowT('field_required')} - - - )} - - {/* reference */} - {inputType === FlowNodeInputTypeEnum.reference && ( - <> - - {workflowT('field_used_as_tool_input')} - { - setIsToolInput(); - }} - /> - - - )} - - {showMaxLenInput && ( - - {t('common:core.module.Max Length')} - { - // @ts-ignore - setValue('maxLength', e || ''); - }} - /> - - )} - - {showMinMaxInput && ( - <> - - {t('common:core.module.Max Value')} - { - // @ts-ignore - setValue('max', e || ''); - }} - /> - - - {t('common:core.module.Min Value')} - { - // @ts-ignore - setValue('min', e || ''); - }} - /> - - - )} - - {showDefaultValue && ( - - - {t('common:core.module.Default Value')} - - {inputType === FlowNodeInputTypeEnum.numberInput && ( - - )} - {inputType === FlowNodeInputTypeEnum.input && ( - - )} - {inputType === FlowNodeInputTypeEnum.textarea && ( - - )} - {inputType === FlowNodeInputTypeEnum.JSONEditor && ( - { - setValue('defaultValue', e); - }} - defaultValue={String(getValues('defaultValue'))} - /> - )} - {inputType === FlowNodeInputTypeEnum.switch && ( - - )} - - )} - - {inputType === FlowNodeInputTypeEnum.addInputParam && ( - <> - - {t('common:core.module.Input Type')} - - {workflowT('only_the_reference_type_is_supported')} - - - - - {workflowT('optional_value_type')} - - - - list={valueTypeSelectList} - bg={'myGray.50'} - value={selectValueTypeList || []} - onSelect={(e) => { - setValue('customInputConfig.selectValueTypeList', e); - }} - /> - - - )} + + + + {!isEdit && ( + + )} + - - - - - - + ); }; diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/VariableTable.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/VariableTable.tsx index 69430fce6..ea1fddbe7 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/VariableTable.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/VariableTable.tsx @@ -36,7 +36,9 @@ const VariableTable = ({
- {!!item.icon && } + {!!item.icon && ( + + )} {item.label || item.key} @@ -48,6 +50,7 @@ const VariableTable = ({ name={'common/settingLight'} w={'16px'} cursor={'pointer'} + _hover={{ color: 'primary.600' }} onClick={() => onEdit(item.key)} /> ) => bg={'white'} borderRadius={'xs'} mx={2} + color={'primary.600'} onClick={() => { onUpdateList( updateList.map((update, i) => {