run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
34.67k stars 4.9k forks source link

[Bug]: OpenWeatherMapToolSpec throws error when called for weather forecast #14744

Closed alexander-fischer closed 1 month ago

alexander-fischer commented 1 month ago

Bug Description

OpenWeatherMapToolSpec which is part of the llama-index agent tool llama-index-tools-weather throws an error whenever the agent call the function forecast_tommorrow_at_location.

The error message is: UnauthorizedError: Invalid API Key provided

This is a known issue for newer API keys for OpenWeatherMap, which don't support the old API endpoints anymore: https://github.com/csparpa/pyowm/issues/316

Version

0.10.53

Steps to Reproduce

Install the tool: llama-index-tools-weather

After installation use the following code to reproduce:

from llama_index.tools.weather import OpenWeatherMapToolSpec

print(OpenWeatherMapToolSpec("your-api-key").forecast_tommorrow_at_location("Berlin"))

Relevant Logs/Tracbacks

No response

dosubot[bot] commented 1 month ago

Hey there, @alexander-fischer! I'm here to help you with any bugs, questions, or contributions you might have. Let's squash those bugs together! 🐞

To address the UnauthorizedError: Invalid API Key provided error in the OpenWeatherMapToolSpec when calling forecast_tommorrow_at_location, ensure that you are using a valid OpenWeatherMap API key. Here is an example of how to initialize the OpenWeatherMapToolSpec correctly:

from llama_index.tools.weather import OpenWeatherMapToolSpec

# Replace 'your_valid_api_key' with your actual OpenWeatherMap API key
tool_spec = OpenWeatherMapToolSpec(key="your_valid_api_key")

print(tool_spec.forecast_tommorrow_at_location("Berlin"))

Make sure the API key you are using is correct and has the necessary permissions to access the OpenWeatherMap API. Additionally, ensure that the pyowm package is installed, as it is required by the OpenWeatherMapToolSpec class. You can install it using:

pip install pyowm

The specific version of the pyowm package compatible with the llama-index-tools-weather package in version 0.10.53 is 3.3.0 [1].

If the issue persists, it may be due to changes in the OpenWeatherMap API endpoints. The forecast_tommorrow_at_location function uses the forecast_at_place(location, "daily") endpoint, which might not be supported by newer API keys [2]. You can refer to the GitHub issue for more details on this problem.

To continue talking to Dosu, mention @dosu.

alexander-fischer commented 1 month ago

fixed here: https://github.com/run-llama/llama_index/pull/14745