zhayujie / chatgpt-on-wechat

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

企业微信应用配置api接收消息报错,提示openapi回调地址请求不通过 #1634

Open Qm-jmz opened 6 months ago

Qm-jmz commented 6 months ago

前置确认

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

操作系统类型?

Docker

运行的python版本是?

python 3.8

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

Latest Release

运行的channel类型是?

other

复现步骤 🕹

服务器使用ipv6,docker-compose安装,环境变量配置wechatcom_app通道相关参数,docker网络为bridge,转发9898端口

企业微信未备案,接收消息服务器配置如下: url http://[ipv6]:9898/wxcomapp

问题描述 😯

企业微信未备案,无法使用域名,只能使用ip,但服务器无公网ipv4有ipv6,故使用ipv6。 容器使用docker-compose安装,环境变量中已配置好wechatcom_app通道相关参数 image

默认docker-compose.yml使用host网络,经测试,国内主机浏览器无法打开http://[ipv6]:9898/wxcomapp,但可打开http://局域网ipv4:9898/wxcomapp。(同时,我的其他容器ipv6可以访问,怀疑本容器内部代码有问题)

尝试修改docker-compose.yml,网络模式设置为bridge,同时设置9898端口转发。国内主机浏览器打开http://[ipv6]:9898/wxcomapp显示如下 image

但在企业微信中配置接收消息服务器时无法保存,出现两种提示: 1.服务器异常,请稍后再试 2.openapi回调地址请求不通过

