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

Crash after many minutes not answer for question #3

Closed
takenek opened this issue Mar 20, 2023 · 4 comments
Closed

Crash after many minutes not answer for question #3

takenek opened this issue Mar 20, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@takenek
Copy link

takenek commented Mar 20, 2023

Hey,
I am not sure this is a bot problem or maybe this is API issue but he do not answer for question and leave IRC with "timeout"
14:29 <@Taken> Zygmunt: Wydaje mi się, że premiera 14th generacji intela będzie chyba w 2023 roku?
14:31 <@Taken> Zygmunt: jesteś tam?
14:32 <@Taken> Zygmunt: która jest godzina?
14:34 -!- Zygmunt [~Zygmunt@xxx.pl] has quit [Ping timeout]
and after another few minutes he crash:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/openai/api_requestor.py", line 672, in _interpret_response_line
    data = json.loads(rbody)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/chatgpt/./chatgpt.py", line 31, in <module>
    response = openai.Completion.create(
  File "/usr/local/lib/python3.9/dist-packages/openai/api_resources/completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/usr/local/lib/python3.9/dist-packages/openai/api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/usr/local/lib/python3.9/dist-packages/openai/api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(
  File "/usr/local/lib/python3.9/dist-packages/openai/api_requestor.py", line 674, in _interpret_response_line
    raise error.APIError(
openai.error.APIError: HTTP code 502 from API (<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
)

@knrd1 knrd1 self-assigned this Mar 20, 2023
@knrd1 knrd1 added the bug Something isn't working label Mar 20, 2023
@knrd1
Copy link
Owner

knrd1 commented Mar 20, 2023

The main reason is the availability of the endpoint API. If you have a free account on OpenAI and currently their endpoints handle a lot of traffic (and this happens almost non-stop), then unfortunately the bot will return 502/500 errors.

Another issue is the error handling by the bot and this needs to be fixed, e.g. adding a "timeout" after which the bot will abandon the request and tell us to try again later, instead of quitting with "Ping Timeout".

@takenek
Copy link
Author

takenek commented Mar 20, 2023

So maybe add support for 502/500 errors? and ofc handling timeouts.

@knrd1
Copy link
Owner

knrd1 commented Mar 20, 2023

I will take care of it this week, thanks for reporting all the issues!

@knrd1
Copy link
Owner

knrd1 commented Mar 21, 2023

Solved. Error handling added for both, IRC and API events.

@knrd1 knrd1 closed this as completed Mar 21, 2023
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