Skip to content

Commit

Permalink
feat: allow any string as model (#367)
Browse files Browse the repository at this point in the history
* refactor(anthropic.ts, openAi.ts): remove model validation against predefined list to allow any string as model, simplifying configuration and improving flexibility
  • Loading branch information
XiaomaiTX authored Aug 18, 2024
1 parent 10b031a commit c425878
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 7 additions & 9 deletions src/engine/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions src/engine/openAi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c425878

Please sign in to comment.