forked from FlowiseAI/Flowise
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request FlowiseAI#34 from FlowiseAI/feature/NotionLoader
add Notion loader
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/components/nodes/documentloaders/Notion/Notion.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { INode, INodeData, INodeParams } from '../../../src/Interface' | ||
import { TextSplitter } from 'langchain/text_splitter' | ||
import { NotionLoader } from 'langchain/document_loaders/fs/notion' | ||
|
||
class Notion_DocumentLoaders implements INode { | ||
label: string | ||
name: string | ||
description: string | ||
type: string | ||
icon: string | ||
category: string | ||
baseClasses: string[] | ||
inputs: INodeParams[] | ||
|
||
constructor() { | ||
this.label = 'Notion Folder' | ||
this.name = 'notionFolder' | ||
this.type = 'Document' | ||
this.icon = 'notion.png' | ||
this.category = 'Document Loaders' | ||
this.description = `Load data from Notion folder` | ||
this.baseClasses = [this.type] | ||
this.inputs = [ | ||
{ | ||
label: 'Notion Folder', | ||
name: 'notionFolder', | ||
type: 'string', | ||
description: 'Get folder path', | ||
placeholder: 'Paste folder path' | ||
}, | ||
{ | ||
label: 'Text Splitter', | ||
name: 'textSplitter', | ||
type: 'TextSplitter', | ||
optional: true | ||
} | ||
] | ||
} | ||
|
||
async init(nodeData: INodeData): Promise<any> { | ||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter | ||
const notionFolder = nodeData.inputs?.notionFolder as string | ||
|
||
const loader = new NotionLoader(notionFolder) | ||
|
||
if (textSplitter) { | ||
const docs = await loader.loadAndSplit(textSplitter) | ||
return docs | ||
} else { | ||
const docs = await loader.load() | ||
return docs | ||
} | ||
} | ||
} | ||
|
||
module.exports = { nodeClass: Notion_DocumentLoaders } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.