mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-08 18:23:45 +08:00
尽量使用同一个代理访问,如果挂了再使用下一个
This commit is contained in:
@@ -15,5 +15,6 @@
|
||||
* [ ] 嵌入 AI 绘画功能,支持根据描述词生成图片
|
||||
* [x] 点卡用完之后,提示加入知识星球
|
||||
* [ ] 增加 Buffer 层,将相同的问题答案缓存起来,相同问题直接返回答案。
|
||||
* [ ] 界面改版,支持创建会话功能,支持发语音
|
||||
* [x] 允许修改角色训练数据
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ func (s *Server) sendMessage(session types.ChatSession, role types.ChatRole, pro
|
||||
time.Sleep(time.Second)
|
||||
continue
|
||||
}
|
||||
logger.Infof("Use API KEY: %s", apiKey)
|
||||
logger.Infof("Use API KEY: %s, PROXY: %s", apiKey, proxyURL)
|
||||
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
|
||||
response, err = client.Do(request)
|
||||
if err == nil {
|
||||
@@ -222,11 +222,14 @@ func (s *Server) sendMessage(session types.ChatSession, role types.ChatRole, pro
|
||||
useMsg := types.Message{Role: "user", Content: prompt}
|
||||
context = append(context, useMsg)
|
||||
message.Content = strings.Join(contents, "")
|
||||
context = append(context, message)
|
||||
|
||||
// 更新上下文消息
|
||||
s.ChatContexts[ctxKey] = types.ChatContext{
|
||||
Messages: context,
|
||||
LastAccessTime: time.Now().Unix(),
|
||||
if s.Config.Chat.EnableContext {
|
||||
context = append(context, message)
|
||||
s.ChatContexts[ctxKey] = types.ChatContext{
|
||||
Messages: context,
|
||||
LastAccessTime: time.Now().Unix(),
|
||||
}
|
||||
}
|
||||
|
||||
// 追加历史消息
|
||||
@@ -261,7 +264,7 @@ func (s *Server) getApiKey(failedKey string) string {
|
||||
|
||||
keys = append(keys, v)
|
||||
}
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.NewSource(time.Now().UnixNano())
|
||||
if len(keys) > 0 {
|
||||
key := keys[rand.Intn(len(keys))]
|
||||
s.ApiKeyAccessStat[key] = time.Now().Unix()
|
||||
|
||||
@@ -354,7 +354,7 @@ func (s *Server) SetChatRoleHandle(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
role, err := GetChatRole(data.Key)
|
||||
_, err = GetChatRole(data.Key)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, types.BizVo{Code: types.Failed, Message: "Role key not exists"})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user