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

@@ -235,6 +235,7 @@ const (
ChannelTypeMokaAI = 44 ChannelTypeMokaAI = 44
ChannelTypeVolcEngine = 45 ChannelTypeVolcEngine = 45
ChannelTypeBaiduV2 = 46 ChannelTypeBaiduV2 = 46
ChannelTypeXinference = 47
ChannelTypeDummy // this one is only for count, do not add any channel after this ChannelTypeDummy // this one is only for count, do not add any channel after this
) )
@@ -287,4 +288,5 @@ var ChannelBaseURLs = []string{
"https://api.moka.ai", //44 "https://api.moka.ai", //44
"https://ark.cn-beijing.volces.com", //45 "https://ark.cn-beijing.volces.com", //45
"https://qianfan.baidubce.com", //46 "https://qianfan.baidubce.com", //46
"", //47
} }

View File

@@ -18,6 +18,7 @@ import (
"one-api/relay/channel/lingyiwanwu" "one-api/relay/channel/lingyiwanwu"
"one-api/relay/channel/minimax" "one-api/relay/channel/minimax"
"one-api/relay/channel/moonshot" "one-api/relay/channel/moonshot"
"one-api/relay/channel/xinference"
relaycommon "one-api/relay/common" relaycommon "one-api/relay/common"
"one-api/relay/constant" "one-api/relay/constant"
"strings" "strings"
@@ -251,6 +252,8 @@ func (a *Adaptor) GetModelList() []string {
return lingyiwanwu.ModelList return lingyiwanwu.ModelList
case common.ChannelTypeMiniMax: case common.ChannelTypeMiniMax:
return minimax.ModelList return minimax.ModelList
case common.ChannelTypeXinference:
return xinference.ModelList
default: default:
return ModelList return ModelList
} }
@@ -266,6 +269,8 @@ func (a *Adaptor) GetChannelName() string {
return lingyiwanwu.ChannelName return lingyiwanwu.ChannelName
case common.ChannelTypeMiniMax: case common.ChannelTypeMiniMax:
return minimax.ChannelName return minimax.ChannelName
case common.ChannelTypeXinference:
return xinference.ChannelName
default: default:
return ChannelName 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 APITypeVolcEngine
APITypeBaiduV2 APITypeBaiduV2
APITypeOpenRouter APITypeOpenRouter
APITypeXinference
APITypeDummy // this one is only for count, do not add any channel after this 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 apiType = APITypeBaiduV2
case common.ChannelTypeOpenRouter: case common.ChannelTypeOpenRouter:
apiType = APITypeOpenRouter apiType = APITypeOpenRouter
case common.ChannelTypeXinference:
apiType = APITypeXinference
} }
if apiType == -1 { if apiType == -1 {
return APITypeOpenAI, false return APITypeOpenAI, false

View File

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

View File

@@ -80,11 +80,12 @@ export const CHANNEL_OPTIONS = [
label: 'Google PaLM2' label: 'Google PaLM2'
}, },
{ {
value: 45, value: 47,
color: 'blue', color: 'blue',
label: '字节火山方舟、豆包、DeepSeek通用' label: 'Xinference'
}, },
{ value: 25, color: 'green', label: 'Moonshot' }, { value: 25, color: 'green', label: 'Moonshot' },
{ value: 20, color: 'green', label: 'OpenRouter' },
{ value: 19, color: 'blue', label: '360 智脑' }, { value: 19, color: 'blue', label: '360 智脑' },
{ value: 23, color: 'teal', label: '腾讯混元' }, { value: 23, color: 'teal', label: '腾讯混元' },
{ value: 31, color: 'green', label: '零一万物' }, { value: 31, color: 'green', label: '零一万物' },
@@ -108,5 +109,10 @@ export const CHANNEL_OPTIONS = [
value: 44, value: 44,
color: 'purple', color: 'purple',
label: '嵌入模型MokaAI M3E' label: '嵌入模型MokaAI M3E'
} },
{
value: 45,
color: 'blue',
label: '字节火山方舟、豆包、DeepSeek通用'
},
]; ];