CaIon пре 2 година
родитељ
комит
3c3c53051d

+ 3 - 3
common/constants.go

@@ -238,7 +238,7 @@ var ChannelBaseURLs = []string{
 	"https://api.aiproxy.io",            // 21
 	"https://fastgpt.run/api/openapi",   // 22
 	"https://hunyuan.cloud.tencent.com", //23
-	"",                                  //24
-	"https://api.moonshot.cn",           //25
-	"https://open.bigmodel.cn",          //26
+	"https://generativelanguage.googleapis.com", //24
+	"https://api.moonshot.cn",                   //25
+	"https://open.bigmodel.cn",                  //26
 }

+ 3 - 0
relay/channel/gemini/adaptor.go

@@ -20,6 +20,9 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIReq
 
 func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
 	version := "v1"
+	if info.ApiVersion != "" {
+		version = info.ApiVersion
+	}
 	action := "generateContent"
 	if info.IsStream {
 		action = "streamGenerateContent"

+ 1 - 1
relay/common/relay_info.go

@@ -57,7 +57,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
 		info.BaseUrl = common.ChannelBaseURLs[channelType]
 	}
 	if info.ChannelType == common.ChannelTypeAzure {
-		info.ApiVersion = GetAzureAPIVersion(c)
+		info.ApiVersion = GetAPIVersion(c)
 	}
 	return info
 }

+ 0 - 9
relay/common/relay_utils.go

@@ -66,12 +66,3 @@ func GetAPIVersion(c *gin.Context) string {
 	}
 	return apiVersion
 }
-
-func GetAzureAPIVersion(c *gin.Context) string {
-	query := c.Request.URL.Query()
-	apiVersion := query.Get("api-version")
-	if apiVersion == "" {
-		apiVersion = c.GetString("api_version")
-	}
-	return apiVersion
-}

+ 1 - 1
relay/relay-audio.go

@@ -113,7 +113,7 @@ func AudioHelper(c *gin.Context, relayMode int) *dto.OpenAIErrorWithStatusCode {
 	fullRequestURL := relaycommon.GetFullRequestURL(baseURL, requestURL, channelType)
 	if relayMode == relayconstant.RelayModeAudioTranscription && channelType == common.ChannelTypeAzure {
 		// https://learn.microsoft.com/en-us/azure/ai-services/openai/whisper-quickstart?tabs=command-line#rest-api
-		apiVersion := relaycommon.GetAzureAPIVersion(c)
+		apiVersion := relaycommon.GetAPIVersion(c)
 		fullRequestURL = fmt.Sprintf("%s/openai/deployments/%s/audio/transcriptions?api-version=%s", baseURL, audioRequest.Model, apiVersion)
 	}