diff --git a/src/api.ts b/src/api.ts index 62a43a8..d3d65ef 100644 --- a/src/api.ts +++ b/src/api.ts @@ -29,6 +29,8 @@ if (!apiKey && command !== 'config' && mode !== CONFIG_MODES.set) { process.exit(1); } +const MODEL = config?.model || 'gpt-3.5-turbo'; + class OpenAi { private openAiApiConfiguration = new OpenAiApiConfiguration({ apiKey: apiKey @@ -47,7 +49,7 @@ class OpenAi { ): Promise => { try { const { data } = await this.openAI.createChatCompletion({ - model: 'gpt-3.5-turbo', + model: MODEL, messages, temperature: 0, top_p: 0.1, diff --git a/src/commands/config.ts b/src/commands/config.ts index 2349253..68aa7ea 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -13,6 +13,7 @@ export enum CONFIG_KEYS { OPENAI_BASE_PATH = 'OPENAI_BASE_PATH', description = 'description', emoji = 'emoji', + model = 'model', language = 'language' } @@ -88,6 +89,15 @@ export const configValidators = { `${value} is not supported yet` ); return value; + }, + + [CONFIG_KEYS.model](value: any) { + validateConfig( + CONFIG_KEYS.OPENAI_BASE_PATH, + value === 'gpt-3.5-turbo' || value === 'gpt-4', + `${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)` + ); + return value; } };