Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持http代理地址 #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shawnfinelee
Copy link

No description provided.

@MgCI2
Copy link

MgCI2 commented Jun 8, 2023

你好,我想问问在那些地方添加api的http代理地址,我怎么调都是报错
image

@Armor-cn
Copy link

Armor-cn commented Jul 1, 2023

只要你网络能直接调通openai接口,这代理没啥用,直接那那行代码去掉就行或者自己写个重载函数也行

@MgCI2
Copy link

MgCI2 commented Jul 25, 2023

我打算部署到国内😅

@496672097
Copy link

各位代理可以按照以下修改:gpt.go
66行左右!
apiKey := config.LoadConfig().ApiKey
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+apiKey)
proxyURL, _ := url.Parse("http://127.0.0.1:7890")
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
},
}
response, err := client.Do(req)

@linweiliang02
Copy link

2023/10/28 19:29:00 扫码成功,请在手机上确认登录
2023/10/28 19:29:11 登录成功
2023/10/28 19:29:12 RetCode:0 Selector:2
2023/10/28 19:29:12 hadler Received msg :
2023/10/28 19:29:12 hadler Received msg :
2023/10/28 19:29:12 RetCode:0 Selector:2
2023/10/28 19:29:12 hadler Received msg :
2023/10/28 19:29:13 RetCode:0 Selector:2
2023/10/28 19:29:13 hadler Received msg :
2023/10/28 19:29:16 RetCode:0 Selector:2
2023/10/28 19:29:17 RetCode:0 Selector:2
2023/10/28 19:29:17 hadler Received msg :
2023/10/28 19:29:31 RetCode:0 Selector:2
2023/10/28 19:29:31 hadler Received msg :
2023/10/28 19:29:49 RetCode:0 Selector:2
2023/10/28 19:29:50 hadler Received msg : 你好
2023/10/28 19:29:52 Received User Meeee Text Msg : 你好
panic: Post "https://api.openai.com/v1/chat/completions": proxyconnect tcp: dial tcp 127.0.0.1:7890: connectex: No connection could be made because the target machine actively refused it.

goroutine 42 [running]:
github.com/poorjobless/wechatbot/chatgpt.Completions({0xc0000ea9c6, 0x9}, {0xc000095340, 0x6})
D:/10-28/wechatbot-main/chatgpt/chatgpt.go:31 +0x325
github.com/poorjobless/wechatbot/handlers.(*UserMessageHandler).ReplyText(0xc0000e9db0?, 0xc000272780)
D:/10-28/wechatbot-main/handlers/user_msg_handler.go:46 +0x1bd
github.com/poorjobless/wechatbot/handlers.(*UserMessageHandler).handle(0x3aeea0?, 0xc00001d440?)
D:/10-28/wechatbot-main/handlers/user_msg_handler.go:21 +0x25
github.com/poorjobless/wechatbot/handlers.Handler(0xc000272780)
D:/10-28/wechatbot-main/handlers/handler.go:54 +0x282
github.com/eatmoreapple/openwechat.(*Bot).syncCheck(0xc0001181c0)
C:/Users/linweiliang02/go/pkg/mod/github.com/eatmoreapple/[email protected]/bot.go:269 +0x227
github.com/eatmoreapple/openwechat.(*Bot).WebInit.func1()
C:/Users/linweiliang02/go/pkg/mod/github.com/eatmoreapple/[email protected]/bot.go:190 +0x79
created by github.com/eatmoreapple/openwechat.(*Bot).WebInit in goroutine 1
C:/Users/linweiliang02/go/pkg/mod/github.com/eatmoreapple/[email protected]/bot.go:185 +0x276
exit status 2

你好,这个是什么意思呢

@linweiliang02
Copy link

