From 7b90b6a287879a0981a92fa5fadc9a3e98f5d5a9 Mon Sep 17 00:00:00 2001 From: Takuya Ono Date: Sun, 7 May 2023 18:15:55 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(config.ts):=20error=20me?= =?UTF-8?q?ssage=20for=20OPENAI=5FBASE=5FPATH=20validation=20(#164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error message for the OPENAI_BASE_PATH validation has been updated to be more descriptive and helpful. The message now reads "Must be string" instead of "${value} is not supported yet". This change improves the clarity of the error message and makes it easier for developers to understand what went wrong when the validation fails. --- src/commands/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/config.ts b/src/commands/config.ts index 9f16034..ed8228c 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -96,8 +96,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; }, From 13015a9033d5fc9ecfb1c78837c7d2e9a0d064de Mon Sep 17 00:00:00 2001 From: Takuya Ono Date: Sun, 7 May 2023 18:16:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix(config.ts):=20convert=20?= =?UTF-8?q?string=20value=20to=20number=20in=20OPENAI=5FMAX=5FTOKENS=20val?= =?UTF-8?q?idator=20(#162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/commands/config.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/commands/config.ts b/src/commands/config.ts index ed8228c..02b6f0a 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',