@@ -116,7 +116,7 @@ describe("gptscript module", () => {
116116
117117 expect ( run ) . toBeDefined ( )
118118 expect ( await run . text ( ) ) . toContain ( "Understood." )
119- } )
119+ } , 10000 )
120120
121121 test ( "evaluate executes and streams a prompt correctly" , async ( ) => {
122122 let out = ""
@@ -129,7 +129,7 @@ describe("gptscript module", () => {
129129 }
130130
131131 const run = await g . evaluate ( t , opts )
132- run . on ( gptscript . RunEventType . CallProgress , ( data : gptscript . CallFrame ) => {
132+ run . on ( gptscript . RunEventType . CallFinish , data => {
133133 for ( let output of data . output ) out += `system: ${ output . content } `
134134 } )
135135
@@ -210,10 +210,11 @@ describe("gptscript module", () => {
210210 }
211211
212212 const run = await g . run ( testGptPath , opts )
213- run . on ( gptscript . RunEventType . CallProgress , data => {
213+ run . on ( gptscript . RunEventType . CallFinish , data => {
214214 for ( let output of data . output ) out += `system: ${ output . content } `
215215 } )
216- await run . text ( )
216+
217+ expect ( await run . text ( ) ) . toContain ( "Calvin Coolidge" )
217218 err = run . err
218219
219220 for ( let c in run . calls ) {
@@ -231,23 +232,21 @@ describe("gptscript module", () => {
231232
232233 test ( "run executes and streams a file with global tools correctly" , async ( ) => {
233234 let out = ""
234- let err = undefined
235235 const testGptPath = path . join ( __dirname , "fixtures" , "global-tools.gpt" )
236236 const opts = {
237237 disableCache : true ,
238238 credentialOverrides : [ "github.com/gptscript-ai/gateway:OPENAI_API_KEY" ]
239239 }
240240
241241 const run = await g . run ( testGptPath , opts )
242- run . on ( gptscript . RunEventType . CallProgress , data => {
242+ run . on ( gptscript . RunEventType . CallFinish , data => {
243243 for ( let output of data . output ) out += `system: ${ output . content } `
244244 } )
245- await run . text ( )
246- err = run . err
247245
246+ expect ( await run . text ( ) ) . toContain ( "Hello!" )
247+ expect ( run . err ) . toEqual ( "" )
248248 expect ( out ) . toContain ( "Hello!" )
249- expect ( err ) . toEqual ( "" )
250- } , 30000 )
249+ } , 60000 )
251250
252251 test ( "aborting a run is reported correctly" , async ( ) => {
253252 let errMessage = ""
@@ -627,7 +626,7 @@ describe("gptscript module", () => {
627626 expect ( await run . text ( ) ) . toContain ( "Lake Huron" )
628627 expect ( run . err ) . toEqual ( "" )
629628 expect ( run . state ) . toEqual ( gptscript . RunState . Continue )
630- } , 10000 )
629+ } , 15000 )
631630
632631 test ( "nextChat on tool providing chat state" , async ( ) => {
633632 const t = {
@@ -651,7 +650,7 @@ describe("gptscript module", () => {
651650 expect ( await run . text ( ) ) . toContain ( "Austin" )
652651 expect ( run . err ) . toEqual ( "" )
653652 expect ( run . state ) . toEqual ( gptscript . RunState . Continue )
654- } , 10000 )
653+ } , 15000 )
655654
656655 test ( "confirm" , async ( ) => {
657656 const t = {
@@ -702,11 +701,11 @@ describe("gptscript module", () => {
702701 run . on ( gptscript . RunEventType . Prompt , async ( data : gptscript . PromptFrame ) => {
703702 expect ( data . message ) . toContain ( "first name" )
704703 expect ( data . fields . length ) . toEqual ( 1 )
705- expect ( data . fields [ 0 ] ) . toEqual ( "first name" )
704+ expect ( data . fields [ 0 ] . name ) . toEqual ( "first name" )
706705 expect ( data . sensitive ) . toBeFalsy ( )
707706
708707 promptFound = true
709- await g . promptResponse ( { id : data . id , responses : { [ data . fields [ 0 ] ] : "Clicky" } } )
708+ await g . promptResponse ( { id : data . id , responses : { [ data . fields [ 0 ] . name ] : "Clicky" } } )
710709 } )
711710
712711 expect ( await run . text ( ) ) . toContain ( "Clicky" )
@@ -722,12 +721,12 @@ describe("gptscript module", () => {
722721 } )
723722 run . on ( gptscript . RunEventType . Prompt , async ( data : gptscript . PromptFrame ) => {
724723 expect ( data . fields . length ) . toEqual ( 1 )
725- expect ( data . fields [ 0 ] ) . toEqual ( "first name" )
724+ expect ( data . fields [ 0 ] . name ) . toEqual ( "first name" )
726725 expect ( data . metadata ) . toEqual ( { key : "value" } )
727726 expect ( data . sensitive ) . toBeFalsy ( )
728727
729728 promptFound = true
730- await g . promptResponse ( { id : data . id , responses : { [ data . fields [ 0 ] ] : "Clicky" } } )
729+ await g . promptResponse ( { id : data . id , responses : { [ data . fields [ 0 ] . name ] : "Clicky" } } )
731730 } )
732731
733732 expect ( await run . text ( ) ) . toContain ( "Clicky" )
@@ -968,6 +967,8 @@ describe("gptscript module", () => {
968967 } catch ( e ) {
969968 throw new Error ( "failed to list datasets: " + e )
970969 }
970+
971+ client . close ( )
971972 } , 60000 )
972973
973974 test ( "create and delete workspace" , async ( ) => {
0 commit comments