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 25c1368 commit 4cf2c5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion gptscript/gptscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ def __init__(self, opts: GlobalOptions = None):

if GPTScript.__server_url == "":
GPTScript.__server_url = os.environ.get("GPTSCRIPT_URL", "127.0.0.1:0")
if not (GPTScript.__server_url.startswith("http://") or GPTScript.__server_url.startswith("https://")):
GPTScript.__server_url = f"http://{GPTScript.__server_url}"

if GPTScript.__gptscript_count == 1 and os.environ.get("GPTSCRIPT_DISABLE_SERVER", "") != "true":
if os.environ.get("GPTSCRIPT_URL", "") != "":
self.opts.Env.append("GPTSCRIPT_URL=" + GPTScript.__server_url)
self._server_url = GPTScript.__server_url
return

if GPTScript.__gptscript_count == 1:
self.opts.toEnv()

GPTScript.__process = Popen(
Expand All @@ -61,6 +68,7 @@ def _wait_for_gptscript(self):
resp = requests.get(self._server_url + "/healthz")
if resp.status_code == 200:
GPTScript.__server_ready = True
self.opts.Env.append("GPTSCRIPT_URL=" + GPTScript.__server_url)
return
except requests.exceptions.ConnectionError:
pass
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ passenv =
ANTHROPIC_API_KEY
GPTSCRIPT_BIN
GPTSCRIPT_URL
GPTSCRIPT_DISABLE_SERVER
GPTSCRIPT_CONFIG_FILE
commands =
install_gptscript
Expand Down

0 comments on commit 4cf2c5a

Please sign in to comment.