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
Unverified
Commit
eacc245b
authored
Apr 06, 2026
by
Calcium-Ion
Committed by
GitHub
Apr 06, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4106 from HynoR/feat/fix
feat(playground): enhance max_tokens handling and input sanitization
parents
03758a4a
427fb7ea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
9 deletions
+37
-9
web/src/components/playground/ParameterControl.jsx
+13
-7
web/src/components/playground/configStorage.js
+4
-0
web/src/helpers/api.js
+12
-1
web/src/hooks/playground/usePlaygroundState.js
+8
-1
No files found.
web/src/components/playground/ParameterControl.jsx
View file @
eacc245b
...
@@ -18,7 +18,14 @@ For commercial licensing, please contact support@quantumnous.com
...
@@ -18,7 +18,14 @@ For commercial licensing, please contact support@quantumnous.com
*/
*/
import
React
from
'react'
;
import
React
from
'react'
;
import
{
Input
,
Slider
,
Typography
,
Button
,
Tag
}
from
'@douyinfe/semi-ui'
;
import
{
Input
,
InputNumber
,
Slider
,
Typography
,
Button
,
Tag
,
}
from
'@douyinfe/semi-ui'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
import
{
Hash
,
Hash
,
...
@@ -241,15 +248,14 @@ const ParameterControl = ({
...
@@ -241,15 +248,14 @@ const ParameterControl = ({
disabled=
{
disabled
}
disabled=
{
disabled
}
/>
/>
</
div
>
</
div
>
<
Input
<
Input
Number
placeholder=
'MaxTokens'
placeholder=
'MaxTokens'
name=
'max_tokens'
name=
'max_tokens'
required
autoComplete=
'new-password'
defaultValue=
{
0
}
value=
{
inputs
.
max_tokens
}
value=
{
inputs
.
max_tokens
}
onChange=
{
(
value
)
=>
onInputChange
(
'max_tokens'
,
value
)
}
onNumberChange=
{
(
value
)
=>
onInputChange
(
'max_tokens'
,
value
)
}
className=
'!rounded-lg'
min=
{
0
}
precision=
{
0
}
style=
{
{
width
:
'100%'
}
}
disabled=
{
!
parameterEnabled
.
max_tokens
||
disabled
}
disabled=
{
!
parameterEnabled
.
max_tokens
||
disabled
}
/>
/>
</
div
>
</
div
>
...
...
web/src/components/playground/configStorage.js
View file @
eacc245b
...
@@ -65,11 +65,15 @@ export const loadConfig = () => {
...
@@ -65,11 +65,15 @@ export const loadConfig = () => {
const
savedConfig
=
localStorage
.
getItem
(
STORAGE_KEYS
.
CONFIG
);
const
savedConfig
=
localStorage
.
getItem
(
STORAGE_KEYS
.
CONFIG
);
if
(
savedConfig
)
{
if
(
savedConfig
)
{
const
parsedConfig
=
JSON
.
parse
(
savedConfig
);
const
parsedConfig
=
JSON
.
parse
(
savedConfig
);
const
parsedMaxTokens
=
parseInt
(
parsedConfig
?.
inputs
?.
max_tokens
,
10
);
const
mergedConfig
=
{
const
mergedConfig
=
{
inputs
:
{
inputs
:
{
...
DEFAULT_CONFIG
.
inputs
,
...
DEFAULT_CONFIG
.
inputs
,
...
parsedConfig
.
inputs
,
...
parsedConfig
.
inputs
,
max_tokens
:
Number
.
isNaN
(
parsedMaxTokens
)
?
parsedConfig
?.
inputs
?.
max_tokens
:
parsedMaxTokens
,
},
},
parameterEnabled
:
{
parameterEnabled
:
{
...
DEFAULT_CONFIG
.
parameterEnabled
,
...
DEFAULT_CONFIG
.
parameterEnabled
,
...
...
web/src/helpers/api.js
View file @
eacc245b
...
@@ -150,7 +150,18 @@ export const buildApiPayload = (
...
@@ -150,7 +150,18 @@ export const buildApiPayload = (
const
value
=
inputs
[
param
];
const
value
=
inputs
[
param
];
const
hasValue
=
value
!==
undefined
&&
value
!==
null
;
const
hasValue
=
value
!==
undefined
&&
value
!==
null
;
if
(
enabled
&&
hasValue
)
{
if
(
!
enabled
)
{
return
;
}
if
(
param
===
'max_tokens'
)
{
if
(
typeof
value
===
'number'
)
{
payload
[
param
]
=
value
;
}
return
;
}
if
(
hasValue
)
{
payload
[
param
]
=
value
;
payload
[
param
]
=
value
;
}
}
});
});
...
...
web/src/hooks/playground/usePlaygroundState.js
View file @
eacc245b
...
@@ -167,7 +167,14 @@ export const usePlaygroundState = () => {
...
@@ -167,7 +167,14 @@ export const usePlaygroundState = () => {
// 配置导入/重置
// 配置导入/重置
const
handleConfigImport
=
useCallback
((
importedConfig
)
=>
{
const
handleConfigImport
=
useCallback
((
importedConfig
)
=>
{
if
(
importedConfig
.
inputs
)
{
if
(
importedConfig
.
inputs
)
{
setInputs
((
prev
)
=>
({
...
prev
,
...
importedConfig
.
inputs
}));
const
parsedMaxTokens
=
parseInt
(
importedConfig
.
inputs
.
max_tokens
,
10
);
setInputs
((
prev
)
=>
({
...
prev
,
...
importedConfig
.
inputs
,
max_tokens
:
Number
.
isNaN
(
parsedMaxTokens
)
?
importedConfig
.
inputs
.
max_tokens
:
parsedMaxTokens
,
}));
}
}
if
(
importedConfig
.
parameterEnabled
)
{
if
(
importedConfig
.
parameterEnabled
)
{
setParameterEnabled
((
prev
)
=>
({
setParameterEnabled
((
prev
)
=>
({
...
...
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