@@ -415,7 +415,7 @@ export class GPTScript {
415
415
return JSON . parse ( result ) as Dataset
416
416
}
417
417
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 > {
419
419
if ( workspaceID == "" ) {
420
420
workspaceID = process . env . GPTSCRIPT_WORKSPACE_ID ?? ""
421
421
}
@@ -425,7 +425,7 @@ export class GPTScript {
425
425
datasetID,
426
426
elementName : elementName ,
427
427
elementDescription : elementDescription ,
428
- elementContent : elementContent
428
+ elementContent : Buffer . from ( elementContent ) . toString ( "base64" )
429
429
} ) ,
430
430
workspaceID : workspaceID ,
431
431
datasetToolRepo : this . opts . DatasetToolRepo ?? "" ,
@@ -439,8 +439,16 @@ export class GPTScript {
439
439
workspaceID = process . env . GPTSCRIPT_WORKSPACE_ID ?? ""
440
440
}
441
441
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
+
442
450
return await this . runBasicCommand ( "datasets/add-elements" , {
443
- input : JSON . stringify ( { datasetID, elements} ) ,
451
+ input : JSON . stringify ( { datasetID, elements : serializableElements } ) ,
444
452
workspaceID : workspaceID ,
445
453
datasetToolRepo : this . opts . DatasetToolRepo ?? "" ,
446
454
env : this . opts . Env ,
@@ -452,7 +460,6 @@ export class GPTScript {
452
460
workspaceID = process . env . GPTSCRIPT_WORKSPACE_ID ?? ""
453
461
}
454
462
455
-
456
463
const result = await this . runBasicCommand ( "datasets/list-elements" , {
457
464
input : JSON . stringify ( { datasetID} ) ,
458
465
workspaceID : workspaceID ,
@@ -473,7 +480,13 @@ export class GPTScript {
473
480
datasetToolRepo : this . opts . DatasetToolRepo ?? "" ,
474
481
env : this . opts . Env
475
482
} )
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
+ }
477
490
}
478
491
479
492
async createWorkspace ( providerType : string , ...fromWorkspaces : string [ ] ) : Promise < string > {
@@ -1309,7 +1322,7 @@ export interface DatasetElementMeta {
1309
1322
export interface DatasetElement {
1310
1323
name : string
1311
1324
description : string
1312
- contents : string
1325
+ contents : ArrayBuffer
1313
1326
}
1314
1327
1315
1328
export interface DatasetMeta {
0 commit comments