diff --git a/common/constants.go b/common/constants.go index 16ac3056..f8ea101c 100644 --- a/common/constants.go +++ b/common/constants.go @@ -199,6 +199,7 @@ const ( ChannelTypeMistral = 30 ChannelTypeGroq = 31 ChannelTypeBedrock = 32 + ChannelTypeLingyi = 33 ) var ChannelBaseURLs = []string{ @@ -235,6 +236,7 @@ var ChannelBaseURLs = []string{ "https://api.mistral.ai", //30 "https://api.groq.com/openai", //31 "", //32 + "https://api.lingyiwanwu.com", //33 } const ( diff --git a/common/model-ratio.go b/common/model-ratio.go index 28886e31..6b556ab3 100644 --- a/common/model-ratio.go +++ b/common/model-ratio.go @@ -195,6 +195,13 @@ func init() { "gemma-7b-it": {[]float64{0.05, 0.05}, ChannelTypeGroq}, // $0.27/$0.27 /1M Tokens 0.00027$ / 1k tokens "mixtral-8x7b-32768": {[]float64{0.135, 0.135}, ChannelTypeGroq}, + + // 2.5 元 / 1M tokens 0.0025 / 1k tokens + "yi-34b-chat-0205": {[]float64{0.1786, 0.1786}, ChannelTypeLingyi}, + // 12 元 / 1M tokens 0.012 / 1k tokens + "yi-34b-chat-200k": {[]float64{0.8571, 0.8571}, ChannelTypeLingyi}, + // 6 元 / 1M tokens 0.006 / 1k tokens + "yi-vl-plus": {[]float64{0.4286, 0.4286}, ChannelTypeLingyi}, } ModelRatio = make(map[string][]float64) diff --git a/controller/model.go b/controller/model.go index 0fc90618..c13c31bb 100644 --- a/controller/model.go +++ b/controller/model.go @@ -60,6 +60,7 @@ func init() { common.ChannelTypeMoonshot: "Moonshot", common.ChannelTypeMistral: "Mistral", common.ChannelTypeGroq: "Groq", + common.ChannelTypeLingyi: "Lingyiwanwu", } } diff --git a/providers/lingyi/base.go b/providers/lingyi/base.go new file mode 100644 index 00000000..c645be93 --- /dev/null +++ b/providers/lingyi/base.go @@ -0,0 +1,36 @@ +package lingyi + +import ( + "one-api/common/requester" + "one-api/model" + "one-api/providers/base" + "one-api/providers/openai" +) + +// 定义供应商工厂 +type LingyiProviderFactory struct{} + +// 创建 LingyiProvider +// https://platform.lingyiwanwu.com/docs#-create-chat-completion +func (f LingyiProviderFactory) Create(channel *model.Channel) base.ProviderInterface { + return &LingyiProvider{ + OpenAIProvider: openai.OpenAIProvider{ + BaseProvider: base.BaseProvider{ + Config: getConfig(), + Channel: channel, + Requester: requester.NewHTTPRequester(*channel.Proxy, openai.RequestErrorHandle), + }, + }, + } +} + +func getConfig() base.ProviderConfig { + return base.ProviderConfig{ + BaseURL: "https://api.lingyiwanwu.com", + ChatCompletions: "/v1/chat/completions", + } +} + +type LingyiProvider struct { + openai.OpenAIProvider +} diff --git a/web/src/constants/ChannelConstants.js b/web/src/constants/ChannelConstants.js index 602a457d..65fa4d18 100644 --- a/web/src/constants/ChannelConstants.js +++ b/web/src/constants/ChannelConstants.js @@ -107,6 +107,12 @@ export const CHANNEL_OPTIONS = { value: 32, color: 'orange' }, + 33: { + key: 33, + text: '零一万物', + value: 33, + color: 'primary' + }, 24: { key: 24, text: 'Azure Speech', diff --git a/web/src/views/Channel/type/Config.js b/web/src/views/Channel/type/Config.js index 63bffe56..080ac1ef 100644 --- a/web/src/views/Channel/type/Config.js +++ b/web/src/views/Channel/type/Config.js @@ -226,6 +226,13 @@ const typeConfig = { key: '按照如下格式输入:Region|AccessKeyID|SecretAccessKey|SessionToken 其中SessionToken可不填空' }, modelGroup: 'Anthropic' + }, + 33: { + input: { + models: ['yi-34b-chat-0205', 'yi-34b-chat-200k', 'yi-vl-plus'], + test_model: 'yi-34b-chat-0205' + }, + modelGroup: 'Lingyiwanwu' } };