Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f9cf073a
authored
Dec 05, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add deepseek channel type
parent
498b2404
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
8 deletions
+95
-8
common/constants.go
+2
-0
relay/channel/deepseek/adaptor.go
+71
-0
relay/channel/deepseek/constants.go
+7
-0
relay/constant/api_type.go
+3
-0
relay/relay_adaptor.go
+3
-0
web/src/constants/channel.constants.js
+9
-8
No files found.
common/constants.go
View file @
f9cf073a
...
@@ -229,6 +229,7 @@ const (
...
@@ -229,6 +229,7 @@ const (
ChannelTypeSiliconFlow
=
40
ChannelTypeSiliconFlow
=
40
ChannelTypeVertexAi
=
41
ChannelTypeVertexAi
=
41
ChannelTypeMistral
=
42
ChannelTypeMistral
=
42
ChannelTypeDeepSeek
=
43
ChannelTypeDummy
// this one is only for count, do not add any channel after this
ChannelTypeDummy
// this one is only for count, do not add any channel after this
...
@@ -278,4 +279,5 @@ var ChannelBaseURLs = []string{
...
@@ -278,4 +279,5 @@ var ChannelBaseURLs = []string{
"https://api.siliconflow.cn"
,
//40
"https://api.siliconflow.cn"
,
//40
""
,
//41
""
,
//41
"https://api.mistral.ai"
,
//42
"https://api.mistral.ai"
,
//42
"https://api.deepseek.com"
,
//43
}
}
relay/channel/deepseek/adaptor.go
0 → 100644
View file @
f9cf073a
package
deepseek
import
(
"errors"
"fmt"
"github.com/gin-gonic/gin"
"io"
"net/http"
"one-api/dto"
"one-api/relay/channel"
"one-api/relay/channel/openai"
relaycommon
"one-api/relay/common"
)
type
Adaptor
struct
{
}
func
(
a
*
Adaptor
)
ConvertAudioRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
dto
.
AudioRequest
)
(
io
.
Reader
,
error
)
{
//TODO implement me
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
a
*
Adaptor
)
ConvertImageRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
dto
.
ImageRequest
)
(
any
,
error
)
{
//TODO implement me
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
a
*
Adaptor
)
Init
(
info
*
relaycommon
.
RelayInfo
)
{
}
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
return
fmt
.
Sprintf
(
"%s/chat/completions"
,
info
.
BaseUrl
),
nil
}
func
(
a
*
Adaptor
)
SetupRequestHeader
(
c
*
gin
.
Context
,
req
*
http
.
Header
,
info
*
relaycommon
.
RelayInfo
)
error
{
channel
.
SetupApiRequestHeader
(
info
,
c
,
req
)
req
.
Set
(
"Authorization"
,
"Bearer "
+
info
.
ApiKey
)
return
nil
}
func
(
a
*
Adaptor
)
ConvertRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
*
dto
.
GeneralOpenAIRequest
)
(
any
,
error
)
{
if
request
==
nil
{
return
nil
,
errors
.
New
(
"request is nil"
)
}
return
request
,
nil
}
func
(
a
*
Adaptor
)
ConvertRerankRequest
(
c
*
gin
.
Context
,
relayMode
int
,
request
dto
.
RerankRequest
)
(
any
,
error
)
{
return
nil
,
nil
}
func
(
a
*
Adaptor
)
DoRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
requestBody
io
.
Reader
)
(
any
,
error
)
{
return
channel
.
DoApiRequest
(
a
,
c
,
info
,
requestBody
)
}
func
(
a
*
Adaptor
)
DoResponse
(
c
*
gin
.
Context
,
resp
*
http
.
Response
,
info
*
relaycommon
.
RelayInfo
)
(
usage
any
,
err
*
dto
.
OpenAIErrorWithStatusCode
)
{
if
info
.
IsStream
{
err
,
usage
=
openai
.
OaiStreamHandler
(
c
,
resp
,
info
)
}
else
{
err
,
usage
=
openai
.
OpenaiHandler
(
c
,
resp
,
info
.
PromptTokens
,
info
.
UpstreamModelName
)
}
return
}
func
(
a
*
Adaptor
)
GetModelList
()
[]
string
{
return
ModelList
}
func
(
a
*
Adaptor
)
GetChannelName
()
string
{
return
ChannelName
}
relay/channel/deepseek/constants.go
0 → 100644
View file @
f9cf073a
package
deepseek
var
ModelList
=
[]
string
{
"deepseek-chat"
,
"deepseek-coder"
,
}
var
ChannelName
=
"deepseek"
relay/constant/api_type.go
View file @
f9cf073a
...
@@ -26,6 +26,7 @@ const (
...
@@ -26,6 +26,7 @@ const (
APITypeSiliconFlow
APITypeSiliconFlow
APITypeVertexAi
APITypeVertexAi
APITypeMistral
APITypeMistral
APITypeDeepSeek
APITypeDummy
// this one is only for count, do not add any channel after this
APITypeDummy
// this one is only for count, do not add any channel after this
)
)
...
@@ -75,6 +76,8 @@ func ChannelType2APIType(channelType int) (int, bool) {
...
@@ -75,6 +76,8 @@ func ChannelType2APIType(channelType int) (int, bool) {
apiType
=
APITypeVertexAi
apiType
=
APITypeVertexAi
case
common
.
ChannelTypeMistral
:
case
common
.
ChannelTypeMistral
:
apiType
=
APITypeMistral
apiType
=
APITypeMistral
case
common
.
ChannelTypeDeepSeek
:
apiType
=
APITypeDeepSeek
}
}
if
apiType
==
-
1
{
if
apiType
==
-
1
{
return
APITypeOpenAI
,
false
return
APITypeOpenAI
,
false
...
...
relay/relay_adaptor.go
View file @
f9cf073a
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"one-api/relay/channel/claude"
"one-api/relay/channel/claude"
"one-api/relay/channel/cloudflare"
"one-api/relay/channel/cloudflare"
"one-api/relay/channel/cohere"
"one-api/relay/channel/cohere"
"one-api/relay/channel/deepseek"
"one-api/relay/channel/dify"
"one-api/relay/channel/dify"
"one-api/relay/channel/gemini"
"one-api/relay/channel/gemini"
"one-api/relay/channel/jina"
"one-api/relay/channel/jina"
...
@@ -71,6 +72,8 @@ func GetAdaptor(apiType int) channel.Adaptor {
...
@@ -71,6 +72,8 @@ func GetAdaptor(apiType int) channel.Adaptor {
return
&
vertex
.
Adaptor
{}
return
&
vertex
.
Adaptor
{}
case
constant
.
APITypeMistral
:
case
constant
.
APITypeMistral
:
return
&
mistral
.
Adaptor
{}
return
&
mistral
.
Adaptor
{}
case
constant
.
APITypeDeepSeek
:
return
&
deepseek
.
Adaptor
{}
}
}
return
nil
return
nil
}
}
...
...
web/src/constants/channel.constants.js
View file @
f9cf073a
...
@@ -45,19 +45,14 @@ export const CHANNEL_OPTIONS = [
...
@@ -45,19 +45,14 @@ export const CHANNEL_OPTIONS = [
label
:
'Azure OpenAI'
label
:
'Azure OpenAI'
},
},
{
{
key
:
24
,
text
:
'Google Gemini'
,
value
:
24
,
color
:
'orange'
,
label
:
'Google Gemini'
},
{
key
:
34
,
key
:
34
,
text
:
'Cohere'
,
text
:
'Cohere'
,
value
:
34
,
value
:
34
,
color
:
'purple'
,
color
:
'purple'
,
label
:
'Cohere'
label
:
'Cohere'
},
},
{
key
:
39
,
text
:
'Cloudflare'
,
value
:
39
,
color
:
'grey'
,
label
:
'Cloudflare'
},
{
key
:
43
,
text
:
'DeepSeek'
,
value
:
43
,
color
:
'blue'
,
label
:
'DeepSeek'
},
{
{
key
:
15
,
key
:
15
,
text
:
'百度文心千帆'
,
text
:
'百度文心千帆'
,
...
@@ -94,13 +89,19 @@ export const CHANNEL_OPTIONS = [
...
@@ -94,13 +89,19 @@ export const CHANNEL_OPTIONS = [
label
:
'智谱 GLM-4V'
label
:
'智谱 GLM-4V'
},
},
{
{
key
:
24
,
text
:
'Google Gemini'
,
value
:
24
,
color
:
'orange'
,
label
:
'Google Gemini'
},
{
key
:
11
,
key
:
11
,
text
:
'Google PaLM2'
,
text
:
'Google PaLM2'
,
value
:
11
,
value
:
11
,
color
:
'orange'
,
color
:
'orange'
,
label
:
'Google PaLM2'
label
:
'Google PaLM2'
},
},
{
key
:
39
,
text
:
'Cloudflare'
,
value
:
39
,
color
:
'grey'
,
label
:
'Cloudflare'
},
{
key
:
25
,
text
:
'Moonshot'
,
value
:
25
,
color
:
'green'
,
label
:
'Moonshot'
},
{
key
:
25
,
text
:
'Moonshot'
,
value
:
25
,
color
:
'green'
,
label
:
'Moonshot'
},
{
key
:
19
,
text
:
'360 智脑'
,
value
:
19
,
color
:
'blue'
,
label
:
'360 智脑'
},
{
key
:
19
,
text
:
'360 智脑'
,
value
:
19
,
color
:
'blue'
,
label
:
'360 智脑'
},
{
key
:
23
,
text
:
'腾讯混元'
,
value
:
23
,
color
:
'teal'
,
label
:
'腾讯混元'
},
{
key
:
23
,
text
:
'腾讯混元'
,
value
:
23
,
color
:
'teal'
,
label
:
'腾讯混元'
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment