Open forrestsocool opened 1 week ago
The issue with the article_ids
parameter being recognized as StringType
instead of ArrayType[StringType]
in Dify version 0.6.11 is due to the _get_tool_parameter_type
method in the ApiBasedToolSchemaParser
class not handling array types. This method currently only checks for integer
, number
, boolean
, and string
types, and defaults to STRING
for any other type.
Here is the relevant part of the code:
@staticmethod
def _get_tool_parameter_type(parameter: dict) -> ToolParameter.ToolParameterType:
parameter = parameter or {}
typ = None
if 'type' in parameter:
typ = parameter['type']
elif 'schema' in parameter and 'type' in parameter['schema']:
typ = parameter['schema']['type']
if typ == 'integer' or typ == 'number':
return ToolParameter.ToolParameterType.NUMBER
elif typ == 'boolean':
return ToolParameter.ToolParameterType.BOOLEAN
elif typ == 'string':
return ToolParameter.ToolParameterType.STRING
Since the method does not check for array
type, it defaults to STRING
. To fix this, you would need to modify the _get_tool_parameter_type
method to handle array
types appropriately [1].
To continue talking to Dosu, mention @dosu.
Our tool currently doesn't support array-type parameters, we might add this feature in the future.
Self Checks
Dify version
0.6.11
Cloud or Self Hosted
Cloud
Steps to reproduce
Import this openapi schema as custom tool, add it into a workflow later, the "article_ids" parameter of ApiInsertArticleInsert is recognized as StringType instead of ArrayType[StringType ] (which Coze workflow can recognize correctly, though it only support 3.0.0 openApi schema, u can convert it ):
the openapi 3.1.0 schema generated by LiteStar
openapi (4).json
✔️ Expected Behavior
type of paramerter article_ids should be list[str]
❌ Actual Behavior
type of paramerter article_ids is str