Skip to content

Commit

Permalink
feat: allow to set baseURL in the auth subcommand
Browse files Browse the repository at this point in the history
Signed-off-by: mudler <mudler@mocaccino.org>
  • Loading branch information
mudler committed Apr 20, 2023
1 parent 9c2929b commit 39530d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
var (
backend string
password string
baseURL string
model string
)

Expand Down Expand Up @@ -100,4 +101,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`)")
}
9 changes: 7 additions & 2 deletions cmd/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 39530d0

Please sign in to comment.