iuiaoin / wechat-gptbot

A wechat robot based on ChatGPT with no risk, very stable! 🚀
MIT License
595 stars 116 forks source link

正常运行就是gpt不回复似乎是URL的问题,捣鼓了一下午也没弄出来 #75

Closed Jerry-155 closed 1 year ago

Jerry-155 commented 1 year ago

Search for answers in existing issues

Python version

python 3.10

Issue description

[INFO][2023-08-02 18:10:21][wechat.py:90] - message received: Message(room_id=No ne, sender_id=wxid_lb4k1t5gx3e722, sender_name=张昊, receiver_id=wxid_dv4222eb61 mi22, receiver_name=Jerry, content=bot 你好, type=1, is_group=False, create_time =2023-08-02 18:10:21, is_at=False) [INFO][2023-08-02 18:10:22][chatgpt.py:26] - [ChatGPTBot] Query=你好 [ERROR][2023-08-02 18:10:27][chatgpt.py:82] - [ChatGPTBot] Exception: Invalid UR L (POST /chat/completions) Traceback (most recent call last): File "E:\test1\wechat\bot\chatgpt.py", line 53, in reply_text response = openai.ChatCompletion.create( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site- packages\openai\api_resources\chat_completion.py", line 25, in create return super().create(*args, **kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site- packages\openai\api_resources\abstract\engine_apiresource.py", line 153, in cre ate response, , api_key = requestor.request( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site- packages\openai\api_requestor.py", line 298, in request resp, got_stream = self._interpret_response(result, stream) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site- packages\openai\api_requestor.py", line 700, in _interpret_response self._interpret_response_line( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site- packages\openai\api_requestor.py", line 763, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: Invalid URL (POST /chat/completions)

Repro steps

No response

Relevant log output

No response

iuiaoin commented 1 year ago

@Jerry-155 The error message you're getting states that an InvalidRequestError occurred due to an "Invalid URL" for the POST request /chat/completions.

There could be a number of reasons why this might be happening. Here are a few possibilities:

  1. Outdated OpenAI API version: The OpenAI API version you're using might be outdated. They may have changed the endpoint you're using, in this case /chat/completions. Make sure to install the right version of the OpenAI python package in requirements.txt:
    pip install -r requirements.txt
  2. API Key: The API key might not have been set correctly. Make sure that the OpenAI API key is being set correctly in your code.
  3. Endpoint URL: The error is specifically saying that the URL of the endpoint /chat/completions is invalid. You need to make sure that the endpoint URL is correctly set. Typically, you shouldn't need to set this yourself, the OpenAI python package should handle this. But if you're trying to manually set the endpoint URL, make sure it is correct.