File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
templates/components/vectordbs/typescript/llamacloud Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,24 @@ async function loadAndIndex() {
32
32
for await ( const filePath of walk ( DATA_DIR ) ) {
33
33
const buffer = await fs . readFile ( filePath ) ;
34
34
const filename = path . basename ( filePath ) ;
35
- const file = new File ( [ buffer ] , filename ) ;
36
- await LLamaCloudFileService . addFileToPipeline ( projectId , pipelineId , file , {
37
- private : "false" ,
38
- } ) ;
35
+ try {
36
+ await LLamaCloudFileService . addFileToPipeline (
37
+ projectId ,
38
+ pipelineId ,
39
+ new File ( [ buffer ] , filename ) ,
40
+ { private : "false" } ,
41
+ ) ;
42
+ } catch ( error ) {
43
+ if (
44
+ error instanceof ReferenceError &&
45
+ error . message . includes ( "File is not defined" )
46
+ ) {
47
+ throw new Error (
48
+ "File class is not supported in the current Node.js version. Please use Node.js 20 or higher." ,
49
+ ) ;
50
+ }
51
+ throw error ;
52
+ }
39
53
}
40
54
41
55
console . log ( `Successfully uploaded documents to LlamaCloud!` ) ;
You can’t perform that action at this time.
0 commit comments