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
59eab663
authored
Aug 27, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: supper OpenRouter now (close #333, close #340)
parent
1966eb71
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
23 deletions
+30
-23
common/constants.go
+22
-20
controller/relay-text.go
+4
-0
web/src/constants/channel.constants.js
+1
-0
web/src/pages/Channel/EditChannel.js
+3
-3
No files found.
common/constants.go
View file @
59eab663
...
@@ -154,26 +154,27 @@ const (
...
@@ -154,26 +154,27 @@ const (
)
)
const
(
const
(
ChannelTypeUnknown
=
0
ChannelTypeUnknown
=
0
ChannelTypeOpenAI
=
1
ChannelTypeOpenAI
=
1
ChannelTypeAPI2D
=
2
ChannelTypeAPI2D
=
2
ChannelTypeAzure
=
3
ChannelTypeAzure
=
3
ChannelTypeCloseAI
=
4
ChannelTypeCloseAI
=
4
ChannelTypeOpenAISB
=
5
ChannelTypeOpenAISB
=
5
ChannelTypeOpenAIMax
=
6
ChannelTypeOpenAIMax
=
6
ChannelTypeOhMyGPT
=
7
ChannelTypeOhMyGPT
=
7
ChannelTypeCustom
=
8
ChannelTypeCustom
=
8
ChannelTypeAILS
=
9
ChannelTypeAILS
=
9
ChannelTypeAIProxy
=
10
ChannelTypeAIProxy
=
10
ChannelTypePaLM
=
11
ChannelTypePaLM
=
11
ChannelTypeAPI2GPT
=
12
ChannelTypeAPI2GPT
=
12
ChannelTypeAIGC2D
=
13
ChannelTypeAIGC2D
=
13
ChannelTypeAnthropic
=
14
ChannelTypeAnthropic
=
14
ChannelTypeBaidu
=
15
ChannelTypeBaidu
=
15
ChannelTypeZhipu
=
16
ChannelTypeZhipu
=
16
ChannelTypeAli
=
17
ChannelTypeAli
=
17
ChannelTypeXunfei
=
18
ChannelTypeXunfei
=
18
ChannelType360
=
19
ChannelType360
=
19
ChannelTypeOpenRouter
=
20
)
)
var
ChannelBaseURLs
=
[]
string
{
var
ChannelBaseURLs
=
[]
string
{
...
@@ -197,4 +198,5 @@ var ChannelBaseURLs = []string{
...
@@ -197,4 +198,5 @@ var ChannelBaseURLs = []string{
"https://dashscope.aliyuncs.com"
,
// 17
"https://dashscope.aliyuncs.com"
,
// 17
""
,
// 18
""
,
// 18
"https://ai.360.cn"
,
// 19
"https://ai.360.cn"
,
// 19
"https://openrouter.ai/api"
,
// 20
}
}
controller/relay-text.go
View file @
59eab663
...
@@ -282,6 +282,10 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
...
@@ -282,6 +282,10 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
req
.
Header
.
Set
(
"api-key"
,
apiKey
)
req
.
Header
.
Set
(
"api-key"
,
apiKey
)
}
else
{
}
else
{
req
.
Header
.
Set
(
"Authorization"
,
c
.
Request
.
Header
.
Get
(
"Authorization"
))
req
.
Header
.
Set
(
"Authorization"
,
c
.
Request
.
Header
.
Get
(
"Authorization"
))
if
channelType
==
common
.
ChannelTypeOpenRouter
{
req
.
Header
.
Set
(
"HTTP-Referer"
,
"https://github.com/songquanpeng/one-api"
)
req
.
Header
.
Set
(
"X-Title"
,
"One API"
)
}
}
}
case
APITypeClaude
:
case
APITypeClaude
:
req
.
Header
.
Set
(
"x-api-key"
,
apiKey
)
req
.
Header
.
Set
(
"x-api-key"
,
apiKey
)
...
...
web/src/constants/channel.constants.js
View file @
59eab663
...
@@ -9,6 +9,7 @@ export const CHANNEL_OPTIONS = [
...
@@ -9,6 +9,7 @@ export const CHANNEL_OPTIONS = [
{
key
:
16
,
text
:
'智谱 ChatGLM'
,
value
:
16
,
color
:
'violet'
},
{
key
:
16
,
text
:
'智谱 ChatGLM'
,
value
:
16
,
color
:
'violet'
},
{
key
:
19
,
text
:
'360 智脑'
,
value
:
19
,
color
:
'blue'
},
{
key
:
19
,
text
:
'360 智脑'
,
value
:
19
,
color
:
'blue'
},
{
key
:
8
,
text
:
'自定义渠道'
,
value
:
8
,
color
:
'pink'
},
{
key
:
8
,
text
:
'自定义渠道'
,
value
:
8
,
color
:
'pink'
},
{
key
:
20
,
text
:
'代理:OpenRouter'
,
value
:
20
,
color
:
'black'
},
{
key
:
2
,
text
:
'代理:API2D'
,
value
:
2
,
color
:
'blue'
},
{
key
:
2
,
text
:
'代理:API2D'
,
value
:
2
,
color
:
'blue'
},
{
key
:
5
,
text
:
'代理:OpenAI-SB'
,
value
:
5
,
color
:
'brown'
},
{
key
:
5
,
text
:
'代理:OpenAI-SB'
,
value
:
5
,
color
:
'brown'
},
{
key
:
7
,
text
:
'代理:OhMyGPT'
,
value
:
7
,
color
:
'purple'
},
{
key
:
7
,
text
:
'代理:OhMyGPT'
,
value
:
7
,
color
:
'purple'
},
...
...
web/src/pages/Channel/EditChannel.js
View file @
59eab663
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Form
,
Header
,
Input
,
Message
,
Segment
}
from
'semantic-ui-react'
;
import
{
Button
,
Form
,
Header
,
Input
,
Message
,
Segment
}
from
'semantic-ui-react'
;
import
{
use
Params
,
useNavigate
}
from
'react-router-dom'
;
import
{
use
Navigate
,
useParams
}
from
'react-router-dom'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
,
verifyJSON
}
from
'../../helpers'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
,
verifyJSON
}
from
'../../helpers'
;
import
{
CHANNEL_OPTIONS
}
from
'../../constants'
;
import
{
CHANNEL_OPTIONS
}
from
'../../constants'
;
...
@@ -19,7 +19,7 @@ const EditChannel = () => {
...
@@ -19,7 +19,7 @@ const EditChannel = () => {
const
handleCancel
=
()
=>
{
const
handleCancel
=
()
=>
{
navigate
(
'/channel'
);
navigate
(
'/channel'
);
};
};
const
originInputs
=
{
const
originInputs
=
{
name
:
''
,
name
:
''
,
type
:
1
,
type
:
1
,
...
@@ -62,7 +62,7 @@ const EditChannel = () => {
...
@@ -62,7 +62,7 @@ const EditChannel = () => {
localModels
=
[
'SparkDesk'
];
localModels
=
[
'SparkDesk'
];
break
;
break
;
case
19
:
case
19
:
localModels
=
[
'360GPT_S2_V9'
,
'embedding-bert-512-v1'
,
'embedding_s1_v1'
,
'semantic_similarity_s1_v1'
,
'360GPT_S2_V9.4'
]
localModels
=
[
'360GPT_S2_V9'
,
'embedding-bert-512-v1'
,
'embedding_s1_v1'
,
'semantic_similarity_s1_v1'
,
'360GPT_S2_V9.4'
]
;
break
;
break
;
}
}
setInputs
((
inputs
)
=>
({
...
inputs
,
models
:
localModels
}));
setInputs
((
inputs
)
=>
({
...
inputs
,
models
:
localModels
}));
...
...
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