File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -215,16 +215,16 @@ export class GPTScript {
215215 const nodes : any [ ] = [ ]
216216
217217 for ( const block of blocks ) {
218- if ( block . type === "tool " ) {
218+ if ( block . type === "text " ) {
219219 nodes . push ( {
220- toolNode : {
221- tool : block
220+ textNode : {
221+ text : "!" + ( block . format || "text" ) + "\n" + block . content
222222 }
223223 } )
224- } else if ( block . type === "text" ) {
224+ } else {
225225 nodes . push ( {
226- textNode : {
227- text : "!" + ( block . format || "text" ) + "\n" + block . content
226+ toolNode : {
227+ tool : block
228228 }
229229 } )
230230 }
Original file line number Diff line number Diff line change @@ -383,6 +383,31 @@ describe("gptscript module", () => {
383383 expect ( response ) . toContain ( "Parameter: text: The text to write" )
384384 } )
385385
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+
386411 test ( "exec tool with chat" , async ( ) => {
387412 let err = undefined
388413 const t = {
You can’t perform that action at this time.
0 commit comments