acheong08 / ChatGPT

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

[Bug]: #1410

Closed iamliustar closed 1 year ago

iamliustar commented 1 year ago

Is there an existing issue for this?

What happened?

When I am using async for data in AsyncChatbot.ask() Report an error

local variable 'message' referenced before assignment

When I am using async for data in AsyncChatbot.post_ Messages() Report an error

revChatGPT.typings.Error: OpenAI: {"detail":[{"loc":["body","messages",0],"msg":"value is not a valid dict","type":"type_error.dict"}]} (code: 422)

When I am using share_conversation() There is a chance of reporting an error

OpenAI: Internal Server Error (code: 500)

Steps to reproduce the problem

1、install python 3.10 2、try to revChatGPT 6.1.2

What should have happened?

Reply message

Version where the problem happens

revChatGPT 6.1.2

What Python version are you running this with?

3.10

What is your operating system ?

Windows

Command Line Arguments

none

Console logs

Traceback (most recent call last):

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\site-packages\revChatGPT\V1.py", line 1334, in __check_response
    response.raise_for_status()
    │        └ <function Response.raise_for_status at 0x0000018F30647400>
    └ <Response [422 Unprocessable Entity]>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\site-packages\httpx\_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
          │               │                │                 └ <Response [422 Unprocessable Entity]>
          │               │                └ <Request('POST', 'https://bypass.churchless.tech/conversation')>
          │               └ "Client error '422 Unprocessable Entity' for url 'https://bypass.churchless.tech/conversation'\nFor more information check: h...
          └ <class 'httpx.HTTPStatusError'>

httpx.HTTPStatusError: Client error '422 Unprocessable Entity' for url 'https://bypass.churchless.tech/conversation'
For more information check: https://httpstatuses.com/422

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

Traceback (most recent call last):

  File "C:\Users\code\PycharmProjects\ai_bot\main.py", line 63, in <module>
    asyncio.run(main())
    │       │   └ <function main at 0x0000018F30A5AB00>
    │       └ <function run at 0x0000018F2C144940>
    └ <module 'asyncio' from 'C:\\ProgramData\\miniconda3\\envs\\ai_bot\\lib\\asyncio\\__init__.py'>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
           │    │                  └ <coroutine object main at 0x0000018F30A49230>
           │    └ <function BaseEventLoop.run_until_complete at 0x0000018F2DD95240>
           └ <_WindowsSelectorEventLoop running=True closed=False debug=False>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\asyncio\base_events.py", line 636, in run_until_complete
    self.run_forever()
    │    └ <function BaseEventLoop.run_forever at 0x0000018F2DD951B0>
    └ <_WindowsSelectorEventLoop running=True closed=False debug=False>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x0000018F2DD96CB0>
    └ <_WindowsSelectorEventLoop running=True closed=False debug=False>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\asyncio\base_events.py", line 1909, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x0000018F2DCDA050>
    └ <Handle <TaskStepMethWrapper object at 0x0000018F357C2560>()>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle <TaskStepMethWrapper object at 0x0000018F357C2560>()>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle <TaskStepMethWrapper object at 0x0000018F357C2560>()>
    │    └ <member '_context' of 'Handle' objects>
    └ <Handle <TaskStepMethWrapper object at 0x0000018F357C2560>()>

> File "C:\Users\code\PycharmProjects\ai_bot\consumer.py", line 60, in process_message
    cleaned_msg = await self.gpt(cleaned_msg)
                        │    │   └ {'self_wxid': 'wxid_k8v2y793l8ok12', 'self_nickname': 'aa🤖', 'wx_type': '1', 'at_user_list': [], 'user_wxid': 'liustar1989', ...
                        │    └ <function Consumer.gpt at 0x0000018F30A5A4D0>
                        └ <consumer.Consumer object at 0x0000018F310CA5F0>

  File "C:\Users\code\PycharmProjects\ai_bot\consumer.py", line 117, in gpt
    async for data in self.chatbot.post_messages(messages=messages, conversation_id=conversation_id, parent_id="",
                      │    │       │                      │                         └ '2643a42f-c0dc-42a9-b8da-81707ca78c38'
                      │    │       │                      └ ['测试']
                      │    │       └ <function AsyncChatbot.post_messages at 0x0000018F30A59990>
                      │    └ <revChatGPT.V1.AsyncChatbot object at 0x0000018F310CA560>
                      └ <consumer.Consumer object at 0x0000018F310CA5F0>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\site-packages\revChatGPT\V1.py", line 1061, in post_messages
    async for msg in self.__send_request(
                     └ <revChatGPT.V1.AsyncChatbot object at 0x0000018F310CA560>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\site-packages\revChatGPT\V1.py", line 893, in __send_request
    await self.__check_response(response)
          │                     └ <Response [422 Unprocessable Entity]>
          └ <revChatGPT.V1.AsyncChatbot object at 0x0000018F310CA560>

  File "C:\ProgramData\miniconda3\envs\ai_bot\lib\site-packages\revChatGPT\V1.py", line 1342, in __check_response
    raise error from ex
          └ OpenAI: {"detail":[{"loc":["body","messages",0],"msg":"value is not a valid dict","type":"type_error.dict"}]} (code: 422)

revChatGPT.typings.Error: OpenAI: {"detail":[{"loc":["body","messages",0],"msg":"value is not a valid dict","type":"type_error.dict"}]} (code: 422)

Additional information

No response

acheong08 commented 1 year ago

fixed