add recursive option for folder-loader
This commit is contained in:
parent
7faaf13ccc
commit
2bb2a7588a
|
|
@ -34,6 +34,12 @@ class Folder_DocumentLoaders implements INode {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
placeholder: ''
|
placeholder: ''
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Recursive',
|
||||||
|
name: 'recursive',
|
||||||
|
type: 'boolean',
|
||||||
|
additionalParams: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Text Splitter',
|
label: 'Text Splitter',
|
||||||
name: 'textSplitter',
|
name: 'textSplitter',
|
||||||
|
|
@ -54,8 +60,12 @@ class Folder_DocumentLoaders implements INode {
|
||||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||||
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 loader = new DirectoryLoader(folderPath, {
|
console.log('Recursive: ', recursive)
|
||||||
|
const loader = new DirectoryLoader(
|
||||||
|
folderPath,
|
||||||
|
{
|
||||||
'.json': (path) => new JSONLoader(path),
|
'.json': (path) => new JSONLoader(path),
|
||||||
'.txt': (path) => new TextLoader(path),
|
'.txt': (path) => new TextLoader(path),
|
||||||
'.csv': (path) => new CSVLoader(path),
|
'.csv': (path) => new CSVLoader(path),
|
||||||
|
|
@ -96,7 +106,9 @@ class Folder_DocumentLoaders implements INode {
|
||||||
'.html': (path) => new TextLoader(path), // HTML
|
'.html': (path) => new TextLoader(path), // HTML
|
||||||
'.vb': (path) => new TextLoader(path), // Visual Basic
|
'.vb': (path) => new TextLoader(path), // Visual Basic
|
||||||
'.xml': (path) => new TextLoader(path) // XML
|
'.xml': (path) => new TextLoader(path) // XML
|
||||||
})
|
},
|
||||||
|
recursive
|
||||||
|
)
|
||||||
let docs = []
|
let docs = []
|
||||||
|
|
||||||
if (textSplitter) {
|
if (textSplitter) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue