feat(playground): enhance max_tokens handling and input sanitization

- Introduced `sanitizePlaygroundInputs` to normalize `max_tokens` input values.
- Updated `loadConfig` to utilize the new sanitization function.
- Replaced `Input` with `InputNumber` for `max_tokens` in `ParameterControl` for better user experience.
- Modified API payload building logic to handle `max_tokens` more robustly.
- Added tests for new helper functions in `playgroundMaxTokens.js` to ensure correct behavior.
This commit is contained in:
HynoR
2026-04-06 00:40:08 +08:00
parent 677d02f2ab
commit 4cd0e3651d
7 changed files with 139 additions and 13 deletions
@@ -21,6 +21,7 @@ import {
STORAGE_KEYS,
DEFAULT_CONFIG,
} from '../../constants/playground.constants';
import { sanitizePlaygroundInputs } from '../../helpers/playgroundMaxTokens';
const MESSAGES_STORAGE_KEY = 'playground_messages';
@@ -67,10 +68,10 @@ export const loadConfig = () => {
const parsedConfig = JSON.parse(savedConfig);
const mergedConfig = {
inputs: {
inputs: sanitizePlaygroundInputs({
...DEFAULT_CONFIG.inputs,
...parsedConfig.inputs,
},
}),
parameterEnabled: {
...DEFAULT_CONFIG.parameterEnabled,
...parsedConfig.parameterEnabled,