Zai-Kun / reverse-engineered-chatgpt

Unofficial reverse-engineered ChatGPT API in Python
Apache License 2.0
240 stars 31 forks source link

UnexpectedResponseError #27

Open iamsky13 opened 6 months ago

iamsky13 commented 6 months ago

I started playing with basic examples and failed to run it

Exception has occurred: UnexpectedResponseError
An unexpected error occurred. Error message: 'NoneType' object is not subscriptable.
This is what the server returned: {"wss_url":"wss://chatgpt-async-webps-prod-eastus-23.webpubsub.azure.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1lYXN0dXMtMjMud2VicHVic3ViLmF6dXJlLmNvbS9jbGllbnQvaHVicy9jb252ZXJzYXRpb25zIiwiaWF0IjoxNzA3MDE1MDU4LCJleHAiOjE3MDcwMTg2NTgsInN1YiI6InVzZXItajE2a2RQSDFhS3ZQTWlnRjNzWGJlcTZpIn0.3_Gnx9QoHBqwY6v44jcuUiiPczggQrLIyt2om001GQI","expires_at":"2024-02-04T03:50:58.264613+00:00","conversation_id":"cb1ff950-ce37-47e6-a877-fc43f1a79514","response_id":"84ff9bef7c174d1e-BOS"}.
  File "D:\reverse-engineered-chatgpt-3.0.1\reverse-engineered-chatgpt-3.0.1\examples\async_basic_example.py", line 28, in main
    async for message_chunk in conversation.chat(prompt):
  File "D:\reverse-engineered-chatgpt-3.0.1\reverse-engineered-chatgpt-3.0.1\examples\async_basic_example.py", line 34, in <module>
    asyncio.run(main())
re_gpt.errors.UnexpectedResponseError: An unexpected error occurred. Error message: 'NoneType' object is not subscriptable.
This is what the server returned: {"wss_url":"wss://chatgpt-async-webps-prod-eastus-23.webpubsub.azure.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1lYXN0dXMtMjMud2VicHVic3ViLmF6dXJlLmNvbS9jbGllbnQvaHVicy9jb252ZXJzYXRpb25zIiwiaWF0IjoxNzA3MDE1MDU4LCJleHAiOjE3MDcwMTg2NTgsInN1YiI6InVzZXItajE2a2RQSDFhS3ZQTWlnRjNzWGJlcTZpIn0.3_Gnx9QoHBqwY6v44jcuUiiPczggQrLIyt2om001GQI","expires_at":"2024-02-04T03:50:58.264613+00:00","conversation_id":"cb1ff950-ce37-47e6-a877-fc43f1a79514","response_id":"84ff9bef7c174d1e-BOS"}.

image

waheedullahkhan001 commented 6 months ago

Same. I am using async variant inside discord bot. It was working fine yesterday.

gerkim62 commented 6 months ago

This issue is that chatgpt has changed how they handle messages. they are using wss instead. someone can please update this library so it can handle wss web scokets. my python skills are limited i would have done it.

LastTherapy commented 6 months ago

Same promlem

Zai-Kun commented 5 months ago

This issue is that chatgpt has changed how they handle messages. they are using wss instead. someone can please update this library so it can handle wss web scokets. my python skills are limited i would have done it.

As you said, ChatGPT changed their backend infrastructure, now they are using websockets. But it seems like this change has only been made in some regions because for some people the re_gpt is still working (including me). And after monitoring ChatGPT's network traffic in my browser, no ebsocket connection was made, it's using the method it was using before. Thus, I can't debug this until the new changes have been applied in my region too.

gerkim62 commented 5 months ago

still not working

LuciferM242 commented 5 months ago

not working for me eather

waheedullahkhan001 commented 5 months ago

FYI

After I saw the latest PR merged ( #33 ), I tried pulling the source code and installing using setup install but still:

Traceback (most recent call last):
  File "C:\Users\Admin\PycharmProjects\playground\main.py", line 27, in <module>
    asyncio.run(main())
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Admin\PycharmProjects\playground\main.py", line 22, in main
    async for message in conversation.chat(prompt):
  File "C:\Users\Admin\PycharmProjects\playground\.venv\Lib\site-packages\re_gpt-3.0.2-py3.12.egg\re_gpt\async_chatgpt.py", line 142, in chat
    raise UnexpectedResponseError(error, server_response)
re_gpt.errors.UnexpectedResponseError: An unexpected error occurred. Error message: 'NoneType' object is not subscriptable.
This is what the server returned: {"detail":"There was a problem with your chat request. Please use a different browser or try again later."}.
Barrierml commented 5 months ago

FYI

After I saw the latest PR merged ( #33 ), I tried pulling the source code and installing using setup install but still:

Traceback (most recent call last):
  File "C:\Users\Admin\PycharmProjects\playground\main.py", line 27, in <module>
    asyncio.run(main())
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Admin\PycharmProjects\playground\main.py", line 22, in main
    async for message in conversation.chat(prompt):
  File "C:\Users\Admin\PycharmProjects\playground\.venv\Lib\site-packages\re_gpt-3.0.2-py3.12.egg\re_gpt\async_chatgpt.py", line 142, in chat
    raise UnexpectedResponseError(error, server_response)
re_gpt.errors.UnexpectedResponseError: An unexpected error occurred. Error message: 'NoneType' object is not subscriptable.
This is what the server returned: {"detail":"There was a problem with your chat request. Please use a different browser or try again later."}.

PR alreay pushed, wait approved, you can use it at https://github.com/Barrierml/reverse-engineered-chatgpt

MahdeenSky commented 4 months ago

still same problem

Barrierml commented 4 months ago

still same problem

Can you provide a return value for this API use your chatgpt account? https://chat.openai.com/backend-api/sentinel/chat-requirements

MahdeenSky commented 4 months ago

still same problem

Can you provide a return value for this API use your chatgpt account? https://chat.openai.com/backend-api/sentinel/chat-requirements

detail" : "Method Not Allowed"

gerkim62 commented 4 months ago

still same problem

Can you provide a return value for this API use your chatgpt account? https://chat.openai.com/backend-api/sentinel/chat-requirements

using get or post?

MahdeenSky commented 4 months ago

still same problem

Can you provide a return value for this API use your chatgpt account? https://chat.openai.com/backend-api/sentinel/chat-requirements

using get or post?

get

waheedullahkhan001 commented 4 months ago

I found the request in network tab when loading ChatGPT:

{ "persona": "chatgpt-freeaccount", "arkose": { "required": false, "dx": null }, "turnstile": { "required": false }, "token": "MY TOKEN" }

phamxtien commented 4 months ago

I use pip install -I curl_cffi==0.6.0b7 and it runs ok and if still error try to fix sync_chatgpt.py image

image