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
56ac6445
authored
Jun 22, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: able to clear all models now
parent
dd87d0a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
web/src/pages/Channel/EditChannel.js
+19
-12
No files found.
web/src/pages/Channel/EditChannel.js
View file @
56ac6445
...
@@ -32,15 +32,15 @@ const EditChannel = () => {
...
@@ -32,15 +32,15 @@ const EditChannel = () => {
let
res
=
await
API
.
get
(
`/api/channel/
${
channelId
}
`
);
let
res
=
await
API
.
get
(
`/api/channel/
${
channelId
}
`
);
const
{
success
,
message
,
data
}
=
res
.
data
;
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
if
(
success
)
{
if
(
data
.
models
===
""
)
{
if
(
data
.
models
===
''
)
{
data
.
models
=
[]
data
.
models
=
[]
;
}
else
{
}
else
{
data
.
models
=
data
.
models
.
split
(
","
)
data
.
models
=
data
.
models
.
split
(
','
);
}
}
if
(
data
.
group
===
""
)
{
if
(
data
.
group
===
''
)
{
data
.
groups
=
[]
data
.
groups
=
[]
;
}
else
{
}
else
{
data
.
groups
=
data
.
group
.
split
(
","
)
data
.
groups
=
data
.
group
.
split
(
','
);
}
}
setInputs
(
data
);
setInputs
(
data
);
}
else
{
}
else
{
...
@@ -55,10 +55,10 @@ const EditChannel = () => {
...
@@ -55,10 +55,10 @@ const EditChannel = () => {
setModelOptions
(
res
.
data
.
data
.
map
((
model
)
=>
({
setModelOptions
(
res
.
data
.
data
.
map
((
model
)
=>
({
key
:
model
.
id
,
key
:
model
.
id
,
text
:
model
.
id
,
text
:
model
.
id
,
value
:
model
.
id
,
value
:
model
.
id
})));
})));
setFullModels
(
res
.
data
.
data
.
map
((
model
)
=>
model
.
id
));
setFullModels
(
res
.
data
.
data
.
map
((
model
)
=>
model
.
id
));
setBasicModels
(
res
.
data
.
data
.
filter
((
model
)
=>
!
model
.
id
.
startsWith
(
"gpt-4"
)).
map
((
model
)
=>
model
.
id
));
setBasicModels
(
res
.
data
.
data
.
filter
((
model
)
=>
!
model
.
id
.
startsWith
(
'gpt-4'
)).
map
((
model
)
=>
model
.
id
));
}
catch
(
error
)
{
}
catch
(
error
)
{
showError
(
error
.
message
);
showError
(
error
.
message
);
}
}
...
@@ -70,7 +70,7 @@ const EditChannel = () => {
...
@@ -70,7 +70,7 @@ const EditChannel = () => {
setGroupOptions
(
res
.
data
.
data
.
map
((
group
)
=>
({
setGroupOptions
(
res
.
data
.
data
.
map
((
group
)
=>
({
key
:
group
,
key
:
group
,
text
:
group
,
text
:
group
,
value
:
group
,
value
:
group
})));
})));
}
catch
(
error
)
{
}
catch
(
error
)
{
showError
(
error
.
message
);
showError
(
error
.
message
);
...
@@ -90,6 +90,10 @@ const EditChannel = () => {
...
@@ -90,6 +90,10 @@ const EditChannel = () => {
showInfo
(
'请填写渠道名称和渠道密钥!'
);
showInfo
(
'请填写渠道名称和渠道密钥!'
);
return
;
return
;
}
}
if
(
inputs
.
models
.
length
===
0
)
{
showInfo
(
'请至少选择一个模型!'
);
return
;
}
let
localInputs
=
inputs
;
let
localInputs
=
inputs
;
if
(
localInputs
.
base_url
.
endsWith
(
'/'
))
{
if
(
localInputs
.
base_url
.
endsWith
(
'/'
))
{
localInputs
.
base_url
=
localInputs
.
base_url
.
slice
(
0
,
localInputs
.
base_url
.
length
-
1
);
localInputs
.
base_url
=
localInputs
.
base_url
.
slice
(
0
,
localInputs
.
base_url
.
length
-
1
);
...
@@ -98,8 +102,8 @@ const EditChannel = () => {
...
@@ -98,8 +102,8 @@ const EditChannel = () => {
localInputs
.
other
=
'2023-03-15-preview'
;
localInputs
.
other
=
'2023-03-15-preview'
;
}
}
let
res
;
let
res
;
localInputs
.
models
=
localInputs
.
models
.
join
(
","
)
localInputs
.
models
=
localInputs
.
models
.
join
(
','
);
localInputs
.
group
=
localInputs
.
groups
.
join
(
","
)
localInputs
.
group
=
localInputs
.
groups
.
join
(
','
);
if
(
isEdit
)
{
if
(
isEdit
)
{
res
=
await
API
.
put
(
`/api/channel/`
,
{
...
localInputs
,
id
:
parseInt
(
channelId
)
});
res
=
await
API
.
put
(
`/api/channel/`
,
{
...
localInputs
,
id
:
parseInt
(
channelId
)
});
}
else
{
}
else
{
...
@@ -231,13 +235,16 @@ const EditChannel = () => {
...
@@ -231,13 +235,16 @@ const EditChannel = () => {
options
=
{
modelOptions
}
options
=
{
modelOptions
}
/
>
/
>
<
/Form.Field
>
<
/Form.Field
>
<
div
style
=
{{
lineHeight
:
'40px'
,
marginBottom
:
'12px'
}}
>
<
div
style
=
{{
lineHeight
:
'40px'
,
marginBottom
:
'12px'
}}
>
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
basicModels
});
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
basicModels
});
}}
>
填入基础模型
<
/Button
>
}}
>
填入基础模型
<
/Button
>
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
fullModels
});
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
fullModels
});
}}
>
填入所有模型
<
/Button
>
}}
>
填入所有模型
<
/Button
>
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
[]
});
}}
>
清除所有模型
<
/Button
>
<
/div
>
<
/div
>
{
{
batch
?
<
Form
.
Field
>
batch
?
<
Form
.
Field
>
...
...
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