🐛 fix(config.ts): convert string value to number in OPENAI_MAX_TOKENS validator (#162)
The OPENAI_MAX_TOKENS validator now converts a string value to a number before validating it. This ensures that the validator works correctly when a string value is passed in.
This commit is contained in:
@@ -65,6 +65,15 @@ export const configValidators = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
[CONFIG_KEYS.OPENAI_MAX_TOKENS](value: any) {
|
[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(
|
validateConfig(
|
||||||
CONFIG_KEYS.OPENAI_MAX_TOKENS,
|
CONFIG_KEYS.OPENAI_MAX_TOKENS,
|
||||||
typeof value === 'number',
|
typeof value === 'number',
|
||||||
|
|||||||
Reference in New Issue
Block a user