mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 09:01:06 +03:00
Feature: Add pdfUsage parameter setting support to folderFiles (#2211)
* Add pdfUsage parameter setting support to folderFiles * Add pdfUsage parameter setting additionalParams: true
This commit is contained in:
@@ -21,7 +21,7 @@ class Folder_DocumentLoaders implements INode {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Folder with Files'
|
this.label = 'Folder with Files'
|
||||||
this.name = 'folderFiles'
|
this.name = 'folderFiles'
|
||||||
this.version = 1.0
|
this.version = 2.0
|
||||||
this.type = 'Document'
|
this.type = 'Document'
|
||||||
this.icon = 'folder.svg'
|
this.icon = 'folder.svg'
|
||||||
this.category = 'Document Loaders'
|
this.category = 'Document Loaders'
|
||||||
@@ -46,6 +46,24 @@ class Folder_DocumentLoaders implements INode {
|
|||||||
type: 'TextSplitter',
|
type: 'TextSplitter',
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Pdf Usage',
|
||||||
|
name: 'pdfUsage',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'One document per page',
|
||||||
|
name: 'perPage'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'One document per file',
|
||||||
|
name: 'perFile'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
default: 'perPage',
|
||||||
|
optional: true,
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Metadata',
|
label: 'Metadata',
|
||||||
name: 'metadata',
|
name: 'metadata',
|
||||||
@@ -61,6 +79,7 @@ class Folder_DocumentLoaders implements INode {
|
|||||||
const folderPath = nodeData.inputs?.folderPath as string
|
const folderPath = nodeData.inputs?.folderPath as string
|
||||||
const metadata = nodeData.inputs?.metadata
|
const metadata = nodeData.inputs?.metadata
|
||||||
const recursive = nodeData.inputs?.recursive as boolean
|
const recursive = nodeData.inputs?.recursive as boolean
|
||||||
|
const pdfUsage = nodeData.inputs?.pdfUsage
|
||||||
|
|
||||||
const loader = new DirectoryLoader(
|
const loader = new DirectoryLoader(
|
||||||
folderPath,
|
folderPath,
|
||||||
@@ -69,8 +88,12 @@ class Folder_DocumentLoaders implements INode {
|
|||||||
'.txt': (path) => new TextLoader(path),
|
'.txt': (path) => new TextLoader(path),
|
||||||
'.csv': (path) => new CSVLoader(path),
|
'.csv': (path) => new CSVLoader(path),
|
||||||
'.docx': (path) => new DocxLoader(path),
|
'.docx': (path) => new DocxLoader(path),
|
||||||
// @ts-ignore
|
'.pdf': (path) =>
|
||||||
'.pdf': (path) => new PDFLoader(path, { pdfjs: () => import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js') }),
|
pdfUsage === 'perFile'
|
||||||
|
? // @ts-ignore
|
||||||
|
new PDFLoader(path, { splitPages: false, pdfjs: () => import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js') })
|
||||||
|
: // @ts-ignore
|
||||||
|
new PDFLoader(path, { pdfjs: () => import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js') }),
|
||||||
'.aspx': (path) => new TextLoader(path),
|
'.aspx': (path) => new TextLoader(path),
|
||||||
'.asp': (path) => new TextLoader(path),
|
'.asp': (path) => new TextLoader(path),
|
||||||
'.cpp': (path) => new TextLoader(path), // C++
|
'.cpp': (path) => new TextLoader(path), // C++
|
||||||
|
|||||||
Reference in New Issue
Block a user