From c72e385625365e45980fa2fd390f695c65d2732a Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Thu, 26 Sep 2024 17:01:43 -0400 Subject: [PATCH] fix: remove the disable server environment variable Now, when the GPTSCRIPT_URL is passed, the SDK will use it and not start its own server. Additionally, the SDK will pass this server URL to child SDK calls. Signed-off-by: Donnie Adams --- gptscript.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gptscript.go b/gptscript.go index 6a9723f..6f543e5 100644 --- a/gptscript.go +++ b/gptscript.go @@ -51,7 +51,7 @@ func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error) { opt.Env = append(opt.Env, opt.toEnv()...) - if serverProcessCancel == nil && os.Getenv("GPTSCRIPT_DISABLE_SERVER") != "true" { + if serverProcessCancel == nil && os.Getenv("GPTSCRIPT_URL") == "" { if serverURL != "" { u, err := url.Parse(serverURL) if err != nil { @@ -66,6 +66,7 @@ func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error) { opt.URL = "http://" + opt.URL } + opt.Env = append(opt.Env, "GPTSCRIPT_URL="+opt.URL) return &GPTScript{ globalOpts: opt, }, nil @@ -121,6 +122,9 @@ func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error) { if !strings.HasPrefix(opt.URL, "http://") && !strings.HasPrefix(opt.URL, "https://") { opt.URL = "http://" + opt.URL } + + opt.Env = append(opt.Env, "GPTSCRIPT_URL="+opt.URL) + return &GPTScript{ globalOpts: opt, }, nil