Zai-Kun / reverse-engineered-chatgpt

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

'NoneType' object is not subscriptable. #44

Closed 1Wayne1 closed 4 months ago

1Wayne1 commented 4 months ago

I try your 'async_basic_example' and I got this error:

Traceback (most recent call last):
  File "E:\py_project\reverse-engineered-chatgpt-main\examples\async_basic_example.py", line 34, in <module>
    asyncio.run(main())
  File "d:\ProgramData\Anaconda3\envs\django\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "d:\ProgramData\Anaconda3\envs\django\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "E:\py_project\reverse-engineered-chatgpt-main\examples\async_basic_example.py", line 28, in main
    async for message_chunk in conversation.chat(prompt):
  File "E:\py_project\reverse-engineered-chatgpt-main\re_gpt\async_chatgpt.py", line 137, 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."}.

I used a proxy like this async with AsyncChatGPT(proxies={"https": "http://localhost:7890"}, session_token=session_token) as chatgpt:

Barrierml commented 4 months ago

Check

You can try to save yourself first

  1. Check your proxy is work
    curl -x http://localhost:7890 https://chat.openai.com/
  2. Check your re_gpt version is newest, you can install use
    pip install git+https://github.com/Zai-Kun/reverse-engineered-chatgpt
  3. Your account is chatgpt-plus or not, Plus users are having problems right now
  4. You can directly use no-sign mode right now for test
    
    from re_gpt import AsyncChatGPT
    import asyncio

async def main(): async with AsyncChatGPT() as chatgpt: conversation = chatgpt.create_new_conversation() async for message_chunk in conversation.chat("hello"): print(message_chunk["content"], flush=True, end="")

if name == "main": asyncio.run(main())



## Finally
If every action does not work, you can provide your environment (Python version, Test Code, And VPN region)
1Wayne1 commented 4 months ago

Check

You can try to save yourself first

  1. Check your proxy is work
curl -x http://localhost:7890 https://chat.openai.com/
  1. Check your re_gpt version is newest, you can install use
pip install git+https://github.com/Zai-Kun/reverse-engineered-chatgpt
  1. Your account is chatgpt-plus or not, Plus users are having problems right now
  2. You can directly use no-sign mode right now for test
from re_gpt import AsyncChatGPT
import asyncio

async def main():
    async with AsyncChatGPT() as chatgpt:
        conversation = chatgpt.create_new_conversation()
        async for message_chunk in conversation.chat("hello"):
            print(message_chunk["content"], flush=True, end="")

if __name__ == "__main__":
    asyncio.run(main())

Finally

If every action does not work, you can provide your environment (Python version, Test Code, And VPN region)

I updated the newest re-gpt and it worked. Thanks