Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenApi 3.1.0 ArrayType is recognized as StringType unexpectly #5720

Open
5 tasks done
forrestsocool opened this issue Jun 28, 2024 · 2 comments
Open
5 tasks done

OpenApi 3.1.0 ArrayType is recognized as StringType unexpectly #5720

forrestsocool opened this issue Jun 28, 2024 · 2 comments
Assignees
Labels
💪 enhancement New feature or request

Comments

@forrestsocool
Copy link

forrestsocool commented Jun 28, 2024

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

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

@dosubot dosubot bot added the 🐞 bug Something isn't working label Jun 28, 2024
Copy link

dosubot bot commented Jun 28, 2024

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.

@laipz8200
Copy link
Collaborator

Our tool currently doesn't support array-type parameters, we might add this feature in the future.

@laipz8200 laipz8200 added 💪 enhancement New feature or request and removed 🐞 bug Something isn't working labels Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants