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

TypeError: 'dict' object is not callable when trying to test Open API tool #97

Closed
Chance-Obondo opened this issue Sep 23, 2024 · 6 comments
Assignees
Labels

Comments

@Chance-Obondo
Copy link

I am getting the mentioned error when trying to test the OpenAPI tool, not sure how to go about it.

My code:
`
import os
from haystack.dataclasses import ChatMessage
from haystack_experimental.components.tools.openapi import OpenAPITool, LLMProvider
from haystack.utils import Secret
os.environ["OPENAI_API_KEY"]=""

os.environ["SERPERDEV_API_KEY"]=""

tool = OpenAPITool(generator_api=LLMProvider.OPENAI,
spec="https://raw.githubusercontent.com/open-meteo/open-meteo/main/openapi.yml")

tool.run(messages=[ChatMessage.from_user("Weather in San Francisco, US")])`

The error:

TypeError: 'dict' object is not callable

@vblagoje
Copy link
Member

@Chance-Obondo this works for me on the main branch but it could indeed not be working on old release of haystack-experimental (v0.1.1). We are about to release a new version of experimental but until then please try with pip install git+https://github.com/deepset-ai/haystack-experimental, export OPENAI_API_KEY and then run:

from haystack.dataclasses import ChatMessage
from haystack_experimental.components.tools.openapi import OpenAPITool, LLMProvider

tool = OpenAPITool(generator_api=LLMProvider.OPENAI, spec="https://raw.githubusercontent.com/open-meteo/open-meteo/main/openapi.yml")
tool.run(messages=[ChatMessage.from_user("Weather in San Francisco, US")])

I just tried it and I get:

{'service_response': [ChatMessage(content='{"latitude": 37.763283, "longitude": -122.41286, "generationtime_ms": 0.07796287536621094, "utc_offset_seconds": 0, "timezone": "GMT", "timezone_abbreviation": "GMT", "elevation": 18.0, "current_weather_units": {"time": "iso8601", "interval": "seconds", "temperature": "\\u00b0C", "windspeed": "km/h", "winddirection": "\\u00b0", "is_day": "", "weathercode": "wmo code"}, "current_weather": {"time": "2024-09-24T09:15", "interval": 900, "temperature": 16.3, "windspeed": 6.5, "winddirection": 289, "is_day": 0, "weathercode": 0}}', role=<ChatRole.USER: 'user'>, name=None, meta={})]}

Let us know 🙏

@Chance-Obondo
Copy link
Author

Thank you! It has worked on my end, is there a way maybe the documentation on colab can be updated and also on github so that anyone else trying to experiment can know there's some updates?

@vblagoje
Copy link
Member

Thank you! It has worked on my end, is there a way maybe the documentation on colab can be updated and also on github so that anyone else trying to experiment can know there's some updates?

It would be a moot update as the new release is imminent - should be literally today. Please keep trying OpenAPITool @Chance-Obondo - your feedback is going to be immensely valuable.

@vblagoje
Copy link
Member

Recommend closing @julian-risch

@vblagoje
Copy link
Member

Thank you! It has worked on my end, is there a way maybe the documentation on colab can be updated and also on github so that anyone else trying to experiment can know there's some updates?

It would be a moot update as the new release is imminent - should be literally today. Please keep trying OpenAPITool @Chance-Obondo - your feedback is going to be immensely valuable.

Also, even though sometimes an OpenAPI spec for a certain REST endpoint is not available - you can usually generate it using its documentation and AI generation tools, making it easier to integrate REST endpoints with your Haystack-based LLM app.

@vblagoje
Copy link
Member

A new release of haystack-experimental is out. This issue is now officially fixed, closing as "Fixed"!

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

No branches or pull requests

3 participants