feat(relay): Add Xinference channel support

This commit is contained in:
1808837298@qq.com
2025-03-12 17:53:46 +08:00
parent 1a2bf8df1f
commit a981e10712
6 changed files with 28 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ import (
"one-api/relay/channel/lingyiwanwu"
"one-api/relay/channel/minimax"
"one-api/relay/channel/moonshot"
"one-api/relay/channel/xinference"
relaycommon "one-api/relay/common"
"one-api/relay/constant"
"strings"
@@ -251,6 +252,8 @@ func (a *Adaptor) GetModelList() []string {
return lingyiwanwu.ModelList
case common.ChannelTypeMiniMax:
return minimax.ModelList
case common.ChannelTypeXinference:
return xinference.ModelList
default:
return ModelList
}
@@ -266,6 +269,8 @@ func (a *Adaptor) GetChannelName() string {
return lingyiwanwu.ChannelName
case common.ChannelTypeMiniMax:
return minimax.ChannelName
case common.ChannelTypeXinference:
return xinference.ChannelName
default:
return ChannelName
}

View File

@@ -0,0 +1,7 @@
package xinference
var ModelList = []string{
"bge-reranker-v2-m3",
}
var ChannelName = "xinference"

View File

@@ -31,6 +31,7 @@ const (
APITypeVolcEngine
APITypeBaiduV2
APITypeOpenRouter
APITypeXinference
APITypeDummy // this one is only for count, do not add any channel after this
)
@@ -89,6 +90,8 @@ func ChannelType2APIType(channelType int) (int, bool) {
apiType = APITypeBaiduV2
case common.ChannelTypeOpenRouter:
apiType = APITypeOpenRouter
case common.ChannelTypeXinference:
apiType = APITypeXinference
}
if apiType == -1 {
return APITypeOpenAI, false

View File

@@ -34,8 +34,6 @@ import (
func GetAdaptor(apiType int) channel.Adaptor {
switch apiType {
//case constant.APITypeAIProxyLibrary:
// return &aiproxy.Adaptor{}
case constant.APITypeAli:
return &ali.Adaptor{}
case constant.APITypeAnthropic:
@@ -86,6 +84,8 @@ func GetAdaptor(apiType int) channel.Adaptor {
return &baidu_v2.Adaptor{}
case constant.APITypeOpenRouter:
return &openrouter.Adaptor{}
case constant.APITypeXinference:
return &openai.Adaptor{}
}
return nil
}