Merge branches 'main' and 'main' of github.com:danding5/new-api

# Conflicts:
#	common/api_type.go
#	constant/api_type.go
#	constant/channel.go
#	relay/relay_adaptor.go
#	web/src/constants/channel.constants.js
This commit is contained in:
DD
2025-09-10 18:33:42 +08:00
597 changed files with 61068 additions and 26580 deletions
+27 -8
View File
@@ -1,8 +1,8 @@
package relay
import (
"github.com/gin-gonic/gin"
"one-api/constant"
commonconstant "one-api/constant"
"one-api/relay/channel"
"one-api/relay/channel/ali"
"one-api/relay/channel/aws"
@@ -19,6 +19,7 @@ import (
"one-api/relay/channel/jina"
"one-api/relay/channel/mistral"
"one-api/relay/channel/mokaai"
"one-api/relay/channel/moonshot"
"one-api/relay/channel/ollama"
"one-api/relay/channel/openai"
"one-api/relay/channel/palm"
@@ -27,6 +28,7 @@ import (
taskjimeng "one-api/relay/channel/task/jimeng"
"one-api/relay/channel/task/kling"
"one-api/relay/channel/task/suno"
taskVidu "one-api/relay/channel/task/vidu"
"one-api/relay/channel/tencent"
"one-api/relay/channel/vertex"
"one-api/relay/channel/volcengine"
@@ -34,7 +36,8 @@ import (
"one-api/relay/channel/xunfei"
"one-api/relay/channel/zhipu"
"one-api/relay/channel/zhipu_4v"
"one-api/relay/channel/submodel"
"strconv"
"one-api/relay/channel/submodel"
)
func GetAdaptor(apiType int) channel.Adaptor {
@@ -97,22 +100,38 @@ func GetAdaptor(apiType int) channel.Adaptor {
return &coze.Adaptor{}
case constant.APITypeJimeng:
return &jimeng.Adaptor{}
case constant.APITypeMoonshot:
return &moonshot.Adaptor{} // Moonshot uses Claude API
case constant.APITypeSubmodel:
return &submodel.Adaptor{}
}
return nil
}
func GetTaskAdaptor(platform commonconstant.TaskPlatform) channel.TaskAdaptor {
func GetTaskPlatform(c *gin.Context) constant.TaskPlatform {
channelType := c.GetInt("channel_type")
if channelType > 0 {
return constant.TaskPlatform(strconv.Itoa(channelType))
}
return constant.TaskPlatform(c.GetString("platform"))
}
func GetTaskAdaptor(platform constant.TaskPlatform) channel.TaskAdaptor {
switch platform {
//case constant.APITypeAIProxyLibrary:
// return &aiproxy.Adaptor{}
case commonconstant.TaskPlatformSuno:
case constant.TaskPlatformSuno:
return &suno.TaskAdaptor{}
case commonconstant.TaskPlatformKling:
return &kling.TaskAdaptor{}
case commonconstant.TaskPlatformJimeng:
return &taskjimeng.TaskAdaptor{}
}
if channelType, err := strconv.ParseInt(string(platform), 10, 64); err == nil {
switch channelType {
case constant.ChannelTypeKling:
return &kling.TaskAdaptor{}
case constant.ChannelTypeJimeng:
return &taskjimeng.TaskAdaptor{}
case constant.ChannelTypeVidu:
return &taskVidu.TaskAdaptor{}
}
}
return nil
}