Skip to content

Commit

Permalink
fix: remove the disable server environment variable
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thedadams committed Sep 26, 2024
1 parent bb61df9 commit c72e385
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gptscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c72e385

Please sign in to comment.