Skip to content

Commit 9c9bae5

Browse files
authored
Merge pull request #34 from njhale/enhance/credential-override
enhance: support credential override
2 parents 4f10a78 + fd3ae1d commit 9c9bae5

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

gptscript/opts.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self,
3030
chatState: str = "",
3131
confirm: bool = False,
3232
prompt: bool = False,
33+
credentialOverride: str = "",
3334
env: list[str] = None,
3435
apiKey: str = "",
3536
baseURL: str = "",
@@ -43,4 +44,5 @@ def __init__(self,
4344
self.chatState = chatState
4445
self.confirm = confirm
4546
self.prompt = prompt
47+
self.credentialOverride = credentialOverride
4648
self.env = env
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
credentials: github.com/gptscript-ai/credential as test.ts.credential_override with TEST_CRED as env
2+
3+
#!/usr/bin/env bash
4+
5+
echo "${TEST_CRED}"

tests/test_gptscript.py

+10
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ async def collect_events(run: Run, e: CallFrame | RunFrame | PromptFrame):
183183
assert "Ronald Reagan" in await run.text(), "Expect streaming file to have correct output"
184184
assert "Ronald Reagan" in stream_output, "Expect stream_output to have correct output when streaming from file"
185185

186+
@pytest.mark.asyncio
187+
async def test_credential_override(gptscript):
188+
run = gptscript.run(
189+
"./tests/fixtures/credential-override.gpt",
190+
Options(
191+
disableCache=True,
192+
credentialOverride='test.ts.credential_override:TEST_CRED=foo'
193+
),
194+
)
195+
assert "foo" in await run.text(), "Expect credential override to have correct output"
186196

187197
@pytest.mark.asyncio
188198
async def test_eval_with_context(gptscript):

0 commit comments

Comments
 (0)