This commit is contained in:
非法操作 2025-12-29 15:43:28 +08:00 committed by GitHub
commit 2d7d2d9760
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 4 deletions

View File

@ -79,6 +79,10 @@ class PluginParameter(BaseModel):
default: Union[float, int, str, bool, list, dict] | None = None
min: Union[float, int] | None = None
max: Union[float, int] | None = None
multiple: bool | None = Field(
default=False,
description="Whether the parameter is multiple select, only valid for select or dynamic-select type",
)
precision: int | None = None
options: list[PluginParameterOption] = Field(default_factory=list)
@ -112,8 +116,11 @@ def cast_parameter_value(typ: StrEnum, value: Any, /):
):
if value is None:
return ""
else:
return value if isinstance(value, str) else str(value)
if isinstance(value, list):
return value
if isinstance(value, str):
return value
return str(value)
case PluginParameterType.BOOLEAN:
if value is None:

View File

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

View File

@ -121,6 +121,7 @@ export type CredentialFormSchemaBase = {
label: TypeWithI18N
type: FormTypeEnum
required: boolean
multiple?: boolean
default?: string
tooltip?: TypeWithI18N
show_on: FormShowOnObject[]

View File

@ -110,6 +110,8 @@ const FormInputItem: FC<Props> = ({
return VarType.arrayFile
else if (type === FormTypeEnum.file)
return VarType.file
else if (isMultipleSelect)
return VarType.array
else if (isSelect)
return VarType.string
// else if (isAppSelector)
@ -129,6 +131,8 @@ const FormInputItem: FC<Props> = ({
const getFilterVar = () => {
if (isNumber)
return (varPayload: any) => varPayload.type === VarType.number
else if (isMultipleSelect)
return (varPayload: any) => [VarType.array, VarType.arrayString, VarType.arrayNumber, VarType.arrayObject].includes(varPayload.type)
else if (isString)
return (varPayload: any) => [VarType.string, VarType.number, VarType.secret].includes(varPayload.type)
else if (isFile)