Skip to content

Commit

Permalink
Merge pull request #34 from njhale/enhance/credential-override
Browse files Browse the repository at this point in the history
enhance: support credential override
  • Loading branch information
njhale authored Jun 27, 2024
2 parents 4f10a78 + fd3ae1d commit 9c9bae5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
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

0 comments on commit 9c9bae5

Please sign in to comment.