终端日志 📒

 docker logs chatgpt-on-wechat
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: wechatcomapp_port=9898
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: linkai_api_key=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: group_chat_prefix=["@bot"]
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: image_create_prefix=["画", "看", " 找"]
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: single_chat_reply_prefix="[bot] "
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: conversation_max_tokens=1000
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: open_ai_api_base=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: expires_in_seconds=3600
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: single_chat_prefix=["bot", "@bot"]
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: model=gpt-3.5-turbo
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: use_linkai=True
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: wechatcomapp_secret=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: proxy=
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: channel_type=wechatcom_app
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: character_desc=你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: linkai_app_code=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: speech_recognition=False
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: wechatcom_corp_id=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: wechatcomapp_agent_id=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: group_name_white_list=[]
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: wechatcomapp_aes_key=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: use_global_plugin_config=True
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: wechatcomapp_token=隐去
[INFO][2023-12-28 08:08:48][config.py:221] - [INIT] override config by environ args: open_ai_api_key=隐去
[INFO][2023-12-28 08:08:48][config.py:236] - [INIT] load config: {'channel_type': 'wechatcom_app', 'model': 'gpt-3.5-turbo', 'open_ai_api_key': '隐去', 'text_to_image': 'dall-e-2', 'voice_to_text': 'openai', 'text_to_voice': 'openai', 'proxy': '', 'hot_reload': False, 'single_chat_prefix': ['bot', '@bot'], 'single_chat_reply_prefix': '[bot] ', 'group_chat_prefix': ['@bot'], 'group_name_white_list': [], 'group_chat_in_one_session': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找'], 'speech_recognition': False, 'group_speech_recognition': False, 'voice_reply_voice': False, 'conversation_max_tokens': 1000, 'expires_in_seconds': 3600, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。', 'temperature': 0.7, 'top_p': 1, 'subscribe_msg': '感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输入。\n支持 图片输出,画字开头的消息将按要求创作图片。\n支持tool、角色扮演和文字冒险等丰富的插件。\n输入{trigger_prefix}#help 查看详细指令。', 'use_linkai': True, 'linkai_api_key': '隐去', 'linkai_app_code': 'yq', 'wechatcomapp_port': 9898, 'open_ai_api_base': 'yq', 'wechatcomapp_secret': 'yq', 'wechatcom_corp_id': 'yq', 'wechatcomapp_agent_id': yq, 'wechatcomapp_aes_key': 'yq', 'use_global_plugin_config': True, 'wechatcomapp_token': 'yq'}
[INFO][2023-12-28 08:08:48][config.py:186] - [Config] User datas file not found, ignore.
[WARNING][2023-12-28 08:08:49][audio_convert.py:9] - import pysilk failed, wechaty voice message will not be supported.
yq
[INFO][2023-12-28 08:08:49][wechatcomapp_channel.py:39] - [wechatcom] init: corp_id: yq, secret: yq, agent_id: yq, token: yq, aes_key: yq
[INFO][2023-12-28 08:08:49][plugin_manager.py:50] - Loading plugins config...
[INFO][2023-12-28 08:08:49][plugin_manager.py:88] - Scaning plugins ...
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Banwords_v1.0 registered, path=./plugins/banwords
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin BDunit_v0.1 registered, path=./plugins/bdunit
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Dungeon_v1.0 registered, path=./plugins/dungeon
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Finish_v1.0 registered, path=./plugins/finish
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Godcmd_v1.0 registered, path=./plugins/godcmd
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Hello_v0.1 registered, path=./plugins/hello
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Keyword_v0.1 registered, path=./plugins/keyword
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin linkai_v0.1.0 registered, path=./plugins/linkai
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin Role_v1.0 registered, path=./plugins/role
chatgpt-tool-hub version: 0.4.6
[INFO][2023-12-28 08:08:49][plugin_manager.py:41] - Plugin tool_v0.4 registered, path=./plugins/tool
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin GODCMD not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin KEYWORD not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin BANWORDS not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin LINKAI not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin TOOL not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin ROLE not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin DUNGEON not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin BDUNIT not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin HELLO not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:123] - Plugin FINISH not found in pconfig, adding to pconfig...
[INFO][2023-12-28 08:08:49][plugin_manager.py:80] - load all config from plugins/config.json: {'godcmd': {'password': '', 'admin_users': []}, 'banwords': {'action': 'replace', 'reply_filter': True, 'reply_action': 'ignore'}, 'tool': {'tools': ['python', 'url-get', 'terminal', 'meteo-weather', 'wikipedia', 'news', 'arxiv'], 'kwargs': {'top_k_results': 2, 'no_default': False, 'model_name': 'gpt-3.5-turbo'}}, 'linkai': {'group_app_map': {}, 'midjourney': {'enabled': True, 'auto_translate': True, 'img_proxy': True, 'max_tasks': 3, 'max_tasks_per_user': 1, 'use_image_create_prefix': True}, 'summary': {'enabled': True, 'group_enabled': False, 'max_file_size': 10000, 'type': ['FILE', 'SHARING']}}}
[INFO][2023-12-28 08:08:49][godcmd.py:194] - [Godcmd] 因未设置口令,本次的临时口令为yq。
[INFO][2023-12-28 08:08:49][godcmd.py:210] - [Godcmd] inited
[INFO][2023-12-28 08:08:49][keyword.py:40] - [keyword] {}
[INFO][2023-12-28 08:08:49][keyword.py:42] - [keyword] inited.
[WARNING][2023-12-28 08:08:49][banwords.py:54] - [Banwords] init failed, ignore or see https://github.com/zhayujie/chatgpt-on-wechat/tree/master/plugins/banwords .
[WARNING][2023-12-28 08:08:49][plugin_manager.py:148] - Failed to init BANWORDS, diabled. [Errno 2] No such file or directory: '/app/plugins/banwords/banwords.txt'
[INFO][2023-12-28 08:08:49][linkai.py:33] - [LinkAI] inited, config={'group_app_map': {}, 'midjourney': {'enabled': True, 'auto_translate': True, 'img_proxy': True, 'max_tasks': 3, 'max_tasks_per_user': 1, 'use_image_create_prefix': True}, 'summary': {'enabled': True, 'group_enabled': False, 'max_file_size': 10000, 'type': ['FILE', 'SHARING']}}
[INFO][2023-12-28 08:08:49][__init__.py:29] - [visual_dl] init failed, error_info: ModuleNotFoundError("No module named 'torch'")
[INFO][2023-12-28 08:08:49][__init__.py:29] - [visual_dl] init failed, error_info: ModuleNotFoundError("No module named 'torch'")
[INFO][2023-12-28 08:08:49][chatgpt.py:186] - proxy no find, directly request to chatgpt instead
[INFO][2023-12-28 08:08:49][chatgpt.py:191] - success use customized api base url: yq
[INFO][2023-12-28 08:08:49][chatgpt.py:186] - proxy no find, directly request to chatgpt instead
[INFO][2023-12-28 08:08:49][chatgpt.py:186] - proxy no find, directly request to chatgpt instead
[INFO][2023-12-28 08:08:50][chatgpt.py:186] - proxy no find, directly request to chatgpt instead
[INFO][2023-12-28 08:08:50][victorinox.py:86] - use_tools=['terminal', 'wikipedia', 'python', 'url-get', 'news', 'meteo-weather', 'arxiv'], params: {'debug': False, 'openai_api_key': 'yq', 'open_ai_api_base': 'yq', 'deployment_id': '', 'proxy': '', 'request_timeout': 120, 'model_name': 'gpt-3.5-turbo', 'no_default': False, 'top_k_results': 2, 'news_api_key': '', 'bing_subscription_key': '', 'google_api_key': '', 'google_cse_id': '', 'searx_search_host': '', 'wolfram_alpha_appid': '', 'morning_news_api_key': '', 'cuda_device': 'cpu', 'think_depth': 3, 'arxiv_summary': True, 'morning_news_use_llm': False, 'llm_api_key': 'yq', 'llm_api_base_url': 'yq'}
[INFO][2023-12-28 08:08:50][tool.py:31] - [tool] inited
[INFO][2023-12-28 08:08:50][role.py:69] - [Role] inited
[INFO][2023-12-28 08:08:50][dungeon.py:56] - [Dungeon] inited
[WARNING][2023-12-28 08:08:50][bdunit.py:42] - [BDunit] init failed, ignore
[WARNING][2023-12-28 08:08:50][plugin_manager.py:148] - Failed to init BDUNIT, diabled. config.json not found
[INFO][2023-12-28 08:08:50][hello.py:24] - [Hello] inited
[INFO][2023-12-28 08:08:50][finish.py:23] - [Finish] inited
http://0.0.0.0:9898/
[INFO][2023-12-28 08:11:58][wechatcomapp_channel.py:133] - [wechatcom] receive params: <Storage {}>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/web/utils.py", line 104, in __getattr__
    return self[key]
KeyError: 'msg_signature'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 280, in process
    return self.handle()
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 271, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 517, in _delegate
    return handle_class(cls)
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 495, in handle_class
    return tocall(*args)
  File "/app/channel/wechatcom/wechatcomapp_channel.py", line 135, in GET
    signature = params.msg_signature
  File "/usr/local/lib/python3.10/site-packages/web/utils.py", line 106, in __getattr__
    raise AttributeError(k)
AttributeError: 'msg_signature'

172.20.0.1:40038 - - [28/Dec/2023 08:11:59] "HTTP/1.1 GET /wxcomapp" - 500 Internal Server Error
[INFO][2023-12-28 08:14:45][wechatcomapp_channel.py:133] - [wechatcom] receive params: <Storage {}>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/web/utils.py", line 104, in __getattr__
    return self[key]
KeyError: 'msg_signature'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 280, in process
    return self.handle()
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 271, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 517, in _delegate
    return handle_class(cls)
  File "/usr/local/lib/python3.10/site-packages/web/application.py", line 495, in handle_class
    return tocall(*args)
  File "/app/channel/wechatcom/wechatcomapp_channel.py", line 135, in GET
    signature = params.msg_signature
  File "/usr/local/lib/python3.10/site-packages/web/utils.py", line 106, in __getattr__
    raise AttributeError(k)
AttributeError: 'msg_signature'

172.20.0.1:58924 - - [28/Dec/2023 08:14:45] "HTTP/1.1 GET /wxcomapp" - 500 Internal Server Error
Wang1Big commented 6 months ago

这个问题我也遇到了,应该是企业微信的API还不支持IPV6,所以无法完成回调。

dsosy commented 6 months ago

我是ipv4,openapi回调地址不通过困扰着

kilimro commented 6 months ago

我也遇到了相同的问题,怎么破呢

kyeo-hub commented 5 months ago

给一个解题思路,花10元随便买个域名,把域名给到cloudflare托管,IPV6利用cloudflare的隧道绑定到域名上面,应该就可以了。上面错误日志里面的是企业微信回调会带的信息,你这里是空,说明根本没有收到企业微信的回调。 另外通过企业微信回调的地址,并不一定要在你这台机器上,也可以利用其他有IPV4的机器部署回调,别问我怎么知道的,最近部署青龙的通知服务时用企业微信回调也是研究了半天,结果使用这个项目回调成功,直接可信IP绑定了青龙的IP,也可以成功接收到青龙的信息(我的青龙和chatgpt-on-wechat不是部署在同一个IP上),不过即使你回调成功,我估计企业微信可信IP哪里还是不能使用IPV6,所以利用cloudflare的隧道加域名应该是比较便宜且方便的办法。 不用cloudflare也可以直接用域名解析IPV6,但是那样就怕你自己的IPV6地址改变了,不稳定。 总结原理就是域名绑定: 1.IPV4利用脚本动态绑定域名 2.IPV6直接绑定域名 3.IPV6+cloudflare隧道绑定域名(这一种重启服务器不怕IP改变)

kilimro commented 5 months ago

您好!您的邮件我已经收到!我会尽快给您回复~

lm379 commented 3 months ago

我也遇到相同的问题了,域名解析到阿里云新加坡的机器上无法通过,但是在广州的服务器就能通过验证,是不是只能境内的ip才能通过校验啊,两台机器都是纯ipv4

kilimro commented 3 months ago

您好!您的邮件我已经收到!我会尽快给您回复~

liurulin commented 1 month ago

现在解决了吗?我也是同样的问题

kilimro commented 1 month ago

您好!您的邮件我已经收到!我会尽快给您回复~

hjhhx commented 3 weeks ago

现在解决了吗?我也是同样的问题