@@ -174,22 +174,47 @@ describe('gptscript module', () => {
174174 expect ( event ) . toContain ( "events: " ) ;
175175 } ) ;
176176
177- test ( 'exec of multiple tools' , async ( ) => {
178- const t0 = new gptscript . Tool ( {
179- tools : [ "ask" ] ,
180- instructions : "Only use the ask tool to ask who was the president of the united states in 1928?"
181- } ) ;
182- const t1 = new gptscript . Tool ( {
183- name : "ask" ,
184- description : "This tool is used to ask a question" ,
185- args : {
186- question : "The question to ask"
187- } ,
188- instructions : "${question}"
189- } ) ;
177+ describe ( 'exec with multiple tools' , ( ) => {
178+ test ( 'multiple tools' , async ( ) => {
179+ const t0 = new gptscript . Tool ( {
180+ tools : [ "ask" ] ,
181+ instructions : "Only use the ask tool to ask who was the president of the united states in 1928?"
182+ } ) ;
183+ const t1 = new gptscript . Tool ( {
184+ name : "ask" ,
185+ description : "This tool is used to ask a question" ,
186+ args : {
187+ question : "The question to ask"
188+ } ,
189+ instructions : "${question}"
190+ } ) ;
190191
191- const response = await gptscript . exec ( [ t0 , t1 ] ) ;
192- expect ( response ) . toBeDefined ( ) ;
193- expect ( response ) . toContain ( "Calvin Coolidge" ) ;
194- } , 30000 ) ;
192+ const response = await gptscript . exec ( [ t0 , t1 ] ) ;
193+ expect ( response ) . toBeDefined ( ) ;
194+ expect ( response ) . toContain ( "Calvin Coolidge" ) ;
195+ } , 30000 ) ;
196+
197+ test ( 'with sub tool' , async ( ) => {
198+ const t0 = new gptscript . Tool ( {
199+ tools : [ "ask" ] ,
200+ instructions : "Only use the ask tool to ask who was the president of the united states in 1928?"
201+ } ) ;
202+ const t1 = new gptscript . Tool ( {
203+ name : "other" ,
204+ instructions : "Who was the president of the united states in 1986?"
205+ } ) ;
206+ const t2 = new gptscript . Tool ( {
207+ name : "ask" ,
208+ description : "This tool is used to ask a question" ,
209+ args : {
210+ question : "The question to ask"
211+ } ,
212+ instructions : "${question}"
213+ } ) ;
214+
215+ const response = await gptscript . exec ( [ t0 , t1 , t2 ] , { subTool : 'other' } ) ;
216+ expect ( response ) . toBeDefined ( ) ;
217+ expect ( response ) . toContain ( "Ronald Reagan" ) ;
218+ } , 30000 ) ;
219+ } ) ;
195220} ) ;
0 commit comments