Skip to content

Commit 10706b1

Browse files
authored
Merge pull request #66 from njhale/enhance/credential-overrides
enhance: support credential override
2 parents bb980a1 + 38fbde2 commit 10706b1

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/gptscript.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface RunOpts {
3737
chatState?: string
3838
confirm?: boolean
3939
prompt?: boolean
40+
credentialOverride?: string
4041
env?: string[]
4142

4243
APIKey?: string
+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/gptscript.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ describe("gptscript module", () => {
106106
expect(result).toContain("Calvin Coolidge")
107107
})
108108

109+
test("should override credentials correctly", async () => {
110+
const testGptPath = path.join(__dirname, "fixtures", "credential-override.gpt")
111+
112+
const result = await (await g.run(testGptPath, {
113+
disableCache: true,
114+
credentialOverride: 'test.ts.credential_override:TEST_CRED=foo',
115+
})).text()
116+
117+
expect(result).toBeDefined()
118+
expect(result).toContain("foo")
119+
})
120+
109121
test("run executes and stream a file correctly", async () => {
110122
let out = ""
111123
let err = undefined
@@ -167,6 +179,7 @@ describe("gptscript module", () => {
167179
expect(err).toBeUndefined()
168180
})
169181

182+
170183
describe("evaluate with multiple tools", () => {
171184
test("multiple tools", async () => {
172185
const t0 = {

0 commit comments

Comments
 (0)