File tree 2 files changed +15
-3
lines changed
code/services/loadbalancer
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 1
1
package loadbalancer
2
2
3
3
import (
4
+ "fmt"
5
+ "math/rand"
4
6
"sync"
7
+ "time"
5
8
)
6
9
7
10
type API struct {
@@ -36,7 +39,12 @@ func (lb *LoadBalancer) GetAPI() *API {
36
39
}
37
40
}
38
41
if len (availableAPIs ) == 0 {
39
- return nil
42
+ //随机复活一个
43
+ fmt .Printf ("No available API, revive one randomly\n " )
44
+ rand .Seed (time .Now ().UnixNano ())
45
+ index := rand .Intn (len (lb .apis ))
46
+ lb .apis [index ].Available = true
47
+ return lb .apis [index ]
40
48
}
41
49
42
50
selectedAPI := availableAPIs [0 ]
Original file line number Diff line number Diff line change @@ -208,10 +208,14 @@ docker run -d --name feishu-chatgpt -p 9000:9000 \
208
208
--env BOT_NAME=chatGpt \
209
209
--env OPENAI_KEY=" sk-xxx1,sk-xxx2,sk-xxx3" \
210
210
--env API_URL=" https://api.openai.com" \
211
- --env HTTP_PROXY=" http://host.docker.internal:7890 " \
211
+ --env HTTP_PROXY=" " \
212
212
feishu-chatgpt:latest
213
213
```
214
-
214
+ 注意:
215
+ - ` BOT_NAME ` 为飞书机器人名称,例如 ` chatGpt `
216
+ - ` OPENAI_KEY ` 为openai key,多个key用逗号分隔,例如 ` sk-xxx1,sk-xxx2,sk-xxx3 `
217
+ - ` HTTP_PROXY ` 为宿主机的proxy地址,例如 ` http://host.docker.internal:7890 `
218
+ - ` API_URL ` 为openai api 接口地址,例如 ` https://api.openai.com ` , 没有反向代理的话,可以不用设置
215
219
---
216
220
217
221
小白简易化 docker 部署
You can’t perform that action at this time.
0 commit comments