Closed hjlarry closed 2 months ago
The tool parameter of type number
does support float values in Dify version 0.7.1. The cast_parameter_by_type
method in the ToolParameterConverter
class handles both integer and float values for the ToolParameter.ToolParameterType.NUMBER
type. Here is the relevant code snippet:
case ToolParameter.ToolParameterType.NUMBER:
if isinstance(value, int) | isinstance(value, float):
return value
elif isinstance(value, str) and value != '':
if '.' in value:
return float(value)
else:
return int(value)
This code shows that if the value is a float or can be converted to a float (i.e., it contains a '.'), it will be correctly handled as a float [1].
The error you are encountering seems to be related to the validation rules defined in the configuration schema. Specifically, the default
value of 7.5
is being interpreted as a float, but the validation expects an integer. Ensure that the default
value is correctly specified as a float and that the validation rules allow for float values.
If the issue persists, you might want to check the specific validation rules or constraints defined for the number
type parameters in the configuration schema. These include min
, max
, and precision
constraints, which ensure that numeric parameters adhere to specified ranges and precision levels [2][3].
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.7.1
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
In a tool's config file, set the params like this:
✔️ Expected Behavior
No response
❌ Actual Behavior
raise Exception: