@@ -116,7 +116,7 @@ describe("gptscript module", () => {
116
116
117
117
expect ( run ) . toBeDefined ( )
118
118
expect ( await run . text ( ) ) . toContain ( "Understood." )
119
- } )
119
+ } , 10000 )
120
120
121
121
test ( "evaluate executes and streams a prompt correctly" , async ( ) => {
122
122
let out = ""
@@ -129,7 +129,7 @@ describe("gptscript module", () => {
129
129
}
130
130
131
131
const run = await g . evaluate ( t , opts )
132
- run . on ( gptscript . RunEventType . CallProgress , ( data : gptscript . CallFrame ) => {
132
+ run . on ( gptscript . RunEventType . CallFinish , data => {
133
133
for ( let output of data . output ) out += `system: ${ output . content } `
134
134
} )
135
135
@@ -210,10 +210,11 @@ describe("gptscript module", () => {
210
210
}
211
211
212
212
const run = await g . run ( testGptPath , opts )
213
- run . on ( gptscript . RunEventType . CallProgress , data => {
213
+ run . on ( gptscript . RunEventType . CallFinish , data => {
214
214
for ( let output of data . output ) out += `system: ${ output . content } `
215
215
} )
216
- await run . text ( )
216
+
217
+ expect ( await run . text ( ) ) . toContain ( "Calvin Coolidge" )
217
218
err = run . err
218
219
219
220
for ( let c in run . calls ) {
@@ -231,23 +232,21 @@ describe("gptscript module", () => {
231
232
232
233
test ( "run executes and streams a file with global tools correctly" , async ( ) => {
233
234
let out = ""
234
- let err = undefined
235
235
const testGptPath = path . join ( __dirname , "fixtures" , "global-tools.gpt" )
236
236
const opts = {
237
237
disableCache : true ,
238
238
credentialOverrides : [ "github.com/gptscript-ai/gateway:OPENAI_API_KEY" ]
239
239
}
240
240
241
241
const run = await g . run ( testGptPath , opts )
242
- run . on ( gptscript . RunEventType . CallProgress , data => {
242
+ run . on ( gptscript . RunEventType . CallFinish , data => {
243
243
for ( let output of data . output ) out += `system: ${ output . content } `
244
244
} )
245
- await run . text ( )
246
- err = run . err
247
245
246
+ expect ( await run . text ( ) ) . toContain ( "Hello!" )
247
+ expect ( run . err ) . toEqual ( "" )
248
248
expect ( out ) . toContain ( "Hello!" )
249
- expect ( err ) . toEqual ( "" )
250
- } , 30000 )
249
+ } , 60000 )
251
250
252
251
test ( "aborting a run is reported correctly" , async ( ) => {
253
252
let errMessage = ""
@@ -627,7 +626,7 @@ describe("gptscript module", () => {
627
626
expect ( await run . text ( ) ) . toContain ( "Lake Huron" )
628
627
expect ( run . err ) . toEqual ( "" )
629
628
expect ( run . state ) . toEqual ( gptscript . RunState . Continue )
630
- } , 10000 )
629
+ } , 15000 )
631
630
632
631
test ( "nextChat on tool providing chat state" , async ( ) => {
633
632
const t = {
@@ -651,7 +650,7 @@ describe("gptscript module", () => {
651
650
expect ( await run . text ( ) ) . toContain ( "Austin" )
652
651
expect ( run . err ) . toEqual ( "" )
653
652
expect ( run . state ) . toEqual ( gptscript . RunState . Continue )
654
- } , 10000 )
653
+ } , 15000 )
655
654
656
655
test ( "confirm" , async ( ) => {
657
656
const t = {
@@ -702,11 +701,11 @@ describe("gptscript module", () => {
702
701
run . on ( gptscript . RunEventType . Prompt , async ( data : gptscript . PromptFrame ) => {
703
702
expect ( data . message ) . toContain ( "first name" )
704
703
expect ( data . fields . length ) . toEqual ( 1 )
705
- expect ( data . fields [ 0 ] ) . toEqual ( "first name" )
704
+ expect ( data . fields [ 0 ] . name ) . toEqual ( "first name" )
706
705
expect ( data . sensitive ) . toBeFalsy ( )
707
706
708
707
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" } } )
710
709
} )
711
710
712
711
expect ( await run . text ( ) ) . toContain ( "Clicky" )
@@ -722,12 +721,12 @@ describe("gptscript module", () => {
722
721
} )
723
722
run . on ( gptscript . RunEventType . Prompt , async ( data : gptscript . PromptFrame ) => {
724
723
expect ( data . fields . length ) . toEqual ( 1 )
725
- expect ( data . fields [ 0 ] ) . toEqual ( "first name" )
724
+ expect ( data . fields [ 0 ] . name ) . toEqual ( "first name" )
726
725
expect ( data . metadata ) . toEqual ( { key : "value" } )
727
726
expect ( data . sensitive ) . toBeFalsy ( )
728
727
729
728
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" } } )
731
730
} )
732
731
733
732
expect ( await run . text ( ) ) . toContain ( "Clicky" )
@@ -968,6 +967,8 @@ describe("gptscript module", () => {
968
967
} catch ( e ) {
969
968
throw new Error ( "failed to list datasets: " + e )
970
969
}
970
+
971
+ client . close ( )
971
972
} , 60000 )
972
973
973
974
test ( "create and delete workspace" , async ( ) => {
0 commit comments