From 176942ab4a49cfe938f55ee91b12fd9f6b271b03 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 11 Nov 2024 15:00:30 -0700 Subject: [PATCH] chore: Add GPTSCRIPT_HTTP_ENV_PREFIX to specify http env vars to send --- pkg/engine/http.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/engine/http.go b/pkg/engine/http.go index a30c01e1..c1dd67e7 100644 --- a/pkg/engine/http.go +++ b/pkg/engine/http.go @@ -82,6 +82,16 @@ func (e *Engine) runHTTP(ctx context.Context, prg *types.Program, tool types.Too req.Header.Add("X-GPTScript-Env", k+"="+envMap[k]) } } + for _, prefix := range strings.Split(os.Getenv("GPTSCRIPT_HTTP_ENV_PREFIX"), ",") { + if prefix == "" { + continue + } + for _, k := range slices.Sorted(maps.Keys(envMap)) { + if strings.HasPrefix(k, prefix) { + req.Header.Add("X-GPTScript-Env", k+"="+envMap[k]) + } + } + } req.Header.Set("X-GPTScript-Tool-Name", tool.Parameters.Name)