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
da017113
authored
Jul 29, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: automatically add related models when switch type
parent
84f92ffa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
web/src/pages/Channel/EditChannel.js
+27
-6
No files found.
web/src/pages/Channel/EditChannel.js
View file @
da017113
...
...
@@ -35,6 +35,27 @@ const EditChannel = () => {
const
[
customModel
,
setCustomModel
]
=
useState
(
''
);
const
handleInputChange
=
(
e
,
{
name
,
value
})
=>
{
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
if
(
name
===
'type'
&&
inputs
.
models
.
length
===
0
)
{
let
localModels
=
[];
switch
(
value
)
{
case
14
:
localModels
=
[
'claude-instant-1'
,
'claude-2'
];
break
;
case
11
:
localModels
=
[
'PaLM-2'
];
break
;
case
15
:
localModels
=
[
'ERNIE-Bot'
,
'ERNIE-Bot-turbo'
,
'Embedding-V1'
];
break
;
case
17
:
localModels
=
[
'qwen-v1'
,
'qwen-plus-v1'
];
break
;
case
16
:
localModels
=
[
'chatglm_pro'
,
'chatglm_std'
,
'chatglm_lite'
];
break
;
}
setInputs
((
inputs
)
=>
({
...
inputs
,
models
:
localModels
}));
}
};
const
loadChannel
=
async
()
=>
{
...
...
@@ -270,8 +291,8 @@ const EditChannel = () => {
}}
>
清除所有模型
<
/Button
>
<
Input
action
=
{
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
if
(
customModel
.
trim
()
===
""
)
return
;
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
if
(
customModel
.
trim
()
===
''
)
return
;
if
(
inputs
.
models
.
includes
(
customModel
))
return
;
let
localModels
=
[...
inputs
.
models
];
localModels
.
push
(
customModel
);
...
...
@@ -279,9 +300,9 @@ const EditChannel = () => {
localModelOptions
.
push
({
key
:
customModel
,
text
:
customModel
,
value
:
customModel
,
value
:
customModel
});
setModelOptions
(
modelOptions
=>
{
setModelOptions
(
modelOptions
=>
{
return
[...
modelOptions
,
...
localModelOptions
];
});
setCustomModel
(
''
);
...
...
@@ -323,7 +344,7 @@ const EditChannel = () => {
label
=
'密钥'
name
=
'key'
required
placeholder
=
{
inputs
.
type
===
15
?
"请输入 access token,当前版本暂不支持自动刷新,请每 30 天更新一次"
:
'请输入渠道对应的鉴权密钥'
}
placeholder
=
{
inputs
.
type
===
15
?
'请输入 access token,当前版本暂不支持自动刷新,请每 30 天更新一次'
:
'请输入渠道对应的鉴权密钥'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
key
}
autoComplete
=
'new-password'
...
...
@@ -354,7 +375,7 @@ const EditChannel = () => {
<
/Form.Field
>
)
}
<
Button
type
=
{
isEdit
?
"button"
:
"submit"
}
positive
onClick
=
{
submit
}
>
提交
<
/Button
>
<
Button
type
=
{
isEdit
?
'button'
:
'submit'
}
positive
onClick
=
{
submit
}
>
提交
<
/Button
>
<
/Form
>
<
/Segment
>
<
/
>
...
...
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