Skip to content

Commit

Permalink
Merge pull request #55 from thedadams/remove-disable-server
Browse files Browse the repository at this point in the history
fix: remove the disable server environment variable
  • Loading branch information
thedadams authored Sep 26, 2024
2 parents 25c1368 + 38c368f commit ac6b6a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 9 additions & 4 deletions gptscript/gptscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ def __init__(self, opts: GlobalOptions = None):
GPTScript.__gptscript_count += 1

if GPTScript.__server_url == "":
GPTScript.__server_url = os.environ.get("GPTSCRIPT_URL", "127.0.0.1:0")
GPTScript.__server_url = os.environ.get("GPTSCRIPT_URL", "http://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 GPTScript.__gptscript_count == 1 and os.environ.get("GPTSCRIPT_URL", "") == "":
self.opts.toEnv()

GPTScript.__process = Popen(
[_get_command(), "--listen-address", GPTScript.__server_url, "sdkserver"],
[_get_command(), "--listen-address", GPTScript.__server_url.removeprefix("http://"), "sdkserver"],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
Expand All @@ -51,7 +53,10 @@ def __init__(self, opts: GlobalOptions = None):
if "=" in GPTScript.__server_url:
GPTScript.__server_url = GPTScript.__server_url.split("=")[1]

self._server_url = f"http://{GPTScript.__server_url}"
self.opts.Env.append("GPTSCRIPT_URL=" + GPTScript.__server_url)
self._server_url = GPTScript.__server_url
if not (self._server_url.startswith("http://") or self._server_url.startswith("https://")):
self._server_url = f"http://{self._server_url}"
self._wait_for_gptscript()

def _wait_for_gptscript(self):
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 ac6b6a5

Please sign in to comment.