KeyError: 'choices'
Closed this issue · 5 comments
I seem to get KeyError: 'choices' a lot
Hi @darthludious Can you provide a log or an example of how to reproduce this? It might be related to the LLM model inference output.
Same error here...
Running assistant...
Prompt: edge browser go to YouTube and browse Tesla videos
Called from: assistant
Listening...
Listening...
Listening...
AI selected application: Microsoft Edge
AI Analyzing: Microsoft Text Input Application
Generating a test case with the assistant. Image visioning started. Analyzing the application Microsoft Text Input Application for context.
Exception in thread Thread-5 (run_assistant):
Traceback (most recent call last):
File "C:\Users<name>\AppData\Local\miniconda3\envs\llm2\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "C:\Users<name>\AppData\Local\miniconda3\envs\llm2\Lib\threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "C:\Code\pywinassistant\pywinassistant-main\core\assistant.py", line 164, in run_assistant
assistant(assistant_goal=action, called_from="assistant")
File "C:\Code\pywinassistant\pywinassistant-main\core\driver.py", line 253, in assistant
assistant_goal = imaging(window_title=app_name, additional_context=additional_context, screenshot_size='Full screen')['choices'][0]['message']['content']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'choices'
AI selected application: Spotify
AI Analyzing: Spotify
Generating a test case with the assistant. Image visioning started. Analyzing the application Spotify for context.
Listening...
Exception in thread Thread-10 (run_assistant):
Traceback (most recent call last):
File "C:\Users\Goose\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1052, in _bootstrap_inner
self.run()
File "C:\Users\Goose\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 989, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Goose\Desktop\jarvis\core\assistant.py", line 164, in run_assistant
assistant(assistant_goal=action, called_from="assistant")
File "C:\Users\Goose\Desktop\jarvis\core\driver.py", line 253, in assistant
assistant_goal = imaging(window_title=app_name, additional_context=additional_context, screenshot_size='Full screen')['choices'][0]['message']['content']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'choices'
Listening...
The fix is to add the API keys correctly:
add your API Key in /core/core_api.py -> line 3: client = OpenAI(api_key='insert_your_api_key_here')
add your API Key in /core/core_imaging.py -> line 12: api_key = 'insert_your_api_key_here'
For more information, you could check the Readme.md for the complete usage and installation guide.
Special thanks to @NadavIs56 !
Ahhhhhh the core_imaging.py - missed that one thank you