From 16e0b9a4f969d04bbc64e87054762a1fd4cff2fe Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Mon, 9 Sep 2024 10:24:25 -0500 Subject: [PATCH] Add support for model selection via command line - Modify `runOptions` to include a `model` field. - Update `run` function to use the specified model from options. - Add a new command-line flag for model selection. - Add relevant environment variable `AICOMMIT_MODEL`. Resolves #5 --- cmd/aicommit/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/aicommit/main.go b/cmd/aicommit/main.go index cfd0590..a6486b1 100644 --- a/cmd/aicommit/main.go +++ b/cmd/aicommit/main.go @@ -127,7 +127,7 @@ func run(inv *serpent.Invocation, opts runOptions) error { } stream, err := opts.client.CreateChatCompletionStream(ctx, openai.ChatCompletionRequest{ - Model: openai.GPT4o, + Model: opts.model, Stream: true, Temperature: 0, // Seed must not be set for the amend-retry workflow. @@ -194,6 +194,7 @@ func run(inv *serpent.Invocation, opts runOptions) error { type runOptions struct { client *openai.Client + model string dryRun bool amend bool ref string @@ -250,6 +251,15 @@ func main() { Env: "OPENAI_API_KEY", Value: serpent.StringOf(&openAIKey), }, + { + Name: "model", + Description: "The model to use, e.g. gpt-4o or gpt-4o-mini.", + Flag: "model", + FlagShorthand: "m", + Default: "gpt-4o", + Env: "AICOMMIT_MODEL", + Value: serpent.StringOf(&opts.model), + }, { Name: "save-key", Description: "Save the OpenAI API key to persistent local configuration and exit.",