chore: opt video channel and platform

This commit is contained in:
feitianbubu
2025-07-22 17:36:38 +08:00
parent 057e551059
commit 7bc9192f3f
8 changed files with 45 additions and 66 deletions

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"
@@ -34,6 +34,7 @@ import (
"one-api/relay/channel/xunfei"
"one-api/relay/channel/zhipu"
"one-api/relay/channel/zhipu_4v"
"strconv"
)
func GetAdaptor(apiType int) channel.Adaptor {
@@ -100,16 +101,28 @@ func GetAdaptor(apiType int) channel.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{}
}
}
return nil
}