File tree 2 files changed +31
-6
lines changed
2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -215,16 +215,16 @@ export class GPTScript {
215
215
const nodes : any [ ] = [ ]
216
216
217
217
for ( const block of blocks ) {
218
- if ( block . type === "tool " ) {
218
+ if ( block . type === "text " ) {
219
219
nodes . push ( {
220
- toolNode : {
221
- tool : block
220
+ textNode : {
221
+ text : "!" + ( block . format || "text" ) + "\n" + block . content
222
222
}
223
223
} )
224
- } else if ( block . type === "text" ) {
224
+ } else {
225
225
nodes . push ( {
226
- textNode : {
227
- text : "!" + ( block . format || "text" ) + "\n" + block . content
226
+ toolNode : {
227
+ tool : block
228
228
}
229
229
} )
230
230
}
Original file line number Diff line number Diff line change @@ -383,6 +383,31 @@ describe("gptscript module", () => {
383
383
expect ( response ) . toContain ( "Parameter: text: The text to write" )
384
384
} )
385
385
386
+ test ( "format context tool" , async ( ) => {
387
+ const tool = {
388
+ id : "my-tool" ,
389
+ type : "context" as ToolType ,
390
+ tools : [ "sys.write" , "sys.read" ] ,
391
+ instructions : "This is a test" ,
392
+ arguments : {
393
+ type : ArgumentSchemaType ,
394
+ properties : {
395
+ text : {
396
+ type : PropertyType ,
397
+ description : "The text to write"
398
+ }
399
+ }
400
+ }
401
+ }
402
+
403
+ const response = await g . stringify ( [ tool ] )
404
+ expect ( response ) . toBeDefined ( )
405
+ expect ( response ) . toContain ( "Tools: sys.write, sys.read" )
406
+ expect ( response ) . toContain ( "This is a test" )
407
+ expect ( response ) . toContain ( "Parameter: text: The text to write" )
408
+ expect ( response ) . toContain ( "Type: Context" )
409
+ } )
410
+
386
411
test ( "exec tool with chat" , async ( ) => {
387
412
let err = undefined
388
413
const t = {
You can’t perform that action at this time.
0 commit comments