zhayujie / bot-on-anything

Connect AI models (like ChatGPT-3.5/4.0, Baidu Yiyan, New Bing, Bard) to apps (like Wechat, public account, DingTalk, Telegram, QQ). 将 ChatGPT、必应、文心一言、谷歌Bard 等对话模型连接各类应用,如微信、公众号、QQ、Telegram、Gmail、Slack、Web、企业微信、飞书、钉钉等。
MIT License
3.89k stars 911 forks source link

OpenAI接口连接失败问题在这讨论 #56

Open Brightpan opened 1 year ago

Brightpan commented 1 year ago

不挂代理请求报错,应该是openAI那边对IP地址加限制了,限制大陆IP。在此求证下。

miozus commented 1 year ago
aaf5e5601c839568902634d7b7a0b68

这种没办法,只有换机场了。这几天公众号还流传"亚洲地区大面积封号"文章。

RegimenArsenic commented 1 year ago

image image 请问一下科学上网配置了,app也能运行成功,但是登录服务器ip却显示无法使用此页面是怎么回事啊 image

你启动的公众号通道

shawpei8 commented 1 year ago

服务器上跑了clash,curl可以。但是日志记录openai没走代理,对代理不是很熟,有没有老哥指导一下。

import os

os.environ["http_proxy"] = "http://127.0.0.1:7890" os.environ["https_proxy"] = "http://127.0.0.1:7890"

速度感人,不知道有什么解决方法?

zwjie12 commented 1 year ago

可以使用反代api,但是api的地址怎么更改,已经反代出来了

现在用的是 openai 的sdk,api 被封装了

@zhayujie 大佬,能像chatgpt-on-wechat一样自行指定API的地址吗? 支持自定义openai_api_base #465

WandingPace commented 1 year ago

image da代理设置了 貌似还是连不上 ,第一天玩centOS,帮忙看看呢

UniStart2 commented 1 year ago

@WandingPace 在Linux服务器上开代理可以试试clash-for-linux这个项目,我把代理开了以后,直接重新启动一边就可以了,也不需要改app.pyconfig.json文件,现在可以看到回复了

wjfkook commented 1 year ago

可以使用反代api,但是api的地址怎么更改,已经反代出来了

现在用的是 openai 的sdk,api 被封装了

没办法解决吗?教程里面都说反向代理出来会更加安全的啊!

WandingPace commented 1 year ago

@WandingPace 在Linux服务器上开代理可以试试clash-for-linux这个项目,我把代理开了以后,直接重新启动一边就可以了,也不需要改app.pyconfig.json文件,现在可以看到回复了

[root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# source /etc/profile.d/clash.sh [root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# proxy_on [√] 已开启代理 [root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# $ env | grep -E 'http_proxy|https_proxy' -bash: $: command not found [root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# env | grep -E 'http_proxy|https_proxy' http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890 [root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# netstat -tln | grep -E '9090|789.' [root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# env | grep -E 'http_proxy|https_proxy' http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890 [root@iZbp10r3vlu6yd4qso9yjrZ clash-for-linux]# curl https://www.google.com curl: (7) Failed connect to 127.0.0.1:7890; Connection refused

前面都成功了 还是访问不了外网

WandingPace commented 1 year ago

@UniStart2 检查了一下代理没问题,不知道是什么原因centOS还是连不上外网 TAT

UniStart2 commented 1 year ago

@WandingPace 你看下你的clash.log日志,你的clash应用貌似没启动起来,你运行的netstat命令没有输出,具体问题你可以去那个项目里提issue或者翻issue

UniStart2 commented 1 year ago

@WandingPace 是系统防火墙的原因么?

WandingPace commented 1 year ago

@UniStart2 防火墙已关闭 log显示/root/clash-for-linux/bin/clash-linux-amd64: line 1: clash-linux-amd64-v1.13.0: command not found

UniStart2 commented 1 year ago

@WandingPace bin目录下的clash对应的core文件没有,这不应该啊,不过实在缺失的话,你可以自己去clash项目下载对应版本的然后解压上传就好了

UniStart2 commented 1 year ago

@WandingPace 还有建议你去clash-for-linux项目看看issue,有没有类似的问题,这样解决的也快一点

WandingPace commented 1 year ago

@UniStart2 查到问题了 原来是因为我在window上解压用宝塔传过去的文件格式有问题

WandingPace commented 1 year ago

代理curl外网有反应了,不过 还是有问题: [INFO][2023-04-20 23:29:56][wechat_mp_channel.py:29] - [WX_Public] receive public msg: 吃饭了吗, userId: o0i-M5rQ_9G-tYT2WWU22NCK-96s [INFO][2023-04-20 23:29:56][wechat_mp_channel.py:57] - count=1, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-20 23:29:57][wechat_mp_channel.py:57] - count=2, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-20 23:29:58][wechat_mp_channel.py:57] - count=3, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-20 23:29:59][wechat_mp_channel.py:57] - count=4, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-20 23:29:59][wechat_mp_channel.py:64] - 微信超时3次 81.69.101.237 - - [20/Apr/2023 23:29:59] "POST /?signature=6a04375218cbd3e36df04f7cb51463d63602fdd0&timestamp=1682004575&nonce=1370567816&openid=o0i-M5rQ_9G-tYT2WWU22NCK-96s HTTP/1.1" 200 335