2023/10/28 19:35:43 Received User Meeee Text Msg : 哈哈
2023/10/28 19:35:43 request gtp json string : {"model":"text-davinci-003","prompt":"哈哈","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}
2023/10/28 19:35:43 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9455->104.18.7.192:443: wsarecv: An existing connection was forcibly closed by the remote host.
2023/10/28 19:35:44 RetCode:0 Selector:2
2023/10/28 19:36:09 RetCode:0 Selector:0
2023/10/28 19:36:10 RetCode:0 Selector:2
2023/10/28 19:36:10 hadler Received msg : 你说什么
2023/10/28 19:36:10 Received User Meeee Text Msg : 你说什么
2023/10/28 19:36:10 request gtp json string : {"model":"text-davinci-003","prompt":"你说什么","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}
2023/10/28 19:36:11 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9508->104.18.6.192:443: wsarecv: An existing connection was forcibly closed by the remote host.
2023/10/28 19:36:11 RetCode:0 Selector:2

你好,这个接口目前不可以使用吗

@linweiliang02
Copy link

我打算部署到国内😅

我想问问目前解决了吗 我遇到了这个问题
request gtp json string : {"model":"text-davinci-003","prompt":"哈喽","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}
2023/10/28 21:33:03 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:41925->104.18.7.192:443: wsarecv: An existing connection was forcibly closed by the remote host.

@Armor-cn
Copy link

Armor-cn commented Oct 28, 2023 via email

@linweiliang02
Copy link

proxyURL, _ := url.Parse("http://127.0.0.1:7890")
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
},

proxyURL, _ := url.Parse("http://127.0.0.1:7890/")
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
},其实就是多了这些对吧 但是会报错呢

@linweiliang02
Copy link

linweiliang02 commented Oct 28, 2023

2023/10/28 19:36:10 request gtp json string : {"model":"text-davinci-003","prompt":"你说什么","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}
2023/10/28 19:36:11 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9508->104.18.6.192:443: wsarecv: An existing connection was forcibly closed by the remote host.
2023/10/28 19:36:11 RetCode:0 Selector:2

目前是报这个错误 是代理的问题吗
2023/10/28 19:36:10 request gtp json string : {"model":"text-davinci-003","prompt":"你说什么","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}
2023/10/28 19:36:11 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9508->104.18.6.192:443: wsarecv: An existing connection was forcibly closed by the remote host.
2023/10/28 19:36:11 RetCode:0 Selector:2

@Armor-cn
Copy link

Armor-cn commented Oct 28, 2023 via email

@linweiliang02
Copy link

可以用的,需要科学上网,才能访问到openai  诚南花已开 @.***  

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年10月28日(星期六) 晚上7:37 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [djun/wechatbot] 支持http代理地址 (PR #8) 2023/10/28 19:35:43 Received User Meeee Text Msg : 哈哈 2023/10/28 19:35:43 request gtp json string : {"model":"text-davinci-003","prompt":"哈哈","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0} 2023/10/28 19:35:43 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9455->104.18.7.192:443: wsarecv: An existing connection was forcibly closed by the remote host. 2023/10/28 19:35:44 RetCode:0 Selector:2 2023/10/28 19:36:09 RetCode:0 Selector:0 2023/10/28 19:36:10 RetCode:0 Selector:2 2023/10/28 19:36:10 hadler Received msg : 你说什么 2023/10/28 19:36:10 Received User Meeee Text Msg : 你说什么 2023/10/28 19:36:10 request gtp json string : {"model":"text-davinci-003","prompt":"你说什么","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0} 2023/10/28 19:36:11 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9508->104.18.6.192:443: wsarecv: An existing connection was forcibly closed by the remote host. 2023/10/28 19:36:11 RetCode:0 Selector:2 你好,这个接口目前不可以使用吗 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

我的网页时可以访问openai的呢

@Armor-cn
Copy link

Armor-cn commented Oct 28, 2023 via email

@Armor-cn
Copy link

Armor-cn commented Oct 28, 2023 via email

@Armor-cn
Copy link

Armor-cn commented Oct 28, 2023 via email

@linweiliang02
Copy link

linweiliang02 commented Oct 28, 2023

使用postman调一下openai的接口,能通,你的服务调用一些问题。在腾讯云上部署,一般响应时间比较长 诚南花已开 @.***  
……
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年10月28日(星期六) 晚上9:53 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [djun/wechatbot] 支持http代理地址 (PR #8) 可以用的,需要科学上网,才能访问到openai  诚南花已开 @.***   … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年10月28日(星期六) 晚上7:37 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [djun/wechatbot] 支持http代理地址 (PR #8) 2023/10/28 19:35:43 Received User Meeee Text Msg : 哈哈 2023/10/28 19:35:43 request gtp json string : {"model":"text-davinci-003","prompt":"哈哈","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0} 2023/10/28 19:35:43 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9455->104.18.7.192:443: wsarecv: An existing connection was forcibly closed by the remote host. 2023/10/28 19:35:44 RetCode:0 Selector:2 2023/10/28 19:36:09 RetCode:0 Selector:0 2023/10/28 19:36:10 RetCode:0 Selector:2 2023/10/28 19:36:10 hadler Received msg : 你说什么 2023/10/28 19:36:10 Received User Meeee Text Msg : 你说什么 2023/10/28 19:36:10 request gtp json string : {"model":"text-davinci-003","prompt":"你说什么","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0} 2023/10/28 19:36:11 gtp request error: Post "https://api.openai.com/v1/completions": read tcp 192.168.10.17:9508->104.18.6.192:443: wsarecv: An existing connection was forcibly closed by the remote host. 2023/10/28 19:36:11 RetCode:0 Selector:2 你好,这个接口目前不可以使用吗 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 我的网页时可以访问openai的呢 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

好的 谢谢
2023/10/28 22:01:42 request gtp json string : {"model":"text-davinci-003","prompt":"哈哈","max_tokens":2048,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}
2023/10/28 22:01:42 gtp request error: Post "https://api.openai.com/v1/completions": proxyconnect tcp: dial tcp 127.0.0.1:7890: connectex: No connection could be made because the target machine actively refused it.

@linweiliang02
Copy link

诚南花已开 @.***  

------------------ 原始邮件 ------------------ 发件人: "djun/wechatbot" @.>; 发送时间: 2023年10月28日(星期六) 晚上9:49 @.>; @.@.>; 主题: Re: [djun/wechatbot] 支持http代理地址 (PR #8) proxyURL, _ := url.Parse("http://127.0.0.1:7890") client := &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyURL(proxyURL), }, proxyURL, _ := url.Parse("http://127.0.0.1:7890/") client := &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyURL(proxyURL), },其实就是多了这些对吧 但是会报错呢 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

您好,方便留个联系方式吗?我这里还是遇到了一些问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants