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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user