From c425878f21f7dfaf0e423d071d65c7921754eaf5 Mon Sep 17 00:00:00 2001 From: XiaomaiTX Date: Sun, 18 Aug 2024 18:47:18 +0800 Subject: [PATCH] feat: allow any string as model (#367) * refactor(anthropic.ts, openAi.ts): remove model validation against predefined list to allow any string as model, simplifying configuration and improving flexibility --- src/engine/anthropic.ts | 16 +++++++--------- src/engine/openAi.ts | 7 ++----- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/engine/anthropic.ts b/src/engine/anthropic.ts index dcd9faaa..5502f9d4 100644 --- a/src/engine/anthropic.ts +++ b/src/engine/anthropic.ts @@ -48,15 +48,13 @@ if ( const MODEL = config?.OCO_MODEL; if (provider === 'anthropic' && - !MODEL_LIST.anthropic.includes(MODEL) && - command !== 'config' && - mode !== CONFIG_MODES.set) { - outro( - `${chalk.red('✖')} Unsupported model ${MODEL} for Anthropic. Supported models are: ${MODEL_LIST.anthropic.join( - ', ' - )}` - ); - process.exit(1); + MODEL.typeof !== 'string' && + command !== 'config' && + mode !== CONFIG_MODES.set) { +outro( + `${chalk.red('✖')} Unsupported model ${MODEL}. The model can be any string, but the current configuration is not supported.` +); +process.exit(1); } export class AnthropicAi implements AiEngine { diff --git a/src/engine/openAi.ts b/src/engine/openAi.ts index 4727f746..2d3f40ed 100644 --- a/src/engine/openAi.ts +++ b/src/engine/openAi.ts @@ -54,15 +54,12 @@ if ( const MODEL = config?.OCO_MODEL || 'gpt-3.5-turbo'; if (provider === 'openai' && - !MODEL_LIST.openai.includes(MODEL) && + MODEL.typeof !== 'string' && command !== 'config' && mode !== CONFIG_MODES.set) { outro( - `${chalk.red('✖')} Unsupported model ${MODEL} for OpenAI. Supported models are: ${MODEL_LIST.openai.join( - ', ' - )}` + `${chalk.red('✖')} Unsupported model ${MODEL}. The model can be any string, but the current configuration is not supported.` ); - process.exit(1); }