chatgpt-on-wechat
chatgpt-on-wechat copied to clipboard
当Channel为terminal时执行异常
前置确认
- [X] 我确认我运行的是最新版本的代码,并且安装了所需的依赖,在FAQS中也未找到类似问题。
⚠️ 搜索issues中是否已存在类似问题
- [X] 我已经搜索过issues和disscussions,没有跟我遇到的问题相关的issue
操作系统类型?
MacOS
运行的python版本是?
other
使用的chatgpt-on-wechat版本是?
Master (branch)
运行的channel
类型是?
wx(个人微信, itchat)
复现步骤 🕹
当设置channel为terminal时,执行错误
问题描述 😯
错误内容:
[ERROR][2023-12-20 14:29:35][chat_channel.py:300] - Worker return exception: 'isgroup'
修改代码:channel/chat_channel.py
:
在if context.get("isgroup", False)
判断没有isgroup
时增加该key
可以解决:
if context.get("isgroup", False):
...
else:
context["session_id"] = cmsg.other_user_id
context["receiver"] = cmsg.other_user_id
context["isgroup"] = False
终端日志 📒
Debug模式下,日志如下:
Please input your question:
User:hi
[ERROR][2023-12-20 14:29:35][chat_channel.py:300] - Worker return exception: 'isgroup'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/channel/chat_channel.py", line 169, in _handle
reply = self._generate_reply(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/channel/chat_channel.py", line 179, in _generate_reply
e_context = PluginManager().emit_event(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/plugins/plugin_manager.py", line 189, in emit_event
instance.handlers[e_context.event](e_context, *args, **kwargs)
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/plugins/linkai/linkai.py", line 112, in on_handle_context
if context.type == ContextType.TEXT and _find_file_id(context):
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/plugins/linkai/linkai.py", line 283, in _find_file_id
user_id = _find_user_id(context)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/plugins/linkai/linkai.py", line 265, in _find_user_id
if context["isgroup"]:
~~~~~~~^^^^^^^^^^^
File "/Users/xxx/Documents/workspace/chatgpt-on-wechat/bridge/context.py", line 46, in __getitem__
return self.kwargs[key]
~~~~~~~~~~~^^^^^
KeyError: 'isgroup'
[ERROR][2024-02-20 21:39:42][chat_channel.py:302] - Worker return exception: 'isgroup' NoneType: None
可复现,解决方案有效
最新版本已修复