File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
code/services/loadbalancer Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 11package loadbalancer
22
33import (
4+ "fmt"
5+ "math/rand"
46 "sync"
7+ "time"
58)
69
710type API struct {
@@ -36,7 +39,12 @@ func (lb *LoadBalancer) GetAPI() *API {
3639 }
3740 }
3841 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 ]
4048 }
4149
4250 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 \
208208--env BOT_NAME=chatGpt \
209209--env OPENAI_KEY=" sk-xxx1,sk-xxx2,sk-xxx3" \
210210--env API_URL=" https://api.openai.com" \
211- --env HTTP_PROXY=" http://host.docker.internal:7890 " \
211+ --env HTTP_PROXY=" " \
212212feishu-chatgpt:latest
213213```
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 ` , 没有反向代理的话,可以不用设置
215219---
216220
217221小白简易化 docker 部署
You can’t perform that action at this time.
0 commit comments