Skip to content

Commit

Permalink
fix: use default values when adding auth (#568)
Browse files Browse the repository at this point in the history
The `auth add` cmd should use `backend` and `model` default values when user doesn't specify them

Closes: #567

Signed-off-by: Jian Zhang <jiazha@redhat.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
3 people committed Sep 19, 2023
1 parent b4656f5 commit 7461a74
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/auth/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ var addCmd = &cobra.Command{
}

// check if backend is not empty and a valid value
if backend == "" || !validBackend(ai.Backends, backend) {
color.Red("Error: Backend AI cannot be empty and accepted values are '%v'", strings.Join(ai.Backends, ", "))
os.Exit(1)
if backend == "" {
color.Yellow("Warning: backend input is empty, will use the default value: openai")
backend = "openai"
} else {
if !validBackend(ai.Backends, backend) {
color.Red("Error: Backend AI accepted values are '%v'", strings.Join(ai.Backends, ", "))
os.Exit(1)
}
}

// check if model is not empty
if model == "" {
color.Red("Error: Model cannot be empty.")
os.Exit(1)
color.Yellow("Warning: model input is empty, will use the default value: gpt-3.5-turbo")
}
if temperature > 1.0 || temperature < 0.0 {
color.Red("Error: temperature ranges from 0 to 1.")
Expand Down

0 comments on commit 7461a74

Please sign in to comment.