diff --git a/relay/adaptor/alibailian/constants.go b/relay/adaptor/alibailian/constants.go new file mode 100644 index 00000000..947946be --- /dev/null +++ b/relay/adaptor/alibailian/constants.go @@ -0,0 +1,20 @@ +package alibailian + +// https://help.aliyun.com/zh/model-studio/getting-started/models + +var ModelList = []string{ + "qwen-turbo", + "qwen-plus", + "qwen-long", + "qwen-max", + "qwen-coder-plus", + "qwen-coder-plus-latest", + "qwen-coder-turbo", + "qwen-coder-turbo-latest", + "qwen-mt-plus", + "qwen-mt-turbo", + "qwq-32b-preview", + + "deepseek-r1", + "deepseek-v3", +} diff --git a/relay/adaptor/alibailian/main.go b/relay/adaptor/alibailian/main.go new file mode 100644 index 00000000..7839e12d --- /dev/null +++ b/relay/adaptor/alibailian/main.go @@ -0,0 +1,19 @@ +package alibailian + +import ( + "fmt" + + "github.com/songquanpeng/one-api/relay/meta" + "github.com/songquanpeng/one-api/relay/relaymode" +) + +func GetRequestURL(meta *meta.Meta) (string, error) { + switch meta.Mode { + case relaymode.ChatCompletions: + return fmt.Sprintf("%s/compatible-mode/v1/chat/completions", meta.BaseURL), nil + case relaymode.Embeddings: + return fmt.Sprintf("%s/compatible-mode/v1/embeddings", meta.BaseURL), nil + default: + } + return "", fmt.Errorf("unsupported relay mode %d for ali bailian", meta.Mode) +} diff --git a/relay/adaptor/openai/adaptor.go b/relay/adaptor/openai/adaptor.go index 3907a0db..4eea25d4 100644 --- a/relay/adaptor/openai/adaptor.go +++ b/relay/adaptor/openai/adaptor.go @@ -10,6 +10,7 @@ import ( "github.com/gin-gonic/gin" "github.com/songquanpeng/one-api/relay/adaptor" + "github.com/songquanpeng/one-api/relay/adaptor/alibailian" "github.com/songquanpeng/one-api/relay/adaptor/baiduv2" "github.com/songquanpeng/one-api/relay/adaptor/doubao" "github.com/songquanpeng/one-api/relay/adaptor/minimax" @@ -56,6 +57,8 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) { return novita.GetRequestURL(meta) case channeltype.BaiduV2: return baiduv2.GetRequestURL(meta) + case channeltype.AliBailian: + return alibailian.GetRequestURL(meta) default: return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil } diff --git a/relay/adaptor/openai/compatible.go b/relay/adaptor/openai/compatible.go index af65365a..36c22a74 100644 --- a/relay/adaptor/openai/compatible.go +++ b/relay/adaptor/openai/compatible.go @@ -2,6 +2,7 @@ package openai import ( "github.com/songquanpeng/one-api/relay/adaptor/ai360" + "github.com/songquanpeng/one-api/relay/adaptor/alibailian" "github.com/songquanpeng/one-api/relay/adaptor/baichuan" "github.com/songquanpeng/one-api/relay/adaptor/baiduv2" "github.com/songquanpeng/one-api/relay/adaptor/deepseek" @@ -79,6 +80,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) { return "xunfeiv2", xunfeiv2.ModelList case channeltype.OpenRouter: return "openrouter", openrouter.ModelList + case channeltype.AliBailian: + return "alibailian", alibailian.ModelList default: return "openai", ModelList } diff --git a/relay/channeltype/define.go b/relay/channeltype/define.go index ff704149..76b549e1 100644 --- a/relay/channeltype/define.go +++ b/relay/channeltype/define.go @@ -50,5 +50,6 @@ const ( Replicate BaiduV2 XunfeiV2 + AliBailian Dummy ) diff --git a/relay/channeltype/url.go b/relay/channeltype/url.go index 59423350..a8acd967 100644 --- a/relay/channeltype/url.go +++ b/relay/channeltype/url.go @@ -50,6 +50,7 @@ var ChannelBaseURLs = []string{ "https://api.replicate.com/v1/models/", // 46 "https://qianfan.baidubce.com", // 47 "https://spark-api-open.xf-yun.com", // 48 + "https://dashscope.aliyuncs.com", // 49 } func init() { diff --git a/web/default/src/constants/channel.constants.js b/web/default/src/constants/channel.constants.js index f6c7d61c..26ffd0c4 100644 --- a/web/default/src/constants/channel.constants.js +++ b/web/default/src/constants/channel.constants.js @@ -1,12 +1,12 @@ export const CHANNEL_OPTIONS = [ - {key: 1, text: 'OpenAI', value: 1, color: 'green'}, - {key: 14, text: 'Anthropic Claude', value: 14, color: 'black'}, - {key: 33, text: 'AWS', value: 33, color: 'black'}, - {key: 3, text: 'Azure OpenAI', value: 3, color: 'olive'}, - {key: 11, text: 'Google PaLM2', value: 11, color: 'orange'}, - {key: 24, text: 'Google Gemini', value: 24, color: 'orange'}, - {key: 28, text: 'Mistral AI', value: 28, color: 'orange'}, - {key: 41, text: 'Novita', value: 41, color: 'purple'}, + {key: 1, text: 'OpenAI', value: 1, color: 'green'}, + {key: 14, text: 'Anthropic Claude', value: 14, color: 'black'}, + {key: 33, text: 'AWS', value: 33, color: 'black'}, + {key: 3, text: 'Azure OpenAI', value: 3, color: 'olive'}, + {key: 11, text: 'Google PaLM2', value: 11, color: 'orange'}, + {key: 24, text: 'Google Gemini', value: 24, color: 'orange'}, + {key: 28, text: 'Mistral AI', value: 28, color: 'orange'}, + {key: 41, text: 'Novita', value: 41, color: 'purple'}, { key: 40, text: '字节火山引擎', @@ -28,7 +28,14 @@ export const CHANNEL_OPTIONS = [ color: 'blue', tip: '请前往此处获取 API Key,注意本渠道仅支持推理服务 V2相关模型', }, - {key: 17, text: '阿里通义千问', value: 17, color: 'orange'}, + { + key: 17, + text: '阿里通义千问', + value: 17, + color: 'orange', + tip: '如需使用阿里云百炼,请使用阿里云百炼渠道', + }, + {key: 49, text: '阿里云百炼', value: 49, color: 'orange'}, { key: 18, text: '讯飞星火认知', @@ -43,38 +50,38 @@ export const CHANNEL_OPTIONS = [ color: 'blue', tip: 'HTTP 版本的讯飞接口,前往此处获取 HTTP 服务接口认证密钥', }, - {key: 16, text: '智谱 ChatGLM', value: 16, color: 'violet'}, - {key: 19, text: '360 智脑', value: 19, color: 'blue'}, - {key: 25, text: 'Moonshot AI', value: 25, color: 'black'}, - {key: 23, text: '腾讯混元', value: 23, color: 'teal'}, - {key: 26, text: '百川大模型', value: 26, color: 'orange'}, - {key: 27, text: 'MiniMax', value: 27, color: 'red'}, - {key: 29, text: 'Groq', value: 29, color: 'orange'}, - {key: 30, text: 'Ollama', value: 30, color: 'black'}, - {key: 31, text: '零一万物', value: 31, color: 'green'}, - {key: 32, text: '阶跃星辰', value: 32, color: 'blue'}, - {key: 34, text: 'Coze', value: 34, color: 'blue'}, - {key: 35, text: 'Cohere', value: 35, color: 'blue'}, - {key: 36, text: 'DeepSeek', value: 36, color: 'black'}, - {key: 37, text: 'Cloudflare', value: 37, color: 'orange'}, - {key: 38, text: 'DeepL', value: 38, color: 'black'}, - {key: 39, text: 'together.ai', value: 39, color: 'blue'}, - {key: 42, text: 'VertexAI', value: 42, color: 'blue'}, - {key: 43, text: 'Proxy', value: 43, color: 'blue'}, - {key: 44, text: 'SiliconFlow', value: 44, color: 'blue'}, - {key: 45, text: 'xAI', value: 45, color: 'blue'}, - {key: 46, text: 'Replicate', value: 46, color: 'blue'}, - {key: 8, text: '自定义渠道', value: 8, color: 'pink'}, - {key: 22, text: '知识库:FastGPT', value: 22, color: 'blue'}, - {key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple'}, + {key: 16, text: '智谱 ChatGLM', value: 16, color: 'violet'}, + {key: 19, text: '360 智脑', value: 19, color: 'blue'}, + {key: 25, text: 'Moonshot AI', value: 25, color: 'black'}, + {key: 23, text: '腾讯混元', value: 23, color: 'teal'}, + {key: 26, text: '百川大模型', value: 26, color: 'orange'}, + {key: 27, text: 'MiniMax', value: 27, color: 'red'}, + {key: 29, text: 'Groq', value: 29, color: 'orange'}, + {key: 30, text: 'Ollama', value: 30, color: 'black'}, + {key: 31, text: '零一万物', value: 31, color: 'green'}, + {key: 32, text: '阶跃星辰', value: 32, color: 'blue'}, + {key: 34, text: 'Coze', value: 34, color: 'blue'}, + {key: 35, text: 'Cohere', value: 35, color: 'blue'}, + {key: 36, text: 'DeepSeek', value: 36, color: 'black'}, + {key: 37, text: 'Cloudflare', value: 37, color: 'orange'}, + {key: 38, text: 'DeepL', value: 38, color: 'black'}, + {key: 39, text: 'together.ai', value: 39, color: 'blue'}, + {key: 42, text: 'VertexAI', value: 42, color: 'blue'}, + {key: 43, text: 'Proxy', value: 43, color: 'blue'}, + {key: 44, text: 'SiliconFlow', value: 44, color: 'blue'}, + {key: 45, text: 'xAI', value: 45, color: 'blue'}, + {key: 46, text: 'Replicate', value: 46, color: 'blue'}, + {key: 8, text: '自定义渠道', value: 8, color: 'pink'}, + {key: 22, text: '知识库:FastGPT', value: 22, color: 'blue'}, + {key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple'}, {key: 20, text: 'OpenRouter', value: 20, color: 'black'}, - {key: 2, text: '代理:API2D', value: 2, color: 'blue'}, - {key: 5, text: '代理:OpenAI-SB', value: 5, color: 'brown'}, - {key: 7, text: '代理:OhMyGPT', value: 7, color: 'purple'}, - {key: 10, text: '代理:AI Proxy', value: 10, color: 'purple'}, - {key: 4, text: '代理:CloseAI', value: 4, color: 'teal'}, - {key: 6, text: '代理:OpenAI Max', value: 6, color: 'violet'}, - {key: 9, text: '代理:AI.LS', value: 9, color: 'yellow'}, - {key: 12, text: '代理:API2GPT', value: 12, color: 'blue'}, - {key: 13, text: '代理:AIGC2D', value: 13, color: 'purple'}, + {key: 2, text: '代理:API2D', value: 2, color: 'blue'}, + {key: 5, text: '代理:OpenAI-SB', value: 5, color: 'brown'}, + {key: 7, text: '代理:OhMyGPT', value: 7, color: 'purple'}, + {key: 10, text: '代理:AI Proxy', value: 10, color: 'purple'}, + {key: 4, text: '代理:CloseAI', value: 4, color: 'teal'}, + {key: 6, text: '代理:OpenAI Max', value: 6, color: 'violet'}, + {key: 9, text: '代理:AI.LS', value: 9, color: 'yellow'}, + {key: 12, text: '代理:API2GPT', value: 12, color: 'blue'}, + {key: 13, text: '代理:AIGC2D', value: 13, color: 'purple'}, ];