From 53715a3e25d0033b79c1067bddc9fa76c7b6657b Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Wed, 5 Jun 2024 11:02:11 -0400 Subject: [PATCH] fix: use entire env for credential prompting If the URL and token environment variable are set outside gptscript, then the credential prompting tool needs those variables. In this case, the extraEnv is nil and doesn't allow prompting to work. Additionally, the credential context default is needed when completing the opts for the SDK server. Signed-off-by: Donnie Adams --- pkg/gptscript/gptscript.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/gptscript/gptscript.go b/pkg/gptscript/gptscript.go index 2ff6bb27..40a5c5ad 100644 --- a/pkg/gptscript/gptscript.go +++ b/pkg/gptscript/gptscript.go @@ -58,6 +58,9 @@ func complete(opts *Options) (result *Options) { if len(result.Env) == 0 { result.Env = os.Environ() } + if result.CredentialContext == "" { + opts.CredentialContext = "default" + } return } @@ -107,9 +110,10 @@ func New(opts *Options) (*GPTScript, error) { closeServer() return nil, err } - oaiClient.SetEnvs(extraEnv) + opts.Env = append(opts.Env, extraEnv...) + oaiClient.SetEnvs(opts.Env) - remoteClient := remote.New(runner, extraEnv, cacheClient, cliCfg, opts.CredentialContext) + remoteClient := remote.New(runner, opts.Env, cacheClient, cliCfg, opts.CredentialContext) if err := registry.AddClient(remoteClient); err != nil { closeServer() return nil, err