refactor(playground): remove playgroundMaxTokens helper and update input handling
- Deleted the `playgroundMaxTokens` helper functions and their associated tests. - Updated `loadConfig` and `usePlaygroundState` to handle `max_tokens` directly without sanitization. - Simplified input handling in `usePlaygroundState` to directly set values without normalization.
This commit is contained in:
@@ -21,7 +21,6 @@ import {
|
||||
STORAGE_KEYS,
|
||||
DEFAULT_CONFIG,
|
||||
} from '../../constants/playground.constants';
|
||||
import { sanitizePlaygroundInputs } from '../../helpers/playgroundMaxTokens';
|
||||
|
||||
const MESSAGES_STORAGE_KEY = 'playground_messages';
|
||||
|
||||
@@ -66,12 +65,16 @@ export const loadConfig = () => {
|
||||
const savedConfig = localStorage.getItem(STORAGE_KEYS.CONFIG);
|
||||
if (savedConfig) {
|
||||
const parsedConfig = JSON.parse(savedConfig);
|
||||
const parsedMaxTokens = parseInt(parsedConfig?.inputs?.max_tokens, 10);
|
||||
|
||||
const mergedConfig = {
|
||||
inputs: sanitizePlaygroundInputs({
|
||||
inputs: {
|
||||
...DEFAULT_CONFIG.inputs,
|
||||
...parsedConfig.inputs,
|
||||
}),
|
||||
max_tokens: Number.isNaN(parsedMaxTokens)
|
||||
? parsedConfig?.inputs?.max_tokens
|
||||
: parsedMaxTokens,
|
||||
},
|
||||
parameterEnabled: {
|
||||
...DEFAULT_CONFIG.parameterEnabled,
|
||||
...parsedConfig.parameterEnabled,
|
||||
|
||||
Reference in New Issue
Block a user