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
4 changes: 4 additions & 0 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ jobs:
- name: Install gptscript
run: |
curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe
- name: Create config file
run: |
echo '{"credsStore":"file"}' > config
- name: Install dependencies
run: npm install
- name: Run Tests
env:
GPTSCRIPT_BIN: .\gptscript.exe
GPTSCRIPT_CONFIG_FILE: .\config
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
NODE_GPTSCRIPT_SKIP_INSTALL_BINARY: true
run: npm test
11 changes: 7 additions & 4 deletions tests/gptscript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,21 +401,24 @@ describe("gptscript module", () => {
}, 10000)

test("confirm", async () => {
let confirmFound = false
const t = {
instructions: "List the files in the current working directory.",
tools: ["sys.exec"]
}

const commands = [`"ls"`, `"dir"`]
let confirmCallCount = 0
const run = await g.evaluate(t, {confirm: true})
run.on(gptscript.RunEventType.CallConfirm, async (data: gptscript.CallFrame) => {
expect(data.input).toContain(`"ls"`)
confirmFound = true
// On Windows, ls is not always a command. The LLM will try to run dir in this case. Allow both.
expect(data.input).toContain(commands[confirmCallCount])
confirmCallCount++
await g.confirm({id: data.id, accept: true})
})

expect(await run.text()).toContain("README.md")
expect(run.err).toEqual("")
expect(confirmFound).toBeTruthy()
expect(confirmCallCount > 0).toBeTruthy()
})

test("do not confirm", async () => {
Expand Down