File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,27 @@ describe("gptscript module", () => {
545
545
expect ( promptFound ) . toBeTruthy ( )
546
546
} )
547
547
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
+
548
569
test ( "prompt without prompt allowed should fail" , async ( ) => {
549
570
let promptFound = false
550
571
const t = {
You can’t perform that action at this time.
0 commit comments