ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

[BUG] Not a JSON response

Open chrisyy2003 opened this issue 3 years ago • 9 comments

Describe the bug A clear and concise description of what the bug is.

sometime it will return Not a JSON response error, and i can't repeat this error because happens very randomly,do you ever had this problem before

chrisyy2003 avatar Dec 11 '22 16:12 chrisyy2003

Yes. It is an issue with OpenAI's api being overloaded.

acheong08 avatar Dec 11 '22 16:12 acheong08

@acheong08 but that gets fixed when i manually change the session token. Here is the stack trace:

  File "/home/mattf/projects/test/chatgpt.py", line 29, in query
    return self.client.get_chat_response(message)['message']
  File "/home/mattf/projects/test/venv/lib/python3.8/site-packages/revChatGPT/revChatGPT.py", line 233, in get_chat_response
    return self.__get_chat_text(data)
  File "/home/mattf/projects/test/venv/lib/python3.8/site-packages/revChatGPT/revChatGPT.py", line 192, in __get_chat_text
    raise Exception("Not a JSON response") from exc2
Exception: Not a JSON response

Isn't it a matter of just refreshing the session on that case as well?

Update: refreshing on that error doesn't work. I have to really manually get the new session cookie.

matheusfillipe avatar Dec 11 '22 17:12 matheusfillipe

It seems to be a problem, after I got this error, I created a new AsyncChatbot() instance and it received it normally Although it breaks again shortly after, I'm not sure if I should refresh_session or login, both functions are always reporting errors

It seems that, nowadays, this error occurs after sending 2 messages

zwa73 avatar Dec 11 '22 20:12 zwa73

Creating new AsyncChatbot() instances does solve this problem reliably However, the error occurs again after 2 messages Tried refresh and login to no avail Resetting the conversation_id doesn't work either Does anyone know what else gets refreshed in a new instance?

zwa73 avatar Dec 11 '22 20:12 zwa73

Well, now that new instances can't be created either, this is a really hard problem to verify

     self.main_chat = self.main_chat = Chatbot(config, conversation_id=None)
  File "E:\Python 3.9\lib\site-packages\revChatGPT\revChatGPT.py", line 89, in __init__
    self.refresh_session()
  File "E:\Python 3.9\lib\site-packages\revChatGPT\revChatGPT.py", line 329, in refresh_session
    raise exc
  File "E:\Python 3.9\lib\site-packages\revChatGPT\revChatGPT.py", line 326, in refresh_session
    self.login(self.config["email"], self.config["password"])
  File "E:\Python 3.9\lib\site-packages\revChatGPT\revChatGPT.py", line 362, in login
    raise exc
  File "E:\Python 3.9\lib\site-packages\revChatGPT\revChatGPT.py", line 355, in login
    auth.begin()
  File "E:\Python 3.9\lib\site-packages\OpenAIAuth\OpenAIAuth.py", line 95, in begin
    raise Exception("API error")
Exception: API error

zwa73 avatar Dec 11 '22 22:12 zwa73

It seems like OpenAI have enabled Cloudflare's attack mode:

Debugger enabled on OpenAIAuth
Beginning auth process
Error in part one
Response: <!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">

KaiserBloo avatar Dec 11 '22 22:12 KaiserBloo

Cloudflare is much harder to bypass. Will take some time as I work on it

acheong08 avatar Dec 12 '22 00:12 acheong08

@acheong08 maybe this could help you https://github.com/lwthiker/curl-impersonate

matheusfillipe avatar Dec 12 '22 00:12 matheusfillipe

@acheong08 maybe this could help you lwthiker/curl-impersonate

Cloudflare now shows up on normal clients as well. It won't do much

acheong08 avatar Dec 12 '22 00:12 acheong08