Skip to content

Commit de91491

Browse files
committed
chore: add test for prompt with metadata
Signed-off-by: Donnie Adams <[email protected]>
1 parent aff096d commit de91491

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/gptscript.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,27 @@ describe("gptscript module", () => {
545545
expect(promptFound).toBeTruthy()
546546
})
547547

548+
test("prompt with metadata", async () => {
549+
let promptFound = false
550+
const run = await g.run("sys.prompt", {
551+
prompt: true,
552+
input: "{\"fields\":\"first name\",\"metadata\":{\"key\":\"value\"}}"
553+
})
554+
run.on(gptscript.RunEventType.Prompt, async (data: gptscript.PromptFrame) => {
555+
expect(data.fields.length).toEqual(1)
556+
expect(data.fields[0]).toEqual("first name")
557+
expect(data.metadata).toEqual({key: "value"})
558+
expect(data.sensitive).toBeFalsy()
559+
560+
promptFound = true
561+
await g.promptResponse({id: data.id, responses: {[data.fields[0]]: "Clicky"}})
562+
})
563+
564+
expect(await run.text()).toContain("Clicky")
565+
expect(run.err).toEqual("")
566+
expect(promptFound).toBeTruthy()
567+
})
568+
548569
test("prompt without prompt allowed should fail", async () => {
549570
let promptFound = false
550571
const t = {

0 commit comments

Comments
 (0)