fix: refine handling of constant and mixed input types in ToolManager and ToolNodeData (#22903)

This commit is contained in:
Yeuoly
2025-07-24 16:14:08 +08:00
committed by GitHub
parent 6ac06486e3
commit 9237976988
3 changed files with 7 additions and 5 deletions

View File

@@ -1011,7 +1011,9 @@ class ToolManager:
if variable is None: if variable is None:
raise ToolParameterError(f"Variable {tool_input.value} does not exist") raise ToolParameterError(f"Variable {tool_input.value} does not exist")
parameter_value = variable.value parameter_value = variable.value
elif tool_input.type in {"mixed", "constant"}: elif tool_input.type == "constant":
parameter_value = tool_input.value
elif tool_input.type == "mixed":
segment_group = variable_pool.convert_template(str(tool_input.value)) segment_group = variable_pool.convert_template(str(tool_input.value))
parameter_value = segment_group.text parameter_value = segment_group.text
else: else:

View File

@@ -54,7 +54,7 @@ class ToolNodeData(BaseNodeData, ToolEntity):
for val in value: for val in value:
if not isinstance(val, str): if not isinstance(val, str):
raise ValueError("value must be a list of strings") raise ValueError("value must be a list of strings")
elif typ == "constant" and not isinstance(value, str | int | float | bool): elif typ == "constant" and not isinstance(value, str | int | float | bool | dict):
raise ValueError("value must be a string, int, float, or bool") raise ValueError("value must be a string, int, float, or bool")
return typ return typ

View File

@@ -164,7 +164,7 @@ const FormInputItem: FC<Props> = ({
...value, ...value,
[variable]: { [variable]: {
...varInput, ...varInput,
...newValue, value: newValue,
}, },
}) })
} }
@@ -242,7 +242,7 @@ const FormInputItem: FC<Props> = ({
<AppSelector <AppSelector
disabled={readOnly} disabled={readOnly}
scope={scope || 'all'} scope={scope || 'all'}
value={varInput as any} value={varInput?.value}
onSelect={handleAppOrModelSelect} onSelect={handleAppOrModelSelect}
/> />
)} )}
@@ -251,7 +251,7 @@ const FormInputItem: FC<Props> = ({
popupClassName='!w-[387px]' popupClassName='!w-[387px]'
isAdvancedMode isAdvancedMode
isInWorkflow isInWorkflow
value={varInput} value={varInput?.value}
setModel={handleAppOrModelSelect} setModel={handleAppOrModelSelect}
readonly={readOnly} readonly={readOnly}
scope={scope} scope={scope}