mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-19 08:56:37 +08:00
fix: fix gemini
This commit is contained in:
parent
6a83c8ad86
commit
3c3c53051d
@ -238,7 +238,7 @@ var ChannelBaseURLs = []string{
|
|||||||
"https://api.aiproxy.io", // 21
|
"https://api.aiproxy.io", // 21
|
||||||
"https://fastgpt.run/api/openapi", // 22
|
"https://fastgpt.run/api/openapi", // 22
|
||||||
"https://hunyuan.cloud.tencent.com", //23
|
"https://hunyuan.cloud.tencent.com", //23
|
||||||
"", //24
|
"https://generativelanguage.googleapis.com", //24
|
||||||
"https://api.moonshot.cn", //25
|
"https://api.moonshot.cn", //25
|
||||||
"https://open.bigmodel.cn", //26
|
"https://open.bigmodel.cn", //26
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIReq
|
|||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
version := "v1"
|
version := "v1"
|
||||||
|
if info.ApiVersion != "" {
|
||||||
|
version = info.ApiVersion
|
||||||
|
}
|
||||||
action := "generateContent"
|
action := "generateContent"
|
||||||
if info.IsStream {
|
if info.IsStream {
|
||||||
action = "streamGenerateContent"
|
action = "streamGenerateContent"
|
||||||
|
@ -57,7 +57,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
|
|||||||
info.BaseUrl = common.ChannelBaseURLs[channelType]
|
info.BaseUrl = common.ChannelBaseURLs[channelType]
|
||||||
}
|
}
|
||||||
if info.ChannelType == common.ChannelTypeAzure {
|
if info.ChannelType == common.ChannelTypeAzure {
|
||||||
info.ApiVersion = GetAzureAPIVersion(c)
|
info.ApiVersion = GetAPIVersion(c)
|
||||||
}
|
}
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
@ -66,12 +66,3 @@ func GetAPIVersion(c *gin.Context) string {
|
|||||||
}
|
}
|
||||||
return apiVersion
|
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
|
|
||||||
}
|
|
||||||
|
@ -113,7 +113,7 @@ func AudioHelper(c *gin.Context, relayMode int) *dto.OpenAIErrorWithStatusCode {
|
|||||||
fullRequestURL := relaycommon.GetFullRequestURL(baseURL, requestURL, channelType)
|
fullRequestURL := relaycommon.GetFullRequestURL(baseURL, requestURL, channelType)
|
||||||
if relayMode == relayconstant.RelayModeAudioTranscription && channelType == common.ChannelTypeAzure {
|
if relayMode == relayconstant.RelayModeAudioTranscription && channelType == common.ChannelTypeAzure {
|
||||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/whisper-quickstart?tabs=command-line#rest-api
|
// 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)
|
fullRequestURL = fmt.Sprintf("%s/openai/deployments/%s/audio/transcriptions?api-version=%s", baseURL, audioRequest.Model, apiVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user