Skip to content

Commit

Permalink
Add support for model selection via command line
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ammario committed Sep 9, 2024
1 parent 230e4c8 commit 16e0b9a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/aicommit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down

0 comments on commit 16e0b9a

Please sign in to comment.