eliranwong / letmedoit

An advanced AI assistant that leverages the capabilities of ChatGPT API, Gemini Pro, AutoGen, and open-source LLMs, enabling it both to engage in conversations and to execute computing tasks on local devices.
https://letmedoit.ai
GNU General Public License v3.0
112 stars 24 forks source link

Error adding api key for openweathermap #48

Closed mikev-db closed 4 months ago

mikev-db commented 4 months ago

I was running into an issue adding the api key for openweathermap. I enabled developer mode to see what was going on. I then ran the API call manually in a python shell and it worked just fine. So I suspected somehow the API key that I am pasting in is not correct or not updating the config variable.

I got past this by:

  1. Shut down letmedoit
  2. Editing the config.py and manually putting in the api key.
  3. Start letmedoit

I was then able to ask about the weather and I can see that the api is being called (with developer mode enabled, etc).

I suspect the .openweathermapapi command is not working properly.

>>> .openweathermapapi                                                          
To set up OpenWeatherMap API Key, read:
https://github.com/eliranwong/letmedoit/wiki/OpenWeatherMap-API-Setup

Enter your OpenWeatherMap API Key:

>>> ********************************                                            
Traceback (most recent call last):
  File "/Users/me/letmedoit/lib/python3.11/site-packages/letmedoit/utils/shared_utils.py", line 552, in getWeather
    weather_condition = data["weather"][0]["description"]
                        ~~~~^^^^^^^^^^^
KeyError: 'weather'

Invalid API key entered!
eliranwong commented 4 months ago

Thanks. I will take a look into it. On my side, it seems everything fine.

bty, you can edit "config.py" directly while you are using LetMeDoIt AI, just enter ".editconfigs" in LetMeDoIt AI prompt. After you finish editing, press "ctrl+s" to save and "ctrl+q" to exit the text editor

eliranwong commented 4 months ago

I haven't managed to duplicate the issue, even I tried to delete my OpenWeatherMap api and re-entered it again.

Entering the OpenWeatherMap API Key looks fine for me. But I take note of this issue in case others users encounter issues that are similar to this one.

I close this issue first, will re-open if someone duplicates it. Many thanks again.

mikev-db commented 4 months ago

Thanks for the tips.

So odd thing, I did the .editconfigs. I removed the api key, and tried asking about the weather. It still used the api key I removed (I can see it in the developer output). I checked the config.py and indeed the api is gone.

So I restarted letmedoit. It immediately asked me for the key. I pasted it in and it worked. I can't explain why it works as I had done the exact same copy/paste steps repeatedly before without success. I also know my previous api copies were correct because I tested the api manually using the same paste just to be sure.

Anyhow, sounds good to close, happy to help chase it down if anyone else runs into it.