From 9f7fc5e6233ee90418dbc52b405b0991ab90e7f2 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Fri, 27 Sep 2024 19:43:18 -0400 Subject: [PATCH] Revert "chore: stop passing GPTSCRIPT_ env vars to children" This reverts commit 472cafb018d342f6704301436628920a935b7d49. --- src/gptscript.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gptscript.ts b/src/gptscript.ts index 0a1600c..4f1cf6e 100644 --- a/src/gptscript.ts +++ b/src/gptscript.ts @@ -139,6 +139,17 @@ export class GPTScript { if (!this.opts.URL) { this.opts.URL = GPTScript.serverURL } + + if (!this.opts.Env) { + this.opts.Env = [] + } + if (this.opts.URL) { + this.opts.Env.push(`GPTSCRIPT_URL=${this.opts.URL}`) + } + + if (this.opts.Token) { + this.opts.Env.push(`GPTSCRIPT_TOKEN=${this.opts.Token}`) + } } } @@ -400,6 +411,14 @@ export class GPTScript { try { await fetch(`${GPTScript.serverURL}/healthz`) this.opts.URL = GPTScript.serverURL + if (!this.opts.Env) { + this.opts.Env = [] + } + this.opts.Env.push(`GPTSCRIPT_URL=${this.opts.URL}`) + if (this.opts.Token) { + this.opts.Env.push(`GPTSCRIPT_TOKEN=${this.opts.Token}`) + } + return } catch { if (count === 0) {