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

Name Handle error is not defined #50

Closed
taherafridi opened this issue May 27, 2024 · 6 comments
Closed

Name Handle error is not defined #50

taherafridi opened this issue May 27, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@taherafridi
Copy link

taherafridi commented May 27, 2024

Updates, so after a few reboots I am able to get the mic to work (not sure how).
When I call it (wake word Cosmo), and ask for anything, it always says the same feedback on the speaker and on the OLED:

Heard <the question I asked>. Something went wrong. Name "handle_error" is not defined.

Please help?
Thanks!

@judahpaul16
Copy link
Owner

Hmmm. Could you provide the traceback by running docker exec -it gpt-home tail -n 100 -f /app/src/events.log and speaking your command again? My guess is your OPENAI_API_KEY isn't exported but I'm not sure which function is not finding handle_error.

@taherafridi
Copy link
Author

taherafridi commented May 27, 2024

Hey Judah, thanks - Not sure how to post the results, it's quite long. I've put it below but please let me k now if there was a better way to share this.

👈 View Traceback

cosmo@cosmo:~ $ docker exec -it gpt-home tail -n 100 -f /app/src/events.log
    response_message = await query_task
                       ^^^^^^^^^^^^^^^^
  File "/app/src/common.py", line 319, in action_router
    return await query_openai(text, display)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/actions.py", line 269, in query_openai
    await handle_error(error_message, None, display)
          ^^^^^^^^^^^^
NameError: name 'handle_error' is not defined

INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
SUCCESS:common:Heard: "high"
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
DEBUG:openai:api_version=None data='{"model": "gpt-4", "messages": [{"role": "system", "content": "You are a helpful assistant. "}, {"role": "user", "content": "Human: high\\nAI:"}], "max_tokens": 100, "temperature": 0.7}' message='Post details'
DEBUG:urllib3.util.retry:Converted retries value: 2 -> Retry(total=2, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.openai.com:443
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/chat/completions HTTP/1.1" 404 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=None request_id=req_1da12952732c872735cda97ea55d065e response_code=404
INFO:openai:error_code=model_not_found error_message='The model `gpt-4` does not exist or you do not have access to it.' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
ERROR:common:Error on try 1: The model `gpt-4` does not exist or you do not have access to it.
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
DEBUG:openai:api_version=None data='{"model": "gpt-4", "messages": [{"role": "system", "content": "You are a helpful assistant. "}, {"role": "user", "content": "Human: high\\nAI:"}], "max_tokens": 100, "temperature": 0.7}' message='Post details'
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/chat/completions HTTP/1.1" 404 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=None request_id=req_5f903564f5c47fb9c93b45f2edf624ee response_code=404
INFO:openai:error_code=model_not_found error_message='The model `gpt-4` does not exist or you do not have access to it.' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
ERROR:common:Error on try 2: The model `gpt-4` does not exist or you do not have access to it.
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
DEBUG:openai:api_version=None data='{"model": "gpt-4", "messages": [{"role": "system", "content": "You are a helpful assistant. "}, {"role": "user", "content": "Human: high\\nAI:"}], "max_tokens": 100, "temperature": 0.7}' message='Post details'
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/chat/completions HTTP/1.1" 404 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=None request_id=req_964b65b0e7e0083f85f4fe63803754c7 response_code=404
INFO:openai:error_code=model_not_found error_message='The model `gpt-4` does not exist or you do not have access to it.' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
ERROR:common:Error on try 3: The model `gpt-4` does not exist or you do not have access to it.
CRITICAL:common:An error occurred: Something Went Wrong: name 'handle_error' is not defined
Traceback (most recent call last):
  File "/app/src/actions.py", line 236, in query_openai
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/env/lib/python3.11/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: The model `gpt-4` does not exist or you do not have access to it.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/src/app.py", line 48, in main
    response_message = await query_task
                       ^^^^^^^^^^^^^^^^
  File "/app/src/common.py", line 319, in action_router
    return await query_openai(text, display)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/actions.py", line 269, in query_openai
    await handle_error(error_message, None, display)
          ^^^^^^^^^^^^
NameError: name 'handle_error' is not defined

INFO:common:Could not understand audio, waiting for a new phrase...
INFO:common:Could not understand audio, waiting for a new phrase...
SUCCESS:common:Heard: "hi cosmo hello"
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
DEBUG:openai:api_version=None data='{"model": "gpt-4", "messages": [{"role": "system", "content": "You are a helpful assistant. "}, {"role": "user", "content": "Human: hi cosmo hello\\nAI:"}], "max_tokens": 100, "temperature": 0.7}' message='Post details'
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/chat/completions HTTP/1.1" 404 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=None request_id=req_f10d960e22945b070708329578cec487 response_code=404
INFO:openai:error_code=model_not_found error_message='The model `gpt-4` does not exist or you do not have access to it.' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
ERROR:common:Error on try 1: The model `gpt-4` does not exist or you do not have access to it.
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
DEBUG:openai:api_version=None data='{"model": "gpt-4", "messages": [{"role": "system", "content": "You are a helpful assistant. "}, {"role": "user", "content": "Human: hi cosmo hello\\nAI:"}], "max_tokens": 100, "temperature": 0.7}' message='Post details'
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/chat/completions HTTP/1.1" 404 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=None request_id=req_4390db5d924800e7adb9ca407e6c5101 response_code=404
INFO:openai:error_code=model_not_found error_message='The model `gpt-4` does not exist or you do not have access to it.' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
ERROR:common:Error on try 2: The model `gpt-4` does not exist or you do not have access to it.
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
DEBUG:openai:api_version=None data='{"model": "gpt-4", "messages": [{"role": "system", "content": "You are a helpful assistant. "}, {"role": "user", "content": "Human: hi cosmo hello\\nAI:"}], "max_tokens": 100, "temperature": 0.7}' message='Post details'
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/chat/completions HTTP/1.1" 404 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=None request_id=req_3d8802e314c116a6faf961cae62b6090 response_code=404
INFO:openai:error_code=model_not_found error_message='The model `gpt-4` does not exist or you do not have access to it.' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
ERROR:common:Error on try 3: The model `gpt-4` does not exist or you do not have access to it.
CRITICAL:common:An error occurred: Something Went Wrong: name 'handle_error' is not defined
Traceback (most recent call last):
  File "/app/src/actions.py", line 236, in query_openai
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/env/lib/python3.11/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: The model `gpt-4` does not exist or you do not have access to it.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/src/app.py", line 48, in main
    response_message = await query_task
                       ^^^^^^^^^^^^^^^^
  File "/app/src/common.py", line 319, in action_router
    return await query_openai(text, display)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/actions.py", line 269, in query_openai
    await handle_error(error_message, None, display)
          ^^^^^^^^^^^^
NameError: name 'handle_error' is not defined

cosmo@cosmo:~ $ 


Edit: In GitHub you can start typing /details and you should get some boilerplate that will create a collapsible element.

<details><summary>Details</summary>
<p>



</p>
</details> 

@judahpaul16
Copy link
Owner

This line here is where it is failing:
openai.error.InvalidRequestError: The model 'gpt-4' does not exist or you do not have access to it.
If you don't have an OpenAI premium account then you have to change the model in settings.json or in the web interface to a gpt-3 model and make sure you have funds in your account. See pricing. Seems like handle_error isn't working for some reason though. Will patch this.

judahpaul16 added a commit that referenced this issue May 27, 2024
@judahpaul16 judahpaul16 self-assigned this May 27, 2024
@judahpaul16 judahpaul16 added the bug Something isn't working label May 27, 2024
@taherafridi
Copy link
Author

As an avid ChatGPT user, I embarassingly know nothing about this! I had no idea you needed a paid account or subscription. Will check out the options and try this again. Thank you.

@judahpaul16
Copy link
Owner

No worries. You don't need a subscription necessarily but you will need at least a couple dollars for the api calls. API calls on gpt-3 are not too bad. gpt-3.5-turbo is $0.50 / 1M tokens for input (your query) and $1.50 / 1M tokens for output (the response). For English text, 1 token is approximately 4 characters or 0.75 words. As a point of reference, the collected works of Shakespeare are about 900,000 words or 1.2M tokens. You can experiment with the tokenizer tool.

@taherafridi
Copy link
Author

Thank you, Judah!
Bought some credits and it works like a charm!

Next step to integrate music and calendar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants