Skip to content

Commit c72e385

Browse files
committed
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 <donnie@acorn.io>
1 parent bb61df9 commit c72e385

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gptscript.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error) {
5151

5252
opt.Env = append(opt.Env, opt.toEnv()...)
5353

54-
if serverProcessCancel == nil && os.Getenv("GPTSCRIPT_DISABLE_SERVER") != "true" {
54+
if serverProcessCancel == nil && os.Getenv("GPTSCRIPT_URL") == "" {
5555
if serverURL != "" {
5656
u, err := url.Parse(serverURL)
5757
if err != nil {
@@ -66,6 +66,7 @@ func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error) {
6666
opt.URL = "http://" + opt.URL
6767
}
6868

69+
opt.Env = append(opt.Env, "GPTSCRIPT_URL="+opt.URL)
6970
return &GPTScript{
7071
globalOpts: opt,
7172
}, nil
@@ -121,6 +122,9 @@ func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error) {
121122
if !strings.HasPrefix(opt.URL, "http://") && !strings.HasPrefix(opt.URL, "https://") {
122123
opt.URL = "http://" + opt.URL
123124
}
125+
126+
opt.Env = append(opt.Env, "GPTSCRIPT_URL="+opt.URL)
127+
124128
return &GPTScript{
125129
globalOpts: opt,
126130
}, nil

0 commit comments

Comments
 (0)