Skip to content

Commit 82a8aec

Browse files
committed
Merge branch 'feat_support_proxy'
2 parents a72b1b4 + fefea3b commit 82a8aec

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

code/services/loadbalancer/loadbalancer.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package loadbalancer
22

33
import (
4+
"fmt"
5+
"math/rand"
46
"sync"
7+
"time"
58
)
69

710
type 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]

readme.md

+6-2
Original file line numberDiff line numberDiff 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="" \
212212
feishu-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 部署

0 commit comments

Comments
 (0)