zhayujie / chatgpt-on-wechat

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT-o1/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
https://docs.link-ai.tech/cow
MIT License
30.4k stars 7.98k forks source link

docker部署使用企业微信通道,发送消息无回复 #1478

Closed xiaolietu closed 11 months ago

xiaolietu commented 11 months ago

前置确认

⚠️ 搜索issues中是否已存在类似问题

操作系统类型?

Linux

运行的python版本是?

python 3.10

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

other

复现步骤 🕹

docker运行正常,通道是wechatcom_app,在自建应用发送内容,无回复,100%出现

问题描述 😯

通道:wechatcom_app 已做的事项:域名、ip白名单都已配置 问题:能收到企业微信自建应用内容,但是不调用openai返回内容,发送问题不返回,发送#help也不返回

终端日志 📒

终端日志
http://0.0.0.0:9898/
[INFO][2023-10-18 14:07:39][wechatcomapp_channel.py:147] - [wechatcom] receive params: 
[DEBUG][2023-10-18 14:07:39][wechatcomapp_channel.py:156] - [wechatcom] receive message: 169760925872911762475700987311000061, msg= TextMessage({'ToUserName': 'wwe0dd20320c9580ef', 'FromUserName': 'ZengXiangBo', 'CreateTime': '1697609258', 'MsgType': 'text', 'Content': '小么小二郎', 'MsgId': '7291176247570098731', 'AgentID': '1000061'})
172.18.0.1:57806 - - [18/Oct/2023 14:07:39] "HTTP/1.1 POST /wxcomapp" - 200 OK
172.18.0.1:57838 - - [18/Oct/2023 14:30:33] "HTTP/1.1 GET /Electron/download/windows/\Program Files\3CX Phone System\Data\DB\base\16384\16393" - 404 Not Found
[INFO][2023-10-18 15:02:49][wechatcomapp_channel.py:147] - [wechatcom] receive params: 
[DEBUG][2023-10-18 15:02:49][wechatcomapp_channel.py:156] - [wechatcom] receive message: 169761256872911904637652065711000061, msg= TextMessage({'ToUserName': 'wwe0dd20320c9580ef', 'FromUserName': 'ZengXiangBo', 'CreateTime': '1697612568', 'MsgType': 'text', 'Content': '#help', 'MsgId': '7291190463765206571', 'AgentID': '1000061'})
172.18.0.1:57882 - - [18/Oct/2023 15:02:49] "HTTP/1.1 POST /wxcomapp" - 200 OK
run.log文件日志
[INFO][2023-10-18 14:07:39][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'timestamp': '1697609258', 'nonce': '1696804648', 'msg_signature': 'bf509ba3ecf82bc37321800905f82afd7ca705af'}>
[DEBUG][2023-10-18 14:07:39][wechatcomapp_channel.py:156] - [wechatcom] receive message: <xml><ToUserName><![CDATA[wwe0dd20320c9580ef]]></ToUserName><FromUserName><![CDATA[ZengXiangBo]]></FromUserName><CreateTime>1697609258</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[小么小二郎]]></Content><MsgId>7291176247570098731</MsgId><AgentID>1000061</AgentID></xml>, msg= TextMessage({'ToUserName': 'wwe0dd20320c9580ef', 'FromUserName': 'ZengXiangBo', 'CreateTime': '1697609258', 'MsgType': 'text', 'Content': '小么小二郎', 'MsgId': '7291176247570098731', 'AgentID': '1000061'})
[INFO][2023-10-18 15:02:49][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'timestamp': '1697612568', 'nonce': '1696949048', 'msg_signature': '46e520666c3d8ab72c64cc35ea55de90346e2120'}>
[DEBUG][2023-10-18 15:02:49][wechatcomapp_channel.py:156] - [wechatcom] receive message: <xml><ToUserName><![CDATA[wwe0dd20320c9580ef]]></ToUserName><FromUserName><![CDATA[ZengXiangBo]]></FromUserName><CreateTime>1697612568</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[#help]]></Content><MsgId>7291190463765206571</MsgId><AgentID>1000061</AgentID></xml>, msg= TextMessage({'ToUserName': 'wwe0dd20320c9580ef', 'FromUserName': 'ZengXiangBo', 'CreateTime': '1697612568', 'MsgType': 'text', 'Content': '#help', 'MsgId': '7291190463765206571', 'AgentID': '1000061'})
zhayujie commented 11 months ago

"single_chat_prefix" 这个触发前缀的参数是一个数组, 如果要配置为空的话应该是 "single_chat_prefix": []

如果是docker-compose 配置应该是 SINGLE_CHAT_PREFIX: '[""]'

xiaolietu commented 11 months ago

@zhayujie 按照您的指点好使一点但又没完全好使。下面给您提供了yml文件内容、终端日志、run.log日志

docker-compose.yml文件内容
version: '2.0'
services:
  chatgpt-on-wechat:
    image: zhayujie/chatgpt-on-wechat
    container_name: chatgpt-on-wechat
    security_opt:
      - seccomp:unconfined
    environment:
      OPEN_AI_API_KEY: ''
      MODEL: 'gpt-3.5-turbo-16k'
      SINGLE_CHAT_PREFIX: '[""]'
      SINGLE_CHAT_REPLY_PREFIX: '["bot"]'
      GROUP_CHAT_PREFIX: '["@bot"]'
      GROUP_NAME_WHITE_LIST: '[""]'
      IMAGE_CREATE_PREFIX: '["画"]'
      CONVERSATION_MAX_TOKENS: '1000'
      SPEECH_RECOGNITION: 'False'
      CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'
      EXPIRES_IN_SECONDS: '3600'
      USE_GLOBAL_PLUGIN_CONFIG: 'True'
      USE_LINKAI: 'False'
      LINKAI_API_KEY: ''
      LINKAI_APP_CODE: ''
      CHANNEL_TYPE: 'wechatcom_app'
      HOT_RELOAD: 'False'
      GROUP_SPEECH_RECOGNITION: 'False'
      VOICE_REPLY_VOICE: 'False'
      RATE_LIMIT_CHATGPT: '30'
      TEMPERATURE: '0.7'
      TIMEOUT: '120'
      TOP_P: '1'
      CLEAR_MEMORY_COMMANDS: '["#清除记忆"]'
      SUBSCRIBE_MSG: '感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输入。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持tool、角色扮演和文字冒险等丰富的插件。\n输入{trigger_prefix}#help 查看详细指令。'
      PLUGIN_TRIGGER_PREFIX: '$'
      WECHATCOM_CORP_ID: ''
      WECHATCOMAPP_TOKEN: ''
      WECHATCOMAPP_PORT: '9898'
      WECHATCOMAPP_SECRET: ''
      WECHATCOMAPP_AGENT_ID: ''
      WECHATCOMAPP_AES_KEY: ''
      TZ: 'Asia/Shanghai'
      debug: 'True'
    ports:
      - 127.0.0.1:9898:9898
    volumes:
      - ./config.json:/app/plugins/godcmd/config.json
终端日志
[INFO][2023-10-18 22:09:03][wechatcomapp_channel.py:147] - [wechatcom] receive params: 
[DEBUG][2023-10-18 22:09:03][wechatcomapp_channel.py:156] - [wechatcom] receive message: 169763814372913003050642522031000061, msg= TextMessage({'ToUserName': 'wwe0dd20320c9580ef', 'FromUserName': 'ZengXiangBo', 'CreateTime': '1697638143', 'MsgType': 'text', 'Content': '你好', 'MsgId': '7291300305064252203', 'AgentID': '1000061'})
172.18.0.1:46380 - - [18/Oct/2023 22:09:03] "HTTP/1.1 POST /wxcomapp" - 200 OK
[DEBUG][2023-10-18 22:09:03][chat_channel.py:326] - [WX] consume context: Context(type=TEXT, content=你好, kwargs={'isgroup': False, 'msg': , 'origin_ctype': , 'openai_api_key': None, 'gpt_model': None, 'session_id': 'ZengXiangBo', 'receiver': 'ZengXiangBo'})
[DEBUG][2023-10-18 22:09:03][chat_channel.py:153] - [WX] ready to handle context: Context(type=TEXT, content=你好, kwargs={'isgroup': False, 'msg': , 'origin_ctype': , 'openai_api_key': None, 'gpt_model': None, 'session_id': 'ZengXiangBo', 'receiver': 'ZengXiangBo'})
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin KEYWORD triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][keyword.py:52] - [keyword] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin LINKAI triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][summary.py:93] - [LinkSum] unsupported url, no need to process, url=你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin TOOL triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][tool.py:68] - [tool] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin ROLE triggered by event Event.ON_HANDLE_CONTEXT
[INFO][2023-10-18 22:09:03][bridge.py:39] - create bot chatGPT for chat
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin DUNGEON triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][dungeon.py:73] - [Dungeon] on_handle_context. content: ['你好']
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin HELLO triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][hello.py:48] - [Hello] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin FINISH triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][finish.py:30] - [Finish] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][chat_channel.py:173] - [WX] ready to handle context: type=TEXT, content=你好
[INFO][2023-10-18 22:09:03][chat_gpt_bot.py:49] - [CHATGPT] query=你好
[DEBUG][2023-10-18 22:09:04][session_manager.py:70] - prompt tokens used=68
[DEBUG][2023-10-18 22:09:04][chat_gpt_bot.py:66] - [CHATGPT] session query=[{'role': 'system', 'content': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, {'role': 'user', 'content': '你好'}]
[DEBUG][2023-10-18 22:09:06][chat_gpt_bot.py:79] - [CHATGPT] new_query=[{'role': 'system', 'content': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, {'role': 'user', 'content': '你好'}], session_id=ZengXiangBo, reply_cont=你好!有什么我可以帮助你的吗?, completion_tokens=18
[DEBUG][2023-10-18 22:09:06][session_manager.py:81] - raw total_tokens=86, savesession tokens=90
[DEBUG][2023-10-18 22:09:06][chat_channel.py:157] - [WX] ready to decorate reply: Reply(type=TEXT, content=你好!有什么我可以帮助你的吗?)
[ERROR][2023-10-18 22:09:06][chat_channel.py:284] - Worker return exception: can only concatenate list (not "str") to list
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/channel/chat_channel.py", line 159, in _handle
    reply = self._decorate_reply(context, reply)
  File "/app/channel/chat_channel.py", line 242, in _decorate_reply
    reply_text = conf().get("single_chat_reply_prefix", "") + reply_text + conf().get("single_chat_reply_suffix", "")
TypeError: can only concatenate list (not "str") to list
run.log文件日志
[INFO][2023-10-18 22:09:03][wechatcomapp_channel.py:147] - [wechatcom] receive params: <Storage {'nonce': '1697507336', 'timestamp': '1697638143', 'msg_signature': 'bee5a15fea3302a61edcdba4e8898d44c89d2455'}>
[DEBUG][2023-10-18 22:09:03][wechatcomapp_channel.py:156] - [wechatcom] receive message: <xml><ToUserName><![CDATA[wwe0dd20320c9580ef]]></ToUserName><FromUserName><![CDATA[ZengXiangBo]]></FromUserName><CreateTime>1697638143</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[你好]]></Content><MsgId>7291300305064252203</MsgId><AgentID>1000061</AgentID></xml>, msg= TextMessage({'ToUserName': 'wwe0dd20320c9580ef', 'FromUserName': 'ZengXiangBo', 'CreateTime': '1697638143', 'MsgType': 'text', 'Content': '你好', 'MsgId': '7291300305064252203', 'AgentID': '1000061'})
[DEBUG][2023-10-18 22:09:03][chat_channel.py:326] - [WX] consume context: Context(type=TEXT, content=你好, kwargs={'isgroup': False, 'msg': <channel.wechatcom.wechatcomapp_message.WechatComAppMessage object at 0x7efe15429c60>, 'origin_ctype': <ContextType.TEXT: 1>, 'openai_api_key': None, 'gpt_model': None, 'session_id': 'ZengXiangBo', 'receiver': 'ZengXiangBo'})
[DEBUG][2023-10-18 22:09:03][chat_channel.py:153] - [WX] ready to handle context: Context(type=TEXT, content=你好, kwargs={'isgroup': False, 'msg': <channel.wechatcom.wechatcomapp_message.WechatComAppMessage object at 0x7efe15429c60>, 'origin_ctype': <ContextType.TEXT: 1>, 'openai_api_key': None, 'gpt_model': None, 'session_id': 'ZengXiangBo', 'receiver': 'ZengXiangBo'})
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin KEYWORD triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][keyword.py:52] - [keyword] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin LINKAI triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][summary.py:93] - [LinkSum] unsupported url, no need to process, url=你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin TOOL triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][tool.py:68] - [tool] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin ROLE triggered by event Event.ON_HANDLE_CONTEXT
[INFO][2023-10-18 22:09:03][bridge.py:39] - create bot chatGPT for chat
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin DUNGEON triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][dungeon.py:73] - [Dungeon] on_handle_context. content: ['你好']
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin HELLO triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][hello.py:48] - [Hello] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][plugin_manager.py:187] - Plugin FINISH triggered by event Event.ON_HANDLE_CONTEXT
[DEBUG][2023-10-18 22:09:03][finish.py:30] - [Finish] on_handle_context. content: 你好
[DEBUG][2023-10-18 22:09:03][chat_channel.py:173] - [WX] ready to handle context: type=TEXT, content=你好
[INFO][2023-10-18 22:09:03][chat_gpt_bot.py:49] - [CHATGPT] query=你好
[DEBUG][2023-10-18 22:09:04][session_manager.py:70] - prompt tokens used=68
[DEBUG][2023-10-18 22:09:04][chat_gpt_bot.py:66] - [CHATGPT] session query=[{'role': 'system', 'content': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, {'role': 'user', 'content': '你好'}]
[DEBUG][2023-10-18 22:09:06][chat_gpt_bot.py:79] - [CHATGPT] new_query=[{'role': 'system', 'content': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, {'role': 'user', 'content': '你好'}], session_id=ZengXiangBo, reply_cont=你好!有什么我可以帮助你的吗?, completion_tokens=18
[DEBUG][2023-10-18 22:09:06][session_manager.py:81] - raw total_tokens=86, savesession tokens=90
[DEBUG][2023-10-18 22:09:06][chat_channel.py:157] - [WX] ready to decorate reply: Reply(type=TEXT, content=你好!有什么我可以帮助你的吗?)
[ERROR][2023-10-18 22:09:06][chat_channel.py:284] - Worker return exception: can only concatenate list (not "str") to list
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/channel/chat_channel.py", line 159, in _handle
    reply = self._decorate_reply(context, reply)
  File "/app/channel/chat_channel.py", line 242, in _decorate_reply
    reply_text = conf().get("single_chat_reply_prefix", "") + reply_text + conf().get("single_chat_reply_suffix", "")
TypeError: can only concatenate list (not "str") to list
zhayujie commented 11 months ago

SINGLE_CHAT_REPLY_PREFIX 这个参数是字符串类型

正确写法是 SINGLE_CHAT_REPLY_PREFIX: '"[bot]"'

LeoAKALiu commented 6 months ago

"single_chat_prefix" 这个触发前缀的参数是一个数组, 如果要配置为空的话应该是 "single_chat_prefix": []

如果是docker-compose 配置应该是 SINGLE_CHAT_PREFIX: '[""]'

json配置为空应该是"single_chat_prefix": [""]