MCPcopy
hub / github.com/FlowiseAI/Flowise / MultiFileLoader

Class MultiFileLoader

packages/components/nodes/documentloaders/File/File.ts:362–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362class MultiFileLoader extends BaseDocumentLoader {
363 constructor(public fileBlobs: { blob: Blob; ext: string }[], public loaders: LoadersMapping) {
364 super()
365
366 if (Object.keys(loaders).length === 0) {
367 throw new Error('Must provide at least one loader')
368 }
369 }
370
371 public async load(): Promise<Document[]> {
372 const documents: Document[] = []
373
374 for (const fileBlob of this.fileBlobs) {
375 const loaderFactory = this.loaders[fileBlob.ext]
376 if (loaderFactory) {
377 const loader = loaderFactory(fileBlob.blob)
378 documents.push(...(await loader.load()))
379 } else {
380 const loader = new TextLoader(fileBlob.blob)
381 try {
382 documents.push(...(await loader.load()))
383 } catch (error) {
384 throw new Error(`Error loading file`)
385 }
386 }
387 }
388
389 return documents
390 }
391}
392
393module.exports = { nodeClass: File_DocumentLoaders }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected