iuiaoin / wechat-gptbot

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

[Bug]: AttributeError: 'str' object has no attribute 'get' #68

Closed JosephLee03 closed 1 year ago

JosephLee03 commented 1 year ago

Search for answers in existing issues

Python version

python 3.8

Issue description

已经尝试在chatgpt.py中 print(type(conf())),结果显示确实为“dict”而非“str” object。新手小白,不知道如何解决bug,求解答,谢谢!

Repro steps

No response

Relevant log output

[INFO][2023-07-28 00:29:58][manager.py:42] - Checking plugins...
[INFO][2023-07-28 00:29:58][manager.py:54] - All plugins are installed
[INFO][2023-07-28 00:29:58][api.py:34] -
                wechat login info:

                nickName: test
                account: **
                wechatId: **
                startTime: 2023-07-28 00:29:58

[INFO][2023-07-28 00:29:58][wechat.py:40] - App startup successfully!
[INFO][2023-07-28 00:29:58][wechat.py:178] - [Websocket] connected
[INFO][2023-07-28 00:30:14][wechat.py:90] - message received: Message(room_id=None, sender_id=wxid_mrpa2pahtcbj22, sender_name=**, receiver_id=wxid_gkz7sggq422229, receiver_name=test, content=如何学习Python, type=1, is_group=False, create_time=2023-07-28 0
0:30:14, is_at=False)
[INFO][2023-07-28 00:30:14][chatgpt.py:26] - [ChatGPTBot] Query=如何学习Python
[ERROR][2023-07-28 00:30:16][chatgpt.py:81] - [ChatGPTBot] Exception: 'str' object has no attribute 'get'
Traceback (most recent call last):
  File "D:\Desktop\wechat-gptbot\bot\chatgpt.py", line 53, in reply_text
    response = openai.ChatCompletion.create(
  File "D:\Anaconda\anaconda3\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "D:\Anaconda\anaconda3\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "D:\Anaconda\anaconda3\lib\site-packages\openai\api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "D:\Anaconda\anaconda3\lib\site-packages\openai\api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "D:\Anaconda\anaconda3\lib\site-packages\openai\api_requestor.py", line 763, in _interpret_response_line
    raise self.handle_error_response(
  File "D:\Anaconda\anaconda3\lib\site-packages\openai\api_requestor.py", line 418, in handle_error_response
    error_code=error_data.get("code"),
AttributeError: 'str' object has no attribute 'get'
iuiaoin commented 1 year ago

在拉了最新的代码之后, 有执行一下pip install -r requirements.txt吗?

JosephLee03 commented 1 year ago

重装了一遍requirements.txt及依赖库,最后排除得出是第三方接口域名的问题。问题已解决,谢谢!