Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove the disable server environment variable #55

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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