Skip to content

Commit

Permalink
✨ feat: support deepseek (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartialBE authored Feb 2, 2024
1 parent 332b6fd commit 48f9ed2
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const (
ChannelTypeGemini = 25
ChannelTypeBaichuan = 26
ChannelTypeMiniMax = 27
ChannelTypeDeepseek = 28
)

var ChannelBaseURLs = []string{
Expand Down Expand Up @@ -222,6 +223,7 @@ var ChannelBaseURLs = []string{
"", //25
"https://api.baichuan-ai.com", //26
"https://api.minimax.chat/v1", //27
"https://api.deepseek.com", //28
}

const (
Expand Down
2 changes: 2 additions & 0 deletions common/model-ratio.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func init() {
"abab5.5-chat": {1.0714, ChannelTypeMiniMax}, // ¥0.015 / 1k tokens
"abab6-chat": {14.2857, ChannelTypeMiniMax}, // ¥0.2 / 1k tokens
"embo-01": {0.0357, ChannelTypeMiniMax}, // ¥0.0005 / 1k tokens
"deepseek-coder": {0.75, ChannelTypeDeepseek}, // 暂定 $0.0015 / 1K tokens
"deepseek-chat": {0.75, ChannelTypeDeepseek}, // 暂定 $0.0015 / 1K tokens
}

ModelRatio = make(map[string]float64)
Expand Down
36 changes: 36 additions & 0 deletions providers/deepseek/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package deepseek

import (
"one-api/common/requester"
"one-api/model"
"one-api/providers/base"
"one-api/providers/openai"
)

type DeepseekProviderFactory struct{}

// 创建 DeepseekProvider
func (f DeepseekProviderFactory) Create(channel *model.Channel) base.ProviderInterface {
config := getDeepseekConfig()
return &DeepseekProvider{
OpenAIProvider: openai.OpenAIProvider{
BaseProvider: base.BaseProvider{
Config: config,
Channel: channel,
Requester: requester.NewHTTPRequester(*channel.Proxy, openai.RequestErrorHandle),
},
BalanceAction: false,
},
}
}

func getDeepseekConfig() base.ProviderConfig {
return base.ProviderConfig{
BaseURL: "https://api.deepseek.com",
ChatCompletions: "/v1/chat/completions",
}
}

type DeepseekProvider struct {
openai.OpenAIProvider
}
2 changes: 2 additions & 0 deletions providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"one-api/providers/base"
"one-api/providers/claude"
"one-api/providers/closeai"
"one-api/providers/deepseek"
"one-api/providers/gemini"
"one-api/providers/minimax"
"one-api/providers/openai"
Expand Down Expand Up @@ -56,6 +57,7 @@ func init() {
providerFactories[common.ChannelTypeGemini] = gemini.GeminiProviderFactory{}
providerFactories[common.ChannelTypeBaichuan] = baichuan.BaichuanProviderFactory{}
providerFactories[common.ChannelTypeMiniMax] = minimax.MiniMaxProviderFactory{}
providerFactories[common.ChannelTypeDeepseek] = deepseek.DeepseekProviderFactory{}

}

Expand Down
6 changes: 6 additions & 0 deletions web/src/constants/ChannelConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export const CHANNEL_OPTIONS = {
value: 27,
color: 'orange'
},
28: {
key: 28,
text: 'Deepseek',
value: 28,
color: 'default'
},
24: {
key: 24,
text: 'Azure Speech',
Expand Down
6 changes: 6 additions & 0 deletions web/src/views/Channel/type/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ const typeConfig = {
prompt: {
key: '按照如下格式输入:APISecret|groupID'
}
},
28: {
input: {
models: ['deepseek-coder', 'deepseek-chat'],
test_model: 'deepseek-chat'
}
}
};

Expand Down

0 comments on commit 48f9ed2

Please sign in to comment.