diff --git a/src/commands/config.ts b/src/commands/config.ts index 1ca297a..14b8490 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -65,6 +65,15 @@ export const configValidators = { }, [CONFIG_KEYS.OPENAI_MAX_TOKENS](value: any) { + // If the value is a string, convert it to a number. + if (typeof value === 'string') { + value = parseInt(value); + validateConfig( + CONFIG_KEYS.OPENAI_MAX_TOKENS, + !isNaN(value), + 'Must be a number' + ); + } validateConfig( CONFIG_KEYS.OPENAI_MAX_TOKENS, typeof value === 'number', @@ -96,8 +105,8 @@ export const configValidators = { [CONFIG_KEYS.OPENAI_BASE_PATH](value: any) { validateConfig( CONFIG_KEYS.OPENAI_BASE_PATH, - typeof value == 'string', - `${value} is not supported yet` + typeof value === 'string', + 'Must be string' ); return value; },