Skip to content

enhance: support credential override #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2024
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