实现 API Key 负载均衡,修复 WebSocket session 失效问题

This commit is contained in:
RockYang
2023-03-22 13:51:27 +08:00
parent 97acfe57e7
commit 20bdf12180
10 changed files with 118 additions and 42 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin"
"net/http"
"openai/types"
"openai/utils"
"strconv"
)
@@ -91,7 +92,9 @@ func (s *Server) ConfigSetHandle(c *gin.Context) {
}
if token, ok := data["token"]; ok {
s.Config.Tokens = append(s.Config.Tokens, token)
if !utils.ContainsItem(s.Config.Tokens, token) {
s.Config.Tokens = append(s.Config.Tokens, token)
}
}
// 保存配置文件