acheong08 / ChatGPT

Reverse engineered ChatGPT API
GNU General Public License v2.0
28.04k stars 4.48k forks source link

[BUG] 429 on returning to previous conversation #418

Closed Jamminroot closed 1 year ago

Jamminroot commented 1 year ago

Describe the bug Trying to continue previous conversation returns 429 upon request: error: {"detail":"Something went wrong, please try reloading the conversation."}! Refreshing session...

To Reproduce Steps to reproduce the behavior:

  1. Use ask() with specific conv_id(A)
  2. Use ask() again (in my case conv_id was None), say it is conv_id(B)
  3. Try to use ask() again with conv_id(A)
  4. See error

Expected behavior Ability to continue old conversation

Output Sorry for not providing logs as per instruction (couldn't really figure the --debug flag, sry); Error is throwin in ChatGPT.py:121

        if response.status_code != 200:
            print(response.text)
            self.refresh_session()

            raise Exception(f"Wrong response code: {response.status_code} error: {response.text}! Refreshing session...")
INFO:werkzeug:Press CTRL+C to quit
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8979cd8a60>: Failed to establish a new connection: [Errno 111] Connection refused')': /session/afae5715998cf3d081d492b69a4814bf/se/log
[2023-01-06 04:14:49,106] WAR connectionpo:812  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8979cd8a60>: Failed to establish a new connection: [Errno 111] Connection refused')': /session/afae5715998cf3d081d492b69a4814bf/se/log
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8979cd9cc0>: Failed to establish a new connection: [Errno 111] Connection refused')': /session/afae5715998cf3d081d492b69a4814bf/se/log
[2023-01-06 04:14:49,108] WAR connectionpo:812  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8979cd9cc0>: Failed to establish a new connection: [Errno 111] Connection refused')': /session/afae5715998cf3d081d492b69a4814bf/se/log
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8979cd9f60>: Failed to establish a new connection: [Errno 111] Connection refused')': /session/afae5715998cf3d081d492b69a4814bf/se/log
[2023-01-06 04:14:49,109] WAR connectionpo:812  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8979cd9f60>: Failed to establish a new connection: [Errno 111] Connection refused')': /session/afae5715998cf3d081d492b69a4814bf/se/log
INFO:root:Request received <Request 'http://127.0.0.1:5001/gpt' [POST]>
INFO:root:Processing input fg for conversation
INFO:chatgpt_api:Input handling, conv_id=, parent_id=, question=fg
INFO:chatgpt_api:Getting a bot  None
INFO:chatgpt_api:Getting first free bot in queue
INFO:chatgpt_api:Using chatbot: chuk
INFO:chatgpt_api:Getting response from ChatGPT
INFO:chatgpt_api:New conversation, input: fg
INFO:chatgpt_utils:Resetting conversation for bot [chuk]
INFO:chatgpt_api:Asking ChatGPT
INFO:chatgpt_api:Got result from ChatGPT
INFO:chatgpt_api:No exceptions happened in input processing, conv_id=ba9b0964-8f3b-4009-a131-d36383d350b8, res={'message': 'I\'
INFO:chatgpt_api:Returning valid response I'm sorry, I don
INFO:chatgpt_api:Finalizing input processing
INFO:chatgpt_api:Releasing bot chuk
INFO:chatgpt_api:Queue length: 0
INFO:chatgpt_api:Bot released chuk
INFO:chatgpt_api:Saving bot configs - dump required
INFO:chatgpt_api:Saving bot configs
INFO:root:Endpoint handling complete. Code: 0
INFO:werkzeug:127.0.0.1 - - [06/Jan/2023 04:14:56] "POST /gpt HTTP/1.1" 200 -
INFO:root:Request received <Request 'http://127.0.0.1:5001/gpt' [POST]>
INFO:root:Processing input l; for conversation ba9b0964-8f3b-4009-a131-d36383d350b8
INFO:chatgpt_api:Input handling, conv_id=ba9b0964-8f3b-4009-a131-d36383d350b8, parent_id=4ce11461-ddb6-400f-b290-a38d883b8da0, question=l;
INFO:chatgpt_api:Getting a bot ba9b0964-8f3b-4009-a131-d36383d350b8 None
INFO:chatgpt_api:conv_id is not empty, len=36
INFO:chatgpt_api:Total bots in queue: 1
INFO:chatgpt_api:Looking up bot for conv_id ba9b0964-8f3b-4009-a131-d36383d350b8
INFO:chatgpt_api:Found a chatbot by conv_id ba9b0964-8f3b-4009-a131-d36383d350b8
INFO:chatgpt_api:Using chatbot: chuk
INFO:chatgpt_api:Getting response from ChatGPT
INFO:chatgpt_api:Continue conversation ba9b0964-8f3b-4009-a131-d36383d350b8, input: l;
INFO:chatgpt_api:No exceptions happened in input processing, conv_id=ba9b0964-8f3b-4009-a131-d36383d350b8, res={'message': 'I\'
INFO:chatgpt_api:Returning valid response I'm sorry, I don
INFO:chatgpt_api:Finalizing input processing
INFO:chatgpt_api:Releasing bot chuk
INFO:chatgpt_api:Queue length: 0
INFO:chatgpt_api:Bot released chuk
INFO:root:Endpoint handling complete. Code: 0
INFO:werkzeug:127.0.0.1 - - [06/Jan/2023 04:15:05] "POST /gpt HTTP/1.1" 200 -
INFO:root:Request received <Request 'http://127.0.0.1:5001/gpt' [POST]>
INFO:root:Processing input kj for conversation 60d04701-66ef-4e99-bf06-d7838bb27c3b
INFO:chatgpt_api:Input handling, conv_id=60d04701-66ef-4e99-bf06-d7838bb27c3b, parent_id=01058fbe-b010-42a6-98bb-73cb13481543, question=kj
INFO:chatgpt_api:Getting a bot 60d04701-66ef-4e99-bf06-d7838bb27c3b None
INFO:chatgpt_api:conv_id is not empty, len=36
INFO:chatgpt_api:Total bots in queue: 1
INFO:chatgpt_api:Looking up bot for conv_id 60d04701-66ef-4e99-bf06-d7838bb27c3b
INFO:chatgpt_api:Found a chatbot by conv_id 60d04701-66ef-4e99-bf06-d7838bb27c3b
INFO:chatgpt_api:Using chatbot: chuk
INFO:chatgpt_api:Getting response from ChatGPT
INFO:chatgpt_api:Continue conversation 60d04701-66ef-4e99-bf06-d7838bb27c3b, input: kj
{"detail":"Something went wrong, please try reloading the conversation."}
ERROR:chatgpt_api:Exception while handling a request: Wrong response code: 429 error: {"detail":"Something went wrong, please try reloading the conversation."}! Refreshing session...
[2023-01-06 04:15:11,400] ERR chatgpt_api.:141  Exception while handling a request: Wrong response code: 429 error: {"detail":"Something went wrong, please try reloading the conversation."}! Refreshing session...
INFO:chatgpt_api:Finalizing input processing
INFO:chatgpt_api:Releasing bot chuk
INFO:chatgpt_api:Queue length: 0
INFO:chatgpt_api:Bot released chuk
INFO:root:Endpoint handling complete. Code: 500
INFO:werkzeug:127.0.0.1 - - [06/Jan/2023 04:15:11] "POST /gpt HTTP/1.1" 500 -

Environment (please complete the following information):

Please update your packages before reporting! pip3 install --upgrade revChatGPT

Name: revChatGPT
Version: 0.0.48.3
Summary: ChatGPT is a reverse engineering of OpenAI's ChatGPT API
Home-page: https://github.com/acheong08/ChatGPT
Author: Antonio Cheong
Author-email: acheong@student.dalat.org
License: GNU General Public License v2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: 2captcha-python, selenium, tls-client-for-chatGPT, undetected-chromedriver
Required-by:

Additional context As an extra - If I try to continue conv_id(A) right after a restart, it works just fine

DiamondDemon669 commented 1 year ago

Ok, I think I found the problem.

ChatGPT uses a message history similar to the blockchain (dont you dare talk about crypto) and when you switch to a different conversation, you also need to change the parent ID to match the last message ID in the chain

Imma try solving it without creating anymore lag

Jamminroot commented 1 year ago

On a second thought - addressing that might not be a good call; Rather a requirement when using the library API. Maybe it's better to hint that parent_id should be a "child" of certain "conv_id", and they both should be valid values?