Skip to content

Commit c425878

Browse files
authored
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
1 parent 10b031a commit c425878

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/engine/anthropic.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,13 @@ if (
4848

4949
const MODEL = config?.OCO_MODEL;
5050
if (provider === 'anthropic' &&
51-
!MODEL_LIST.anthropic.includes(MODEL) &&
52-
command !== 'config' &&
53-
mode !== CONFIG_MODES.set) {
54-
outro(
55-
`${chalk.red('✖')} Unsupported model ${MODEL} for Anthropic. Supported models are: ${MODEL_LIST.anthropic.join(
56-
', '
57-
)}`
58-
);
59-
process.exit(1);
51+
MODEL.typeof !== 'string' &&
52+
command !== 'config' &&
53+
mode !== CONFIG_MODES.set) {
54+
outro(
55+
`${chalk.red('✖')} Unsupported model ${MODEL}. The model can be any string, but the current configuration is not supported.`
56+
);
57+
process.exit(1);
6058
}
6159

6260
export class AnthropicAi implements AiEngine {

src/engine/openAi.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,12 @@ if (
5454

5555
const MODEL = config?.OCO_MODEL || 'gpt-3.5-turbo';
5656
if (provider === 'openai' &&
57-
!MODEL_LIST.openai.includes(MODEL) &&
57+
MODEL.typeof !== 'string' &&
5858
command !== 'config' &&
5959
mode !== CONFIG_MODES.set) {
6060
outro(
61-
`${chalk.red('✖')} Unsupported model ${MODEL} for OpenAI. Supported models are: ${MODEL_LIST.openai.join(
62-
', '
63-
)}`
61+
`${chalk.red('✖')} Unsupported model ${MODEL}. The model can be any string, but the current configuration is not supported.`
6462
);
65-
6663
process.exit(1);
6764
}
6865

0 commit comments

Comments
 (0)