UniStart2 commented 1 year ago

@WandingPace 微信调用超时3次我也有,不过之后还是能拿到回复内容的,不知道你的行不行

WandingPace commented 1 year ago

还是拿不到回复,完整的log是这样的 `[root@iZbp10r3vlu6yd4qso9yjrZ bot-on-anything]# python3.9 app.py Load config success [INFO][2023-04-21 13:29:07][plugin_registry.py:23] - Plugin Selector_v0.1 registered [INFO][2023-04-21 13:29:07][log.py:32] - [Selector] inited [WARNING][2023-04-21 13:29:07][log.py:39] - Failed to import plugin createimg Load config success [INFO][2023-04-21 13:29:07][log.py:34] - [MultiChannel] Start up chatgpt on wechat_mp [INFO][2023-04-21 13:29:07][wechat_mp_channel.py:39] - [WX_Public] Wechat Public account service start! Bottle v0.12.25 server starting up (using AutoServer())... Listening on http://0.0.0.0:80/ Hit Ctrl-C to quit.

[INFO][2023-04-21 13:29:29][wechat_mp_channel.py:29] - [WX_Public] receive public msg: 你是谁, userId: o0i-M5oFHLaPtuIRMZqCkB-e6ee8 [INFO][2023-04-21 13:29:29][wechat_mp_channel.py:53] - Not res do send: content=你是谁, context={'from_user_id': 'o0i-M5oFHLaPtuIRMZqCkB-e6ee8'} [INFO][2023-04-21 13:29:29][wechat_mp_channel.py:58] - count=1, res={'status': 'waiting', 'req_times': 1} [INFO][2023-04-21 13:29:30][wechat_mp_channel.py:58] - count=2, res={'status': 'waiting', 'req_times': 1} [INFO][2023-04-21 13:29:31][wechat_mp_channel.py:58] - count=3, res={'status': 'waiting', 'req_times': 1} [INFO][2023-04-21 13:29:32][wechat_mp_channel.py:58] - count=4, res={'status': 'waiting', 'req_times': 1} [INFO][2023-04-21 13:29:33][wechat_mp_channel.py:58] - count=5, res={'status': 'waiting', 'req_times': 1} [W 230421 13:29:34 robot:613] No handler responded message <werobot.messages.messages.TextMessage object at 0x7f800934bbb0> 81.69.101.193 - - [21/Apr/2023 13:29:34] "POST /?signature=ed2e4b9f2f81a18c73224c8a25e4ec3afc2bbf75&timestamp=1682054969&nonce=1529681221&openid=o0i-M5oFHLaPtuIRMZqCkB-e6ee8 HTTP/1.1" 200 0 [INFO][2023-04-21 13:29:34][wechat_mp_channel.py:29] - [WX_Public] receive public msg: 你是谁, userId: o0i-M5oFHLaPtuIRMZqCkB-e6ee8 [INFO][2023-04-21 13:29:34][wechat_mp_channel.py:58] - count=1, res={'status': 'waiting', 'req_times': 2} [INFO][2023-04-21 13:29:35][wechat_mp_channel.py:58] - count=2, res={'status': 'waiting', 'req_times': 2} [INFO][2023-04-21 13:29:36][wechat_mp_channel.py:58] - count=3, res={'status': 'waiting', 'req_times': 2} [INFO][2023-04-21 13:29:37][wechat_mp_channel.py:58] - count=4, res={'status': 'waiting', 'req_times': 2} [INFO][2023-04-21 13:29:38][wechat_mp_channel.py:58] - count=5, res={'status': 'waiting', 'req_times': 2} [W 230421 13:29:39 robot:613] No handler responded message <werobot.messages.messages.TextMessage object at 0x7f800934b9a0> 175.24.211.157 - - [21/Apr/2023 13:29:39] "POST /?signature=ed2e4b9f2f81a18c73224c8a25e4ec3afc2bbf75&timestamp=1682054969&nonce=1529681221&openid=o0i-M5oFHLaPtuIRMZqCkB-e6ee8 HTTP/1.1" 200 0 [INFO][2023-04-21 13:29:39][wechat_mp_channel.py:29] - [WX_Public] receive public msg: 你是谁, userId: o0i-M5oFHLaPtuIRMZqCkB-e6ee8 [INFO][2023-04-21 13:29:39][wechat_mp_channel.py:58] - count=1, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-21 13:29:40][wechat_mp_channel.py:58] - count=2, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-21 13:29:41][wechat_mp_channel.py:58] - count=3, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-21 13:29:42][wechat_mp_channel.py:58] - count=4, res={'status': 'waiting', 'req_times': 3} [INFO][2023-04-21 13:29:42][wechat_mp_channel.py:65] - 微信超时3次 81.69.101.193 - - [21/Apr/2023 13:29:42] "POST /?signature=ed2e4b9f2f81a18c73224c8a25e4ec3afc2bbf75&timestamp=1682054969&nonce=1529681221&openid=o0i-M5oFHLaPtuIRMZqCkB-e6ee8 HTTP/1.1" 200 335`

