@@ -415,7 +415,7 @@ export class GPTScript {
415415 return JSON . parse ( result ) as Dataset
416416 }
417417
418- async addDatasetElement ( workspaceID : string , datasetID : string , elementName : string , elementDescription : string , elementContent : string ) : Promise < DatasetElementMeta > {
418+ async addDatasetElement ( workspaceID : string , datasetID : string , elementName : string , elementDescription : string , elementContent : ArrayBuffer ) : Promise < DatasetElementMeta > {
419419 if ( workspaceID == "" ) {
420420 workspaceID = process . env . GPTSCRIPT_WORKSPACE_ID ?? ""
421421 }
@@ -425,7 +425,7 @@ export class GPTScript {
425425 datasetID,
426426 elementName : elementName ,
427427 elementDescription : elementDescription ,
428- elementContent : elementContent
428+ elementContent : Buffer . from ( elementContent ) . toString ( "base64" )
429429 } ) ,
430430 workspaceID : workspaceID ,
431431 datasetToolRepo : this . opts . DatasetToolRepo ?? "" ,
@@ -439,8 +439,16 @@ export class GPTScript {
439439 workspaceID = process . env . GPTSCRIPT_WORKSPACE_ID ?? ""
440440 }
441441
442+ const serializableElements = elements . map ( e => {
443+ return {
444+ name : e . name ,
445+ description : e . description ,
446+ contents : Buffer . from ( e . contents ) . toString ( "base64" )
447+ }
448+ } )
449+
442450 return await this . runBasicCommand ( "datasets/add-elements" , {
443- input : JSON . stringify ( { datasetID, elements} ) ,
451+ input : JSON . stringify ( { datasetID, elements : serializableElements } ) ,
444452 workspaceID : workspaceID ,
445453 datasetToolRepo : this . opts . DatasetToolRepo ?? "" ,
446454 env : this . opts . Env ,
@@ -452,7 +460,6 @@ export class GPTScript {
452460 workspaceID = process . env . GPTSCRIPT_WORKSPACE_ID ?? ""
453461 }
454462
455-
456463 const result = await this . runBasicCommand ( "datasets/list-elements" , {
457464 input : JSON . stringify ( { datasetID} ) ,
458465 workspaceID : workspaceID ,
@@ -473,7 +480,13 @@ export class GPTScript {
473480 datasetToolRepo : this . opts . DatasetToolRepo ?? "" ,
474481 env : this . opts . Env
475482 } )
476- return JSON . parse ( result ) as DatasetElement
483+
484+ const element = JSON . parse ( result )
485+ return {
486+ name : element . name ,
487+ description : element . description ,
488+ contents : Buffer . from ( element . contents , "base64" )
489+ }
477490 }
478491
479492 async createWorkspace ( providerType : string , ...fromWorkspaces : string [ ] ) : Promise < string > {
@@ -1309,7 +1322,7 @@ export interface DatasetElementMeta {
13091322export interface DatasetElement {
13101323 name : string
13111324 description : string
1312- contents : string
1325+ contents : ArrayBuffer
13131326}
13141327
13151328export interface DatasetMeta {
0 commit comments