mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 05:01:10 +03:00
Merge branch 'main' of https://github.com/FlowiseAI/Flowise
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { CharacterTextSplitter, CharacterTextSplitterParams } from 'langchain/text_splitter'
|
||||
|
||||
class CharacterTextSplitter_TextSplitters implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Character Text Splitter'
|
||||
this.name = 'characterTextSplitter'
|
||||
this.type = 'CharacterTextSplitter'
|
||||
this.icon = 'textsplitter.svg'
|
||||
this.category = 'Text Splitters'
|
||||
this.description = `splits only on one type of character (defaults to "\\n\\n").`
|
||||
this.baseClasses = [this.type, ...getBaseClasses(CharacterTextSplitter)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Separator',
|
||||
name: 'separator',
|
||||
type: 'string',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Chunk Size',
|
||||
name: 'chunkSize',
|
||||
type: 'number',
|
||||
default: 1000,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Chunk Overlap',
|
||||
name: 'chunkOverlap',
|
||||
type: 'number',
|
||||
optional: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const separator = nodeData.inputs?.separator as string
|
||||
const chunkSize = nodeData.inputs?.chunkSize as string
|
||||
const chunkOverlap = nodeData.inputs?.chunkOverlap as string
|
||||
|
||||
const obj = {} as CharacterTextSplitterParams
|
||||
|
||||
if (separator) obj.separator = separator
|
||||
if (chunkSize) obj.chunkSize = parseInt(chunkSize, 10)
|
||||
if (chunkOverlap) obj.chunkOverlap = parseInt(chunkOverlap, 10)
|
||||
|
||||
const splitter = new CharacterTextSplitter(obj)
|
||||
|
||||
return splitter
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: CharacterTextSplitter_TextSplitters }
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-abc" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M3 16v-6a2 2 0 1 1 4 0v6"></path>
|
||||
<path d="M3 13h4"></path>
|
||||
<path d="M10 8v6a2 2 0 1 0 4 0v-1a2 2 0 1 0 -4 0v1"></path>
|
||||
<path d="M20.732 12a2 2 0 0 0 -3.732 1v1a2 2 0 0 0 3.726 1.01"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 502 B |
@@ -0,0 +1,55 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { MarkdownTextSplitter, MarkdownTextSplitterParams } from 'langchain/text_splitter'
|
||||
|
||||
class MarkdownTextSplitter_TextSplitters implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Markdown Text Splitter'
|
||||
this.name = 'markdownTextSplitter'
|
||||
this.type = 'MarkdownTextSplitter'
|
||||
this.icon = 'markdownTextSplitter.svg'
|
||||
this.category = 'Text Splitters'
|
||||
this.description = `Split your content into documents based on the Markdown headers`
|
||||
this.baseClasses = [this.type, ...getBaseClasses(MarkdownTextSplitter)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Chunk Size',
|
||||
name: 'chunkSize',
|
||||
type: 'number',
|
||||
default: 1000,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Chunk Overlap',
|
||||
name: 'chunkOverlap',
|
||||
type: 'number',
|
||||
optional: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const chunkSize = nodeData.inputs?.chunkSize as string
|
||||
const chunkOverlap = nodeData.inputs?.chunkOverlap as string
|
||||
|
||||
const obj = {} as MarkdownTextSplitterParams
|
||||
|
||||
if (chunkSize) obj.chunkSize = parseInt(chunkSize, 10)
|
||||
if (chunkOverlap) obj.chunkOverlap = parseInt(chunkOverlap, 10)
|
||||
|
||||
const splitter = new MarkdownTextSplitter(obj)
|
||||
|
||||
return splitter
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MarkdownTextSplitter_TextSplitters }
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-markdown" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M3 5m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z"></path>
|
||||
<path d="M7 15v-6l2 2l2 -2v6"></path>
|
||||
<path d="M14 13l2 2l2 -2m-2 2v-6"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 482 B |
+1
-1
@@ -18,7 +18,7 @@ class RecursiveCharacterTextSplitter_TextSplitters implements INode {
|
||||
this.type = 'RecursiveCharacterTextSplitter'
|
||||
this.icon = 'textsplitter.svg'
|
||||
this.category = 'Text Splitters'
|
||||
this.description = `Split documents recursively by different characters - starting with "\n\n", then "\n", then " "`
|
||||
this.description = `Split documents recursively by different characters - starting with "\\n\\n", then "\\n", then " "`
|
||||
this.baseClasses = [this.type, ...getBaseClasses(RecursiveCharacterTextSplitter)]
|
||||
this.inputs = [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { TokenTextSplitter, TokenTextSplitterParams } from 'langchain/text_splitter'
|
||||
import { TiktokenEncoding } from '@dqbd/tiktoken'
|
||||
|
||||
class TokenTextSplitter_TextSplitters implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Token Text Splitter'
|
||||
this.name = 'tokenTextSplitter'
|
||||
this.type = 'TokenTextSplitter'
|
||||
this.icon = 'tiktoken.svg'
|
||||
this.category = 'Text Splitters'
|
||||
this.description = `Splits a raw text string by first converting the text into BPE tokens, then split these tokens into chunks and convert the tokens within a single chunk back into text.`
|
||||
this.baseClasses = [this.type, ...getBaseClasses(TokenTextSplitter)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Encoding Name',
|
||||
name: 'encodingName',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
label: 'gpt2',
|
||||
name: 'gpt2'
|
||||
},
|
||||
{
|
||||
label: 'r50k_base',
|
||||
name: 'r50k_base'
|
||||
},
|
||||
{
|
||||
label: 'p50k_base',
|
||||
name: 'p50k_base'
|
||||
},
|
||||
{
|
||||
label: 'p50k_edit',
|
||||
name: 'p50k_edit'
|
||||
},
|
||||
{
|
||||
label: 'cl100k_base',
|
||||
name: 'cl100k_base'
|
||||
}
|
||||
],
|
||||
default: 'gpt2'
|
||||
},
|
||||
{
|
||||
label: 'Chunk Size',
|
||||
name: 'chunkSize',
|
||||
type: 'number',
|
||||
default: 1000,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Chunk Overlap',
|
||||
name: 'chunkOverlap',
|
||||
type: 'number',
|
||||
optional: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const encodingName = nodeData.inputs?.encodingName as string
|
||||
const chunkSize = nodeData.inputs?.chunkSize as string
|
||||
const chunkOverlap = nodeData.inputs?.chunkOverlap as string
|
||||
|
||||
const obj = {} as TokenTextSplitterParams
|
||||
|
||||
obj.encodingName = encodingName as TiktokenEncoding
|
||||
if (chunkSize) obj.chunkSize = parseInt(chunkSize, 10)
|
||||
if (chunkOverlap) obj.chunkOverlap = parseInt(chunkOverlap, 10)
|
||||
|
||||
const splitter = new TokenTextSplitter(obj)
|
||||
|
||||
return splitter
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: TokenTextSplitter_TextSplitters }
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-hourglass" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M6.5 7h11"></path>
|
||||
<path d="M6.5 17h11"></path>
|
||||
<path d="M6 20v-2a6 6 0 1 1 12 0v2a1 1 0 0 1 -1 1h-10a1 1 0 0 1 -1 -1z"></path>
|
||||
<path d="M6 4v2a6 6 0 1 0 12 0v-2a1 1 0 0 0 -1 -1h-10a1 1 0 0 0 -1 1z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 524 B |
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE.md",
|
||||
"dependencies": {
|
||||
"@dqbd/tiktoken": "^1.0.4",
|
||||
"@dqbd/tiktoken": "^1.0.7",
|
||||
"@huggingface/inference": "^1.6.3",
|
||||
"@pinecone-database/pinecone": "^0.0.12",
|
||||
"@supabase/supabase-js": "^2.21.0",
|
||||
|
||||
Reference in New Issue
Block a user