Merge branch 'songquanpeng:main' into refactor-main

This commit is contained in:
ckt 2023-07-25 22:38:59 +08:00 committed by GitHub
commit ccd7a99b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -85,13 +85,14 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
}
}
apiType := APITypeOpenAI
if strings.HasPrefix(textRequest.Model, "claude") {
switch channelType {
case common.ChannelTypeAnthropic:
apiType = APITypeClaude
} else if strings.HasPrefix(textRequest.Model, "ERNIE") {
case common.ChannelTypeBaidu:
apiType = APITypeBaidu
} else if strings.HasPrefix(textRequest.Model, "PaLM") {
case common.ChannelTypePaLM:
apiType = APITypePaLM
} else if strings.HasPrefix(textRequest.Model, "chatglm_") {
case common.ChannelTypeZhipu:
apiType = APITypeZhipu
}
baseURL := common.ChannelBaseURLs[channelType]
@ -140,6 +141,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
fullRequestURL += "?access_token=" + apiKey // TODO: access token expire in 30 days
case APITypePaLM:
fullRequestURL = "https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage"
if baseURL != "" {
fullRequestURL = fmt.Sprintf("%s/v1beta2/models/chat-bison-001:generateMessage", baseURL)
}
apiKey := c.Request.Header.Get("Authorization")
apiKey = strings.TrimPrefix(apiKey, "Bearer ")
fullRequestURL += "?key=" + apiKey

View File

@ -12,7 +12,7 @@ func SetRelayRouter(router *gin.Engine) {
modelsRouter := router.Group("/v1/models")
modelsRouter.Use(middleware.TokenAuth())
{
modelsRouter.GET("/", controller.ListModels)
modelsRouter.GET("", controller.ListModels)
modelsRouter.GET("/:model", controller.RetrieveModel)
}
relayV1Router := router.Group("/v1")