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
9dd29b3d
authored
May 21, 2024
by
Calcium-Ion
Committed by
GitHub
May 21, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #266 from Calcium-Ion/custom-channel
feat: 自定义渠道功能变更
parents
45ace20c
455ee8c4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
12 deletions
+16
-12
common/model-ratio.go
+2
-2
relay/channel/openai/adaptor.go
+4
-4
web/src/pages/Channel/EditChannel.js
+10
-6
No files found.
common/model-ratio.go
View file @
9dd29b3d
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"strings"
"strings"
)
)
//from songquanpeng/one-api
//
from songquanpeng/one-api
const
(
const
(
USD2RMB
=
7.3
// 暂定 1 USD = 7.3 RMB
USD2RMB
=
7.3
// 暂定 1 USD = 7.3 RMB
USD
=
500
// $0.002 = 1 -> $1 = 500
USD
=
500
// $0.002 = 1 -> $1 = 500
...
@@ -289,7 +289,7 @@ func GetCompletionRatio(name string) float64 {
...
@@ -289,7 +289,7 @@ func GetCompletionRatio(name string) float64 {
}
}
return
4.0
/
3.0
return
4.0
/
3.0
}
}
if
strings
.
HasPrefix
(
name
,
"gpt-4"
)
&&
name
!=
"gpt-4-all"
&&
name
!=
"gpt-4-gizmo-*"
{
if
strings
.
HasPrefix
(
name
,
"gpt-4"
)
&&
!
strings
.
HasSuffix
(
name
,
"-all"
)
&&
!
strings
.
HasSuffix
(
name
,
"-gizmo-*"
)
{
if
strings
.
HasPrefix
(
name
,
"gpt-4-turbo"
)
||
strings
.
HasSuffix
(
name
,
"preview"
)
||
strings
.
HasPrefix
(
name
,
"gpt-4o"
)
{
if
strings
.
HasPrefix
(
name
,
"gpt-4-turbo"
)
||
strings
.
HasSuffix
(
name
,
"preview"
)
||
strings
.
HasPrefix
(
name
,
"gpt-4o"
)
{
return
3
return
3
}
}
...
...
relay/channel/openai/adaptor.go
View file @
9dd29b3d
...
@@ -41,10 +41,10 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
...
@@ -41,10 +41,10 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
requestURL
,
info
.
ChannelType
),
nil
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
requestURL
,
info
.
ChannelType
),
nil
case
common
.
ChannelTypeMiniMax
:
case
common
.
ChannelTypeMiniMax
:
return
minimax
.
GetRequestURL
(
info
)
return
minimax
.
GetRequestURL
(
info
)
//
case common.ChannelTypeCustom:
case
common
.
ChannelTypeCustom
:
//
url := info.BaseUrl
url
:=
info
.
BaseUrl
//
url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
url
=
strings
.
Replace
(
url
,
"{model}"
,
info
.
UpstreamModelName
,
-
1
)
//
return url, nil
return
url
,
nil
default
:
default
:
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
info
.
RequestURLPath
,
info
.
ChannelType
),
nil
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
info
.
RequestURLPath
,
info
.
ChannelType
),
nil
}
}
...
...
web/src/pages/Channel/EditChannel.js
View file @
9dd29b3d
...
@@ -301,17 +301,18 @@ const EditChannel = (props) => {
...
@@ -301,17 +301,18 @@ const EditChannel = (props) => {
const
addCustomModels
=
()
=>
{
const
addCustomModels
=
()
=>
{
if
(
customModel
.
trim
()
===
''
)
return
;
if
(
customModel
.
trim
()
===
''
)
return
;
// 使用逗号分隔字符串,然后去除每个模型名称前后的空格
// 使用逗号分隔字符串,然后去除每个模型名称前后的空格
const
modelArray
=
customModel
.
split
(
','
).
map
(
model
=>
model
.
trim
());
const
modelArray
=
customModel
.
split
(
','
).
map
(
(
model
)
=>
model
.
trim
());
let
localModels
=
[...
inputs
.
models
];
let
localModels
=
[...
inputs
.
models
];
let
localModelOptions
=
[...
modelOptions
];
let
localModelOptions
=
[...
modelOptions
];
let
hasError
=
false
;
let
hasError
=
false
;
modelArray
.
forEach
(
model
=>
{
modelArray
.
forEach
(
(
model
)
=>
{
// 检查模型是否已存在,且模型名称非空
// 检查模型是否已存在,且模型名称非空
if
(
model
&&
!
localModels
.
includes
(
model
))
{
if
(
model
&&
!
localModels
.
includes
(
model
))
{
localModels
.
push
(
model
);
// 添加到模型列表
localModels
.
push
(
model
);
// 添加到模型列表
localModelOptions
.
push
({
// 添加到下拉选项
localModelOptions
.
push
({
// 添加到下拉选项
key
:
model
,
key
:
model
,
text
:
model
,
text
:
model
,
value
:
model
,
value
:
model
,
...
@@ -330,7 +331,6 @@ const EditChannel = (props) => {
...
@@ -330,7 +331,6 @@ const EditChannel = (props) => {
handleInputChange
(
'models'
,
localModels
);
handleInputChange
(
'models'
,
localModels
);
};
};
return
(
return
(
<>
<>
<
SideSheet
<
SideSheet
...
@@ -433,11 +433,15 @@ const EditChannel = (props) => {
...
@@ -433,11 +433,15 @@ const EditChannel = (props) => {
{
inputs
.
type
===
8
&&
(
{
inputs
.
type
===
8
&&
(
<>
<>
<
div
style
=
{{
marginTop
:
10
}}
>
<
div
style
=
{{
marginTop
:
10
}}
>
<
Typography
.
Text
strong
>
Base
URL
:
<
/Typography.Text
>
<
Typography
.
Text
strong
>
完整的
Base
URL
,支持变量
{
'{model}'
}
:
<
/Typography.Text
>
<
/div
>
<
/div
>
<
Input
<
Input
name
=
'base_url'
name
=
'base_url'
placeholder
=
{
'请输入自定义渠道的 Base URL'
}
placeholder
=
{
'请输入完整的URL,例如:https://api.openai.com/v1/chat/completions'
}
onChange
=
{(
value
)
=>
{
onChange
=
{(
value
)
=>
{
handleInputChange
(
'base_url'
,
value
);
handleInputChange
(
'base_url'
,
value
);
}}
}}
...
...
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