From be9eb59fbbcfb87d56f1e9fed7fbabd37c1d96bb Mon Sep 17 00:00:00 2001 From: JustSong Date: Thu, 14 Mar 2024 23:11:36 +0800 Subject: [PATCH] feat: support lingyiwanwu --- README.md | 1 + common/constants.go | 2 ++ common/model-ratio.go | 4 ++++ relay/channel/lingyiwanwu/constants.go | 9 +++++++++ relay/channel/openai/compatible.go | 4 ++++ web/berry/src/constants/ChannelConstants.js | 6 ++++++ web/berry/src/views/Channel/type/Config.js | 3 +++ web/default/src/constants/channel.constants.js | 1 + 8 files changed, 30 insertions(+) create mode 100644 relay/channel/lingyiwanwu/constants.go diff --git a/README.md b/README.md index 8f6c6bf7..0ba659c4 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用 + [x] [MINIMAX](https://api.minimax.chat/) + [x] [Groq](https://wow.groq.com/) + [x] [Ollama](https://github.com/ollama/ollama) + + [x] [零一万物](https://platform.lingyiwanwu.com/) 2. 支持配置镜像以及众多[第三方代理服务](https://iamazing.cn/page/openai-api-third-party-services)。 3. 支持通过**负载均衡**的方式访问多个渠道。 4. 支持 **stream 模式**,可以通过流式传输实现打字机效果。 diff --git a/common/constants.go b/common/constants.go index f4f575ba..849bdce7 100644 --- a/common/constants.go +++ b/common/constants.go @@ -70,6 +70,7 @@ const ( ChannelTypeMistral ChannelTypeGroq ChannelTypeOllama + ChannelTypeLingYiWanWu ChannelTypeDummy ) @@ -106,6 +107,7 @@ var ChannelBaseURLs = []string{ "https://api.mistral.ai", // 28 "https://api.groq.com/openai", // 29 "http://localhost:11434", // 30 + "https://api.lingyiwanwu.com", // 31 } const ( diff --git a/common/model-ratio.go b/common/model-ratio.go index 5b0a759b..c1b2856d 100644 --- a/common/model-ratio.go +++ b/common/model-ratio.go @@ -130,6 +130,10 @@ var ModelRatio = map[string]float64{ "llama2-7b-2048": 0.1 / 1000 * USD, "mixtral-8x7b-32768": 0.27 / 1000 * USD, "gemma-7b-it": 0.1 / 1000 * USD, + // https://platform.lingyiwanwu.com/docs#-计费单元 + "yi-34b-chat-0205": 2.5 / 1000000 * RMB, + "yi-34b-chat-200k": 12.0 / 1000000 * RMB, + "yi-vl-plus": 6.0 / 1000000 * RMB, } var CompletionRatio = map[string]float64{} diff --git a/relay/channel/lingyiwanwu/constants.go b/relay/channel/lingyiwanwu/constants.go new file mode 100644 index 00000000..30000e9d --- /dev/null +++ b/relay/channel/lingyiwanwu/constants.go @@ -0,0 +1,9 @@ +package lingyiwanwu + +// https://platform.lingyiwanwu.com/docs + +var ModelList = []string{ + "yi-34b-chat-0205", + "yi-34b-chat-200k", + "yi-vl-plus", +} diff --git a/relay/channel/openai/compatible.go b/relay/channel/openai/compatible.go index 767eec4b..e4951a34 100644 --- a/relay/channel/openai/compatible.go +++ b/relay/channel/openai/compatible.go @@ -5,6 +5,7 @@ import ( "github.com/songquanpeng/one-api/relay/channel/ai360" "github.com/songquanpeng/one-api/relay/channel/baichuan" "github.com/songquanpeng/one-api/relay/channel/groq" + "github.com/songquanpeng/one-api/relay/channel/lingyiwanwu" "github.com/songquanpeng/one-api/relay/channel/minimax" "github.com/songquanpeng/one-api/relay/channel/mistral" "github.com/songquanpeng/one-api/relay/channel/moonshot" @@ -18,6 +19,7 @@ var CompatibleChannels = []int{ common.ChannelTypeMinimax, common.ChannelTypeMistral, common.ChannelTypeGroq, + common.ChannelTypeLingYiWanWu, } func GetCompatibleChannelMeta(channelType int) (string, []string) { @@ -36,6 +38,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) { return "mistralai", mistral.ModelList case common.ChannelTypeGroq: return "groq", groq.ModelList + case common.ChannelTypeLingYiWanWu: + return "lingyiwanwu", lingyiwanwu.ModelList default: return "openai", ModelList } diff --git a/web/berry/src/constants/ChannelConstants.js b/web/berry/src/constants/ChannelConstants.js index c0379381..06597b93 100644 --- a/web/berry/src/constants/ChannelConstants.js +++ b/web/berry/src/constants/ChannelConstants.js @@ -101,6 +101,12 @@ export const CHANNEL_OPTIONS = { value: 30, color: 'default' }, + 31: { + key: 31, + text: '零一万物', + value: 31, + color: 'default' + }, 8: { key: 8, text: '自定义渠道', diff --git a/web/berry/src/views/Channel/type/Config.js b/web/berry/src/views/Channel/type/Config.js index c42c0253..8dfe77a4 100644 --- a/web/berry/src/views/Channel/type/Config.js +++ b/web/berry/src/views/Channel/type/Config.js @@ -169,6 +169,9 @@ const typeConfig = { 30: { modelGroup: "ollama", }, + 31: { + modelGroup: "lingyiwanwu", + }, }; export { defaultConfig, typeConfig }; diff --git a/web/default/src/constants/channel.constants.js b/web/default/src/constants/channel.constants.js index c8284ef2..8d536e58 100644 --- a/web/default/src/constants/channel.constants.js +++ b/web/default/src/constants/channel.constants.js @@ -16,6 +16,7 @@ export const CHANNEL_OPTIONS = [ { 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: 8, text: '自定义渠道', value: 8, color: 'pink' }, { key: 22, text: '知识库:FastGPT', value: 22, color: 'blue' }, { key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple' },