From 459a6709c4c2c741c7686ef535a56c85c7fc6d32 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Tue, 30 Dec 2025 15:14:23 +0800 Subject: [PATCH] feat: The parameter type of the parameter extraction node is recommended to be lowercase, and the parameter type of the function is missing the boolean type (#4586) --- .../step_node/tool_lib_node/impl/base_tool_lib_node.py | 5 +++++ .../flow/step_node/tool_node/i_tool_node.py | 2 +- .../flow/step_node/tool_node/impl/base_tool_node.py | 5 +++++ apps/tools/serializers/tool.py | 3 +++ ui/src/views/tool/component/FieldFormDialog.vue | 2 +- .../component/ParametersFieldDialog.vue | 10 +++++----- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py b/apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py index 61f35f58c..abbba7508 100644 --- a/apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py +++ b/apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py @@ -56,6 +56,8 @@ def valid_reference_value(_type, value, name): try: if _type == 'int': instance_type = int | float + elif _type == 'boolean': + instance_type = bool elif _type == 'float': instance_type = float | int elif _type == 'dict': @@ -103,6 +105,9 @@ def convert_value(name: str, value, _type, is_required, source, node): value = node.workflow_manage.generate_prompt(value) if _type == 'int': return int(value) + if _type == 'boolean': + value = 0 if ['0', '[]'].__contains__(value) else value + return bool(value) if _type == 'float': return float(value) if _type == 'dict': diff --git a/apps/application/flow/step_node/tool_node/i_tool_node.py b/apps/application/flow/step_node/tool_node/i_tool_node.py index 6ee077ed7..1b34e96fe 100644 --- a/apps/application/flow/step_node/tool_node/i_tool_node.py +++ b/apps/application/flow/step_node/tool_node/i_tool_node.py @@ -24,7 +24,7 @@ class InputField(serializers.Serializer): name = serializers.CharField(required=True, label=_('Variable Name')) is_required = serializers.BooleanField(required=True, label=_("Is this field required")) type = serializers.CharField(required=True, label=_("type"), validators=[ - validators.RegexValidator(regex=re.compile("^string|int|dict|array|float$"), + validators.RegexValidator(regex=re.compile("^string|int|dict|array|float|boolean$"), message=_("The field only supports string|int|dict|array|float"), code=500) ]) source = serializers.CharField(required=True, label=_("source"), validators=[ diff --git a/apps/application/flow/step_node/tool_node/impl/base_tool_node.py b/apps/application/flow/step_node/tool_node/impl/base_tool_node.py index 5cc9e1711..f7220b2fc 100644 --- a/apps/application/flow/step_node/tool_node/impl/base_tool_node.py +++ b/apps/application/flow/step_node/tool_node/impl/base_tool_node.py @@ -35,6 +35,8 @@ def valid_reference_value(_type, value, name): try: if _type == 'int': instance_type = int | float + elif _type == 'boolean': + instance_type = bool elif _type == 'float': instance_type = float | int elif _type == 'dict': @@ -82,6 +84,9 @@ def convert_value(name: str, value, _type, is_required, source, node): value = node.workflow_manage.generate_prompt(value) if _type == 'int': return int(value) + if _type == 'boolean': + value = 0 if ['0', '[]'].__contains__(value) else value + return bool(value) if _type == 'float': return float(value) if _type == 'dict': diff --git a/apps/tools/serializers/tool.py b/apps/tools/serializers/tool.py index e39e7476b..b8f09b687 100644 --- a/apps/tools/serializers/tool.py +++ b/apps/tools/serializers/tool.py @@ -438,6 +438,9 @@ class ToolSerializer(serializers.Serializer): try: if _type == 'int': return int(value) + if _type == 'boolean': + value = 0 if ['0', '[]'].__contains__(value) else value + return bool(value) if _type == 'float': return float(value) if _type == 'dict': diff --git a/ui/src/views/tool/component/FieldFormDialog.vue b/ui/src/views/tool/component/FieldFormDialog.vue index f817956b3..83e4e903e 100644 --- a/ui/src/views/tool/component/FieldFormDialog.vue +++ b/ui/src/views/tool/component/FieldFormDialog.vue @@ -62,7 +62,7 @@ import { ref, reactive, watch } from 'vue' import type { FormInstance } from 'element-plus' import { cloneDeep } from 'lodash' import { t } from '@/locales' -const typeOptions = ['string', 'int', 'dict', 'array', 'float'] +const typeOptions = ['string', 'int', 'dict', 'array', 'float', 'boolean'] const emit = defineEmits(['refresh']) diff --git a/ui/src/workflow/nodes/parameter-extraction-node/component/ParametersFieldDialog.vue b/ui/src/workflow/nodes/parameter-extraction-node/component/ParametersFieldDialog.vue index d300b680f..aae6bde4f 100644 --- a/ui/src/workflow/nodes/parameter-extraction-node/component/ParametersFieldDialog.vue +++ b/ui/src/workflow/nodes/parameter-extraction-node/component/ParametersFieldDialog.vue @@ -93,23 +93,23 @@ const emit = defineEmits(['refresh']) const options = [ { value: 'string', - label: 'String', + label: 'string', }, { value: 'number', - label: 'Number', + label: 'number', }, { value: 'object', - label: 'Object', + label: 'object', }, { value: 'boolean', - label: 'Boolean', + label: 'boolean', }, { value: 'array', - label: 'Array', + label: 'array', }, ] const fieldFormRef = ref()