Skip to content
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
2 changes: 2 additions & 0 deletions gptscript/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand All @@ -43,4 +44,5 @@ def __init__(self,
self.chatState = chatState
self.confirm = confirm
self.prompt = prompt
self.credentialOverride = credentialOverride
self.env = env
5 changes: 5 additions & 0 deletions tests/fixtures/credential-override.gpt
Original file line number Diff line number Diff line change
@@ -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}"
10 changes: 10 additions & 0 deletions tests/test_gptscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down