diff --git a/gptscript/opts.py b/gptscript/opts.py index 468cdee..71b7831 100644 --- a/gptscript/opts.py +++ b/gptscript/opts.py @@ -30,6 +30,7 @@ def __init__(self, chatState: str = "", confirm: bool = False, prompt: bool = False, + credentialOverride: str = "", env: list[str] = None, apiKey: str = "", baseURL: str = "", @@ -43,4 +44,5 @@ def __init__(self, self.chatState = chatState self.confirm = confirm self.prompt = prompt + self.credentialOverride = credentialOverride self.env = env diff --git a/tests/fixtures/credential-override.gpt b/tests/fixtures/credential-override.gpt new file mode 100644 index 0000000..6211989 --- /dev/null +++ b/tests/fixtures/credential-override.gpt @@ -0,0 +1,5 @@ +credentials: github.com/gptscript-ai/credential as test.ts.credential_override with TEST_CRED as env + +#!/usr/bin/env bash + +echo "${TEST_CRED}" diff --git a/tests/test_gptscript.py b/tests/test_gptscript.py index 6e2c062..1469d49 100644 --- a/tests/test_gptscript.py +++ b/tests/test_gptscript.py @@ -183,6 +183,16 @@ async def collect_events(run: Run, e: CallFrame | RunFrame | PromptFrame): assert "Ronald Reagan" in await run.text(), "Expect streaming file to have correct output" assert "Ronald Reagan" in stream_output, "Expect stream_output to have correct output when streaming from file" +@pytest.mark.asyncio +async def test_credential_override(gptscript): + run = gptscript.run( + "./tests/fixtures/credential-override.gpt", + Options( + disableCache=True, + credentialOverride='test.ts.credential_override:TEST_CRED=foo' + ), + ) + assert "foo" in await run.text(), "Expect credential override to have correct output" @pytest.mark.asyncio async def test_eval_with_context(gptscript):