From fc1ba025c09b5dc6634f0800312ff47b278cee1c Mon Sep 17 00:00:00 2001 From: mudler Date: Thu, 20 Apr 2023 22:50:03 +0200 Subject: [PATCH] feat: allow to set baseURL in the auth subcommand Signed-off-by: mudler --- cmd/auth/auth.go | 4 ++++ cmd/serve/serve.go | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/auth/auth.go b/cmd/auth/auth.go index d0c910f367..1f49037a96 100644 --- a/cmd/auth/auth.go +++ b/cmd/auth/auth.go @@ -16,6 +16,7 @@ import ( var ( backend string password string + baseURL string model string ) @@ -73,6 +74,7 @@ var AuthCmd = &cobra.Command{ Name: backend, Model: model, Password: password, + BaseURL: baseURL, } if providerIndex == -1 { @@ -100,4 +102,6 @@ func init() { AuthCmd.Flags().StringVarP(&model, "model", "m", "gpt-3.5-turbo", "Backend AI model") // add flag for password AuthCmd.Flags().StringVarP(&password, "password", "p", "", "Backend AI password") + // add flag for url + AuthCmd.Flags().StringVarP(&baseURL, "baseurl", "u", "", "URL AI provider, (e.g `http://localhost:8080/v1`)") } diff --git a/cmd/serve/serve.go b/cmd/serve/serve.go index 89cbcc616d..491dc91d55 100644 --- a/cmd/serve/serve.go +++ b/cmd/serve/serve.go @@ -34,13 +34,18 @@ var ServeCmd = &cobra.Command{ backend = os.Getenv("K8SGPT_BACKEND") password := os.Getenv("K8SGPT_PASSWORD") model := os.Getenv("K8SGPT_MODEL") - // If the envs are set, alocate in place to the aiProvider + baseURL := os.Getenv("K8SGPT_BASEURL") + + // If the envs are set, allocate in place to the aiProvider // else exit with error - if backend != "" || password != "" || model != "" { + envIsSet := backend != "" || password != "" || model != "" || baseURL != "" + + if envIsSet { aiProvider = &ai.AIProvider{ Name: backend, Password: password, Model: model, + BaseURL: baseURL, } configAI.Providers = append(configAI.Providers, *aiProvider)