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

Cannot import openapi.json as external tool #12696

Closed
5 tasks done
yjc980121 opened this issue Jan 13, 2025 · 3 comments
Closed
5 tasks done

Cannot import openapi.json as external tool #12696

yjc980121 opened this issue Jan 13, 2025 · 3 comments
Labels
🐞 bug Something isn't working 🔨 feat:tools Tools for agent, function call related stuff.

Comments

@yjc980121
Copy link
Contributor

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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Cannot import openapi.json as external tool in v0.15.0, works fine in v0.11.0

the service is fastapi auto generate openapi.json, stanard

2025-01-13 10:02:22,077.077 INFO [Thread-3464 (_generate_worker)] [_client.py:1038] - HTTP Request: POST http://sandbox:8194/v1/sandbox/run "HTTP/1.1 200 OK"
2025-01-13 10:02:43,685.685 INFO [ThreadPoolExecutor-512_0] [_client.py:1038] - HTTP Request: POST http://sandbox:8194/v1/sandbox/run "HTTP/1.1 200 OK"
2025-01-13 11:25:54,958.958 INFO [Dummy-3479] [_client.py:1038] - HTTP Request: GET http://10.101.3.59:8202/openapi.json "HTTP/1.1 200 OK"
2025-01-13 11:25:54,961.961 ERROR [Dummy-3479] [api_tools_manage_service.py:202] - parse api schema error
Traceback (most recent call last):
File "/app/api/services/tools/api_tools_manage_service.py", line 39, in parser_api_schema
tool_bundles, schema_type = ApiBasedToolSchemaParser.auto_parse_to_tool_bundle(schema, warning=warnings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/tools/utils/parser.py", line 341, in auto_parse_to_tool_bundle
openapi = ApiBasedToolSchemaParser.parse_openapi_to_tool_bundle(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/tools/utils/parser.py", line 115, in parse_openapi_to_tool_bundle
en_US=parameter.get("description", ""), zh_Hans=parameter.get("description", "")
^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 856, in getattr
raise AttributeError(f'{type(self).name!r} object has no attribute {item!r}')
AttributeError: 'ToolParameter' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/api/services/tools/api_tools_manage_service.py", line 41, in parser_api_schema
raise ValueError(f"invalid schema: {str(e)}")
ValueError: invalid schema: 'ToolParameter' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/api/services/tools/api_tools_manage_service.py", line 200, in get_api_tool_provider_remote_schema
ApiToolManageService.parser_api_schema(schema)
File "/app/api/services/tools/api_tools_manage_service.py", line 84, in parser_api_schema
raise ValueError(f"invalid schema: {str(e)}")
ValueError: invalid schema: invalid schema: 'ToolParameter' object has no attribute 'get'

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

@dosubot dosubot bot added 🐞 bug Something isn't working 🔨 feat:tools Tools for agent, function call related stuff. labels Jan 13, 2025
Copy link

dosubot bot commented Jan 13, 2025

A similar issue has been discussed in the Dify repository, specifically in the thread titled "parse_openapi_to_tool_bundle not support all type (array/object)" which is currently unsolved [1].

The error you're encountering seems to be related to the ToolParameter object not having a get attribute. This might be due to changes in how the ToolParameter class is expected to be used in version 0.15.0 compared to 0.11.0. The parse_openapi_to_tool_bundle function is likely trying to access a parameter attribute incorrectly.

To address this issue, you might want to check the ToolParameter class definition in the current version to ensure that the attributes are being accessed correctly. The ToolParameter class has specific attributes like name, label, human_description, etc., but it does not have a get method or attribute [2][3].

Reviewing the changes in the parse_openapi_to_tool_bundle function between versions 0.11.0 and 0.15.0 might also provide insights into what might be causing this issue, although specific changes were not found in the available data.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@crazywoola
Copy link
Member

Fixed in 0.15.1 fix: Parsing OpenAPI spec for external tools (#12518) (#12530)

@xujingbao
Copy link

Fixed in 0.15.1 fix: Parsing OpenAPI spec for external tools (#12518) (#12530)

some error, updated to 0.15.1, worked! good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🔨 feat:tools Tools for agent, function call related stuff.
Projects
None yet
Development

No branches or pull requests

3 participants