Skip to content

Commit

Permalink
chore: add test for prompt with metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Aug 20, 2024
1 parent aff096d commit de91491
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/gptscript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,27 @@ describe("gptscript module", () => {
expect(promptFound).toBeTruthy()
})

test("prompt with metadata", async () => {
let promptFound = false
const run = await g.run("sys.prompt", {
prompt: true,
input: "{\"fields\":\"first name\",\"metadata\":{\"key\":\"value\"}}"
})
run.on(gptscript.RunEventType.Prompt, async (data: gptscript.PromptFrame) => {
expect(data.fields.length).toEqual(1)
expect(data.fields[0]).toEqual("first name")
expect(data.metadata).toEqual({key: "value"})
expect(data.sensitive).toBeFalsy()

promptFound = true
await g.promptResponse({id: data.id, responses: {[data.fields[0]]: "Clicky"}})
})

expect(await run.text()).toContain("Clicky")
expect(run.err).toEqual("")
expect(promptFound).toBeTruthy()
})

test("prompt without prompt allowed should fail", async () => {
let promptFound = false
const t = {
Expand Down

0 comments on commit de91491

Please sign in to comment.