[ERROR][2024-06-14 20:15:36][chat_channel.py:303] - Worker return exception: can only concatenate str (not "list") to str
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 176, in _handle
reply = self._decorate_reply(context, reply)
File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 261, in _decorate_reply
reply_text = conf().get("single_chat_reply_prefix", "") + reply_text + conf().get("single_chat_reply_suffix", "")
TypeError: can only concatenate str (not "list") to str
[INFO][2024-06-14 20:16:56][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'msg_signature': 'aeb6646b9251e3dbd2e3bbdbe18929e3666f5c8d', 'timestamp': '1718367416', 'nonce': '1718551955'}>
问题描述 😯
企业微信应用建立调试中,简单回复如你是谁正常,复杂查询回复报错。
比如[INFO][2024-06-14 20:16:56][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'msg_signature': 'aeb6646b9251e3dbd2e3bbdbe18929e3666f5c8d', 'timestamp': '1718367416', 'nonce': '1718551955'}>
183.47.98.168:16224 - - [14/Jun/2024 20:16:56] "HTTP/1.1 POST /wxcomapp" - 200 OK
[INFO][2024-06-14 20:16:56][chat_gpt_bot.py:49] - [CHATGPT] query=广州今天天气
[WARNING][2024-06-14 20:16:56][session_manager.py:94] - Exception when counting tokens precisely for prompt: name 'get_tokenizer' is not defined
[WARNING][2024-06-14 20:17:04][session_manager.py:106] - Exception when counting tokens precisely for session: name 'get_tokenizer' is not defined
[INFO][2024-06-14 20:17:04][wechatcomapp_channel.py:63] - [wechatcom] Do send text to QinXiaoQiang: [xyb]
您好,我来了~今天广州的天气预报显示,天气状况为大雨转大到暴雨,气温范围在33℃到26℃之间,风力为3-4级。
如果是复杂的问题,直接会报错
[WARNING][2024-06-14 20:15:19][session_manager.py:94] - Exception when counting tokens precisely for prompt: name 'get_tokenizer' is not defined
[WARNING][2024-06-14 20:15:36][session_manager.py:106] - Exception when counting tokens precisely for session: name 'get_tokenizer' is not defined
[ERROR][2024-06-14 20:15:36][chat_channel.py:303] - Worker return exception: can only concatenate str (not "list") to str
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 176, in _handle
reply = self._decorate_reply(context, reply)
File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 261, in _decorate_reply
reply_text = conf().get("", "") + reply_text + conf().get("single_chat_reply_suffix", "")
TypeError: can only concatenate str (not "list") to str
前置确认
⚠️ 搜索issues中是否已存在类似问题
操作系统类型?
MacOS
运行的python版本是?
python 3.8
使用的chatgpt-on-wechat版本是?
Latest Release
运行的
channel
类型是?other
复现步骤 🕹
[ERROR][2024-06-14 20:15:36][chat_channel.py:303] - Worker return exception: can only concatenate str (not "list") to str Traceback (most recent call last): File "/usr/local/python3/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 176, in _handle reply = self._decorate_reply(context, reply) File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 261, in _decorate_reply reply_text = conf().get("single_chat_reply_prefix", "") + reply_text + conf().get("single_chat_reply_suffix", "") TypeError: can only concatenate str (not "list") to str [INFO][2024-06-14 20:16:56][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'msg_signature': 'aeb6646b9251e3dbd2e3bbdbe18929e3666f5c8d', 'timestamp': '1718367416', 'nonce': '1718551955'}>
问题描述 😯
企业微信应用建立调试中,简单回复如你是谁正常,复杂查询回复报错。 比如[INFO][2024-06-14 20:16:56][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'msg_signature': 'aeb6646b9251e3dbd2e3bbdbe18929e3666f5c8d', 'timestamp': '1718367416', 'nonce': '1718551955'}> 183.47.98.168:16224 - - [14/Jun/2024 20:16:56] "HTTP/1.1 POST /wxcomapp" - 200 OK [INFO][2024-06-14 20:16:56][chat_gpt_bot.py:49] - [CHATGPT] query=广州今天天气 [WARNING][2024-06-14 20:16:56][session_manager.py:94] - Exception when counting tokens precisely for prompt: name 'get_tokenizer' is not defined [WARNING][2024-06-14 20:17:04][session_manager.py:106] - Exception when counting tokens precisely for session: name 'get_tokenizer' is not defined [INFO][2024-06-14 20:17:04][wechatcomapp_channel.py:63] - [wechatcom] Do send text to QinXiaoQiang: [xyb] 您好,我来了~今天广州的天气预报显示,天气状况为大雨转大到暴雨,气温范围在33℃到26℃之间,风力为3-4级。
如果是复杂的问题,直接会报错 [WARNING][2024-06-14 20:15:19][session_manager.py:94] - Exception when counting tokens precisely for prompt: name 'get_tokenizer' is not defined [WARNING][2024-06-14 20:15:36][session_manager.py:106] - Exception when counting tokens precisely for session: name 'get_tokenizer' is not defined [ERROR][2024-06-14 20:15:36][chat_channel.py:303] - Worker return exception: can only concatenate str (not "list") to str Traceback (most recent call last): File "/usr/local/python3/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 176, in _handle reply = self._decorate_reply(context, reply) File "/usr/cow-qywx/chatgpt-on-wechat/channel/chat_channel.py", line 261, in _decorate_reply reply_text = conf().get("", "") + reply_text + conf().get("single_chat_reply_suffix", "") TypeError: can only concatenate str (not "list") to str
gpt4的解释: 这个错误信息表明在 chat_channel.py 文件的第 261 行,你尝试将一个字符串与一个列表进行拼接,这是不允许的。具体来说,reply_text 是一个列表,而你试图将其与字符串 conf().get("single_chat_reply_prefix", "") 和 conf().get("single_chat_reply_suffix", "") 进行拼接。
要解决这个问题,你需要确保 reply_text 是一个字符串,而不是一个列表。你可以通过以下几种方式来处理:
检查 reply_text 的来源:确保在赋值给 reply_text 之前,它已经被正确地转换为字符串。
gpt4给出代码 def _decorate_reply(self, context, reply):
假设 reply_text 是一个列表
终端日志 📒