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、企业微信、飞书、钉钉等。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Brightpan opened this issue · comments

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

同,今天服务器运行没有回复

是的,需要代理

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

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

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

暂时通过代理或者外网服务器来解决吧, 其他方案我周末更新下

几种可能的方案:

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

2.开代理:

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

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

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

我使用的美西甲骨文,然后腾讯云再反代了一下

几种可能的方案:

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

2.开代理:

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

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

有可行方案的欢迎补充

OpenWrt软路由搭梯子绕过大陆IP模式就能用。

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

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

分流模式设置问题

服务器上跑了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"

这段加进app.py

这段加进app.py

解决了,谢谢

建议railway ,部署变更都很方便

建议railway ,部署变更都很方便

后续会支持

解决方案:zhayujie/chatgpt-on-wechat#351

步骤相似,配置的位置稍有不同

commented

几种可能的方案:

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

我挂在 美国的一个服务器上,请问 proxy应该怎么填写

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

我挂在 美国的一个服务器上,请问 proxy应该怎么填写
不用代理

@wobushitiegan 不填就行

commented

服务器上跑了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"

使用docker运行项目,容器内跑了clash,增加代码,可以正常运行

服务器上跑了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"

使用docker运行项目,容器内跑了clash,增加代码,可以正常运行

请问在docker里面用clash代理跑QQ,端口监听有什么改变吗,或者需要加什么代码吗。谢谢了

commented

image
请问这种情况是代理失败了吗?我运行程序用httpbin检测ip是在我vpn所代理地方,但是还是显示失败了😭😭

1.使用QQ
2.运行在本地,本地开了代理
3.app.py运行成功,配置如下
1678267777041
4.go-cqhttp启动成功,能成功收发qq消息,不过会跳警告
image
5.与bot对话时,能接收到消息,但是貌似无法连接
image

@wanhaij 10000端口上运行的客户端有日志显示吗

@wanhaij 10000端口上运行的客户端有日志显示吗

没有日志...
我尝试把proxy参数删除掉,现在的配置如下:
image
但是还是会报无法连接代理的错误,我的理解是这种配置下应该不会尝试连接代理吧
image

@wanhaij 10000端口上运行的客户端有日志显示吗

没有日志... 我尝试把proxy参数删除掉,现在的配置如下: image 但是还是会报无法连接代理的错误,我的理解是这种配置下应该不会尝试连接代理吧 image

image
代理的日志翻到了,感觉可能是代理的问题

commented

目前我能开代理用web 打开,但是
image
哪个大哥教我下,代理信息如图:
image "proxy": "http://usla.mjt001.com", 写成这样没用

目前我能开代理用web 打开,但是 image 哪个大哥教我下,代理信息如图: image "proxy": "http://usla.mjt001.com", 写成这样没用

一样的问题

经常出现后台日志显示 ChatGP已经回复,公众号提示服务出现故障,是什么问题

你运行客户端可以使用吗

commented

在clash的配置文件里,rules下面,添加上openai的规则,指定openai走的线路

commented

No handler responded messageda导致的超时这种该怎么解决
图片

必应的怎么代理呀?不通

No handler responded messageda导致的超时这种该怎么解决 图片

我回退到老版本了,可以用。感觉像是进程池的问题
2caa181

commented

我也是上面这个问题 两天了 #190
image

commented

都按上面说的解决不了

commented

我解决了

我解决了

怎么解决的啊大佬

commented

已解决。

// 20230329174025 
// 使用代理,打开浏览器情况下访问 https://api.openai.com/ 正常情况会显示

{
  "error": {
    "message": "Invalid URL (GET /)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

如果在服务器(全局代理),终端使用 wget 应该是这样

➜  bot-on-anything git:(master) wget https://api.openai.com
--2023-03-29 18:13:20--  https://api.openai.com/
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 404 NOT FOUND
2023-03-29 18:13:21 ERROR 404: NOT FOUND.

如果收不到,就说明你的代理问题(比如一元鸡汤全被BAN了)。

总之,本地测试通过后,再上传配置到服务器,覆盖 ~/.config/clash/config.yaml

commented

虚拟机部署,运行app.py成功,按照博主视频去配置的web端。但是对话显示“连接不到网络”
日志显示
Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f28cda2da00>: Failed to establish a new connection: [Errno 111] Connection refused')))
[WARNING][2023-03-31 04:36:07][log.py:39] - [CHATGPT] APIConnection failed

commented

如果有使用wsl2的Linux子系统的注意设置代理的ip不是127.0.0.1,使用下面命令获得该ip
cat /etc/resolv.conf #执行后可以看到dns服务器ip,该ip即为宿主window的ip,通过该ip+代理监听端口号设置就好
ipconfig #或者在window下执行该命令获取wsl的ip`

commented

我也是上面这个问题 两天了 #190 image

我也是你这个问题。解决了没~

commented

已解决。

// 20230329174025 
// 使用代理,打开浏览器情况下访问 https://api.openai.com/ 正常情况会显示

{
  "error": {
    "message": "Invalid URL (GET /)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

如果在服务器(全局代理),终端使用 wget 应该是这样

➜  bot-on-anything git:(master) wget https://api.openai.com
--2023-03-29 18:13:20--  https://api.openai.com/
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 404 NOT FOUND
2023-03-29 18:13:21 ERROR 404: NOT FOUND.

如果收不到,就说明你的代理问题(比如一元鸡汤全被BAN了)。

总之,本地测试通过后,再上传配置到服务器,覆盖 ~/.config/clash/config.yaml

我和你一样,代理是没问题的,但是会出现#56 (comment) 这个情况

我用的是AWS的ECS新加坡可用区,理论上应该是可以访问的,但在挂载到公众号的时候一直显示无法访问是什么情况?我自己改了一下Wechat_MP的端口为8080就可以,但公众号是不能用8080的

我用的是AWS的ECS新加坡可用区,理论上应该是可以访问的,但在挂载到公众号的时候一直显示无法访问是什么情况?我自己改了一下Wechat_MP的端口为8080就可以,但公众号是不能用8080的

兄弟我也用的AWS,同样问题,解决了吗?

commented
commented
commented

我解决了 wilson_sec @.***

---原始邮件--- 发件人: @.> 发送时间: 2023年4月2日(周日) 中午12:17 收件人: @.>; 抄送: "Ni @.@.>; 主题: Re: [zhayujie/bot-on-anything] OpenAI接口连接失败问题在这讨论 (Issue #56) 我也是上面这个问题 两天了 #190 我也是你这个问题。解决了没~ — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

怎么解决的

使用这个项目https://github.com/x-dr/chatgptProxyAPI,在Cloudflare上搭建了一个代理转发云函数,请问如何和本项目结合呢

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

commented

aaf5e5601c839568902634d7b7a0b68

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

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

你启动的公众号通道

服务器上跑了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"

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

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

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

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

commented

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

commented

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

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

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

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

commented

@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

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

commented

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

commented

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

commented

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

commented

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

commented

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

commented

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

commented

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

commented

代理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

commented

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

commented

还是拿不到回复,完整的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`

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

commented

解决了 谢谢大佬

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

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

commented

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

几种可能的方案:

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

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

几种可能的方案:

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

2.开代理:

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

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

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

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