From 7461a748f8e994e58ac4f56fd9919b1744bd7366 Mon Sep 17 00:00:00 2001 From: Jian Zhang Date: Wed, 20 Sep 2023 03:17:19 +0800 Subject: [PATCH] fix: use default values when adding auth (#568) The `auth add` cmd should use `backend` and `model` default values when user doesn't specify them Closes: #567 Signed-off-by: Jian Zhang Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com> Co-authored-by: Alex Jones --- cmd/auth/add.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/auth/add.go b/cmd/auth/add.go index 6aa6271433..f8518ce5ce 100644 --- a/cmd/auth/add.go +++ b/cmd/auth/add.go @@ -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.")