🐛 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:
Takuya Ono
2023-05-07 18:16:32 +09:00
committed by GitHub
parent 7b90b6a287
commit 13015a9033

View File

@@ -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',