Skip to content

Commit

Permalink
Merge pull request #52 from thedadams/fix-confirm-test-windows
Browse files Browse the repository at this point in the history
fix: adjust confirm test for Windows
  • Loading branch information
thedadams authored Jun 13, 2024
2 parents 689611d + ce065fb commit abe1a57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit abe1a57

Please sign in to comment.