jiuyuan-light commented 1 year ago

image 这个问题可以查一下这里的代码有没有问题

WandingPace commented 1 year ago

解决了 谢谢大佬

keilau119 commented 1 year ago

@WandingPace 微信调用超时3次我也有,不过之后还是能拿到回复内容的,不知道你的行不行

我这边测试会提示“公众号服务故障”,你那边有这个问题吗?

UniStart2 commented 1 year ago

@keilau119 有时问的太快会有这种情况,等一下就好了

guoqikun commented 1 year ago

几种可能的方案:

1.直接用能访问外网的服务器: 比如 阿里云香港服务器 -- 已试验

我自己买了一个阿里云新加坡的云服务器,部署项目后,联不通

zzhcn commented 1 year ago

几种可能的方案:

1.直接用能访问外网的服务器: 比如 阿里云香港服务器 -- 已试验

2.开代理:

  • 本地开发环境: 直接开启vpn就行,但要保证运行python程序的 命令行 或 IDE 也能生效 -- 已试验,用的hk节点
  • 服务器环境: 需要服务器运行代理软件 -- 已实验

3.托管到能访问外网的容器平台 -- 比如railway等, 待试验

详细步骤参考:zhayujie/chatgpt-on-wechat#351 , 有可行方案的欢迎补充

用香港的服务器目前也出现问题

shukui-ipo commented 3 months ago

docker部署的项目,使用clash代理,能连接外网,但是对话时提示 [WARNING][2024-06-01 19:19:39][chat_gpt_bot.py:150] - [CHATGPT] APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc5b8c1d180>: Failed to establish a new connection: [Errno 111] Connection refused'))) [WARNING][2024-06-01 19:19:44][chat_gpt_bot.py:160] - [CHATGPT] 第1次重试 [WARNING][2024-06-01 19:19:44][chat_gpt_bot.py:150] - [CHATGPT] APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc5b86d7e50>: Failed to establish a new connection: [Errno 111] Connection refused'))) [WARNING][2024-06-01 19:19:49][chat_gpt_bot.py:160] - [CHATGPT] 第2次重试 [WARNING][2024-06-01 19:19:49][chat_gpt_bot.py:150] - [CHATGPT] APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc5b9ce89d0>: Failed to establish a new connection: [Errno 111] Connection refused'))) [INFO][2024-06-01 19:19:49][wechat_channel.py:217] - [WX] sendMsg=Reply(type=ERROR, content=[ERROR] 我连接不到你的网络)

shukui-ipo commented 3 months ago

也配置了proxy

eatless commented 2 months ago

大哥们,求助,项目按照视频配置了,也正常启动了,但是提示报错: image