Skip to content

Commit 4cf2c5a

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 <[email protected]>
1 parent 25c1368 commit 4cf2c5a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

gptscript/gptscript.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ def __init__(self, opts: GlobalOptions = None):
3333

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

37-
if GPTScript.__gptscript_count == 1 and os.environ.get("GPTSCRIPT_DISABLE_SERVER", "") != "true":
39+
if os.environ.get("GPTSCRIPT_URL", "") != "":
40+
self.opts.Env.append("GPTSCRIPT_URL=" + GPTScript.__server_url)
41+
self._server_url = GPTScript.__server_url
42+
return
43+
44+
if GPTScript.__gptscript_count == 1:
3845
self.opts.toEnv()
3946

4047
GPTScript.__process = Popen(
@@ -61,6 +68,7 @@ def _wait_for_gptscript(self):
6168
resp = requests.get(self._server_url + "/healthz")
6269
if resp.status_code == 200:
6370
GPTScript.__server_ready = True
71+
self.opts.Env.append("GPTSCRIPT_URL=" + GPTScript.__server_url)
6472
return
6573
except requests.exceptions.ConnectionError:
6674
pass

tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ passenv =
1212
ANTHROPIC_API_KEY
1313
GPTSCRIPT_BIN
1414
GPTSCRIPT_URL
15-
GPTSCRIPT_DISABLE_SERVER
1615
GPTSCRIPT_CONFIG_FILE
1716
commands =
1817
install_gptscript

0 commit comments

Comments
 (0)