mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 11:01:22 +03:00
modify string to password
This commit is contained in:
+6
-5
@@ -1,6 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { NotionDBLoader } from 'langchain/document_loaders/web/notiondb'
|
||||
import { NotionDBLoader, NotionDBLoaderParams } from 'langchain/document_loaders/web/notiondb'
|
||||
|
||||
class NotionDB_DocumentLoaders implements INode {
|
||||
label: string
|
||||
@@ -37,7 +37,7 @@ class NotionDB_DocumentLoaders implements INode {
|
||||
{
|
||||
label: 'Notion Integration Token',
|
||||
name: 'notionIntegrationToken',
|
||||
type: 'string',
|
||||
type: 'password',
|
||||
description:
|
||||
'You can find integration token <a target="_blank" href="https://developers.notion.com/docs/create-a-notion-integration#step-1-create-an-integration">here</a>'
|
||||
},
|
||||
@@ -64,13 +64,14 @@ class NotionDB_DocumentLoaders implements INode {
|
||||
const pageSizeLimit = nodeData.inputs?.pageSizeLimit as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
|
||||
const loader = new NotionDBLoader({
|
||||
const obj: NotionDBLoaderParams = {
|
||||
pageSizeLimit: pageSizeLimit ? parseInt(pageSizeLimit, 10) : 10,
|
||||
databaseId,
|
||||
notionIntegrationToken
|
||||
})
|
||||
let docs = []
|
||||
}
|
||||
const loader = new NotionDBLoader(obj)
|
||||
|
||||
let docs = []
|
||||
if (textSplitter) {
|
||||
docs = await loader.loadAndSplit(textSplitter)
|
||||
} else {
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,81 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { NotionLoader } from 'langchain/document_loaders/fs/notion'
|
||||
|
||||
class NotionFolder_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
|
||||
},
|
||||
{
|
||||
label: 'Metadata',
|
||||
name: 'metadata',
|
||||
type: 'json',
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const notionFolder = nodeData.inputs?.notionFolder as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
|
||||
const loader = new NotionLoader(notionFolder)
|
||||
let docs = []
|
||||
|
||||
if (textSplitter) {
|
||||
docs = await loader.loadAndSplit(textSplitter)
|
||||
} else {
|
||||
docs = await loader.load()
|
||||
}
|
||||
|
||||
if (metadata) {
|
||||
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
|
||||
let finaldocs = []
|
||||
for (const doc of docs) {
|
||||
const newdoc = {
|
||||
...doc,
|
||||
metadata: {
|
||||
...doc.metadata,
|
||||
...parsedMetadata
|
||||
}
|
||||
}
|
||||
finaldocs.push(newdoc)
|
||||
}
|
||||
return finaldocs
|
||||
}
|
||||
|
||||
return docs
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: NotionFolder_DocumentLoaders }
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user