From 74d9a750ca01361eb81fdcc91eb5886ecff1d17c Mon Sep 17 00:00:00 2001 From: Aris Boutselis Date: Tue, 25 Apr 2023 20:45:04 +0300 Subject: [PATCH] feat: don't ask for password if backend is localai Signed-off-by: Aris Boutselis --- cmd/auth/auth.go | 2 +- pkg/ai/iai.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/auth/auth.go b/cmd/auth/auth.go index 33cba9bcad..cb077a1896 100644 --- a/cmd/auth/auth.go +++ b/cmd/auth/auth.go @@ -71,7 +71,7 @@ var AuthCmd = &cobra.Command{ os.Exit(1) } - if password == "" { + if ai.NeedPassword(backend) && password == "" { fmt.Printf("Enter %s Key: ", backend) bytePassword, err := term.ReadPassword(int(syscall.Stdin)) if err != nil { diff --git a/pkg/ai/iai.go b/pkg/ai/iai.go index 4cd2eb8ac0..39e66b3dc2 100644 --- a/pkg/ai/iai.go +++ b/pkg/ai/iai.go @@ -67,3 +67,7 @@ func (p *AIProvider) GetPassword() string { func (p *AIProvider) GetModel() string { return p.Model } + +func NeedPassword(backend string) bool { + return backend != "localai" +}