Просмотр исходного кода

fix: 修复 FetchUpstreamModels 函数中 AuthHeader 的使用,确保正确处理 多key聚合的情况

RedwindA 4 месяцев назад
Родитель
Сommit
76d71a032a
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      controller/channel.go

+ 3 - 2
controller/channel.go

@@ -193,10 +193,11 @@ func FetchUpstreamModels(c *gin.Context) {
 
 
 	// 获取响应体 - 根据渠道类型决定是否添加 AuthHeader
 	// 获取响应体 - 根据渠道类型决定是否添加 AuthHeader
 	var body []byte
 	var body []byte
+	key := strings.Split(channel.Key, "\n")[0]
 	if channel.Type == constant.ChannelTypeGemini {
 	if channel.Type == constant.ChannelTypeGemini {
-		body, err = GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key)) // Use AuthHeader since Gemini now forces it
+		body, err = GetResponseBody("GET", url, channel, GetAuthHeader(key)) // Use AuthHeader since Gemini now forces it
 	} else {
 	} else {
-		body, err = GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
+		body, err = GetResponseBody("GET", url, channel, GetAuthHeader(key))
 	}
 	}
 	if err != nil {
 	if err != nil {
 		common.ApiError(c, err)
 		common.ApiError(c, err)