Skip to content

Commit 53715a3

Browse files
committed
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 <[email protected]>
1 parent 49fc1c9 commit 53715a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/gptscript/gptscript.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func complete(opts *Options) (result *Options) {
5858
if len(result.Env) == 0 {
5959
result.Env = os.Environ()
6060
}
61+
if result.CredentialContext == "" {
62+
opts.CredentialContext = "default"
63+
}
6164
return
6265
}
6366

@@ -107,9 +110,10 @@ func New(opts *Options) (*GPTScript, error) {
107110
closeServer()
108111
return nil, err
109112
}
110-
oaiClient.SetEnvs(extraEnv)
113+
opts.Env = append(opts.Env, extraEnv...)
114+
oaiClient.SetEnvs(opts.Env)
111115

112-
remoteClient := remote.New(runner, extraEnv, cacheClient, cliCfg, opts.CredentialContext)
116+
remoteClient := remote.New(runner, opts.Env, cacheClient, cliCfg, opts.CredentialContext)
113117
if err := registry.AddClient(remoteClient); err != nil {
114118
closeServer()
115119
return nil, err

0 commit comments

Comments
 (0)