Compare commits
4 Commits
v0.5.0-alp
...
v0.5.1-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c134604cee | ||
|
|
929e43ef81 | ||
|
|
dce8bbe1ca | ||
|
|
bc2f48b1f2 |
@@ -16,6 +16,14 @@ import (
|
|||||||
|
|
||||||
func testChannel(channel *model.Channel, request ChatRequest) (error, *OpenAIError) {
|
func testChannel(channel *model.Channel, request ChatRequest) (error, *OpenAIError) {
|
||||||
switch channel.Type {
|
switch channel.Type {
|
||||||
|
case common.ChannelTypePaLM:
|
||||||
|
fallthrough
|
||||||
|
case common.ChannelTypeAnthropic:
|
||||||
|
fallthrough
|
||||||
|
case common.ChannelTypeBaidu:
|
||||||
|
fallthrough
|
||||||
|
case common.ChannelTypeZhipu:
|
||||||
|
return errors.New("该渠道类型当前版本不支持测试,请手动测试"), nil
|
||||||
case common.ChannelTypeAzure:
|
case common.ChannelTypeAzure:
|
||||||
request.Model = "gpt-35-turbo"
|
request.Model = "gpt-35-turbo"
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -85,13 +85,14 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
apiType := APITypeOpenAI
|
apiType := APITypeOpenAI
|
||||||
if strings.HasPrefix(textRequest.Model, "claude") {
|
switch channelType {
|
||||||
|
case common.ChannelTypeAnthropic:
|
||||||
apiType = APITypeClaude
|
apiType = APITypeClaude
|
||||||
} else if strings.HasPrefix(textRequest.Model, "ERNIE") {
|
case common.ChannelTypeBaidu:
|
||||||
apiType = APITypeBaidu
|
apiType = APITypeBaidu
|
||||||
} else if strings.HasPrefix(textRequest.Model, "PaLM") {
|
case common.ChannelTypePaLM:
|
||||||
apiType = APITypePaLM
|
apiType = APITypePaLM
|
||||||
} else if strings.HasPrefix(textRequest.Model, "chatglm_") {
|
case common.ChannelTypeZhipu:
|
||||||
apiType = APITypeZhipu
|
apiType = APITypeZhipu
|
||||||
}
|
}
|
||||||
baseURL := common.ChannelBaseURLs[channelType]
|
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
|
fullRequestURL += "?access_token=" + apiKey // TODO: access token expire in 30 days
|
||||||
case APITypePaLM:
|
case APITypePaLM:
|
||||||
fullRequestURL = "https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage"
|
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 := c.Request.Header.Get("Authorization")
|
||||||
apiKey = strings.TrimPrefix(apiKey, "Bearer ")
|
apiKey = strings.TrimPrefix(apiKey, "Bearer ")
|
||||||
fullRequestURL += "?key=" + apiKey
|
fullRequestURL += "?key=" + apiKey
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func SetRelayRouter(router *gin.Engine) {
|
|||||||
modelsRouter := router.Group("/v1/models")
|
modelsRouter := router.Group("/v1/models")
|
||||||
modelsRouter.Use(middleware.TokenAuth())
|
modelsRouter.Use(middleware.TokenAuth())
|
||||||
{
|
{
|
||||||
modelsRouter.GET("/", controller.ListModels)
|
modelsRouter.GET("", controller.ListModels)
|
||||||
modelsRouter.GET("/:model", controller.RetrieveModel)
|
modelsRouter.GET("/:model", controller.RetrieveModel)
|
||||||
}
|
}
|
||||||
relayV1Router := router.Group("/v1")
|
relayV1Router := router.Group("/v1")
|
||||||
|
|||||||
Reference in New Issue
Block a user