浏览代码

feat(relay): Add Xinference channel support

[email protected] 9 月之前
父节点
当前提交
a981e10712

+ 2 - 0
common/constants.go

@@ -235,6 +235,7 @@ const (
 	ChannelTypeMokaAI         = 44
 	ChannelTypeVolcEngine     = 45
 	ChannelTypeBaiduV2        = 46
+	ChannelTypeXinference     = 47
 	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://ark.cn-beijing.volces.com",         //45
 	"https://qianfan.baidubce.com",              //46
+	"",                                          //47
 }

+ 5 - 0
relay/channel/openai/adaptor.go

@@ -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
 	}

+ 7 - 0
relay/channel/xinference/constant.go

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

+ 3 - 0
relay/constant/api_type.go

@@ -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

+ 2 - 2
relay/relay_adaptor.go

@@ -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
 }

+ 9 - 3
web/src/constants/channel.constants.js

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