Merge branch 'main' into feature/CustomTool

This commit is contained in:
Henry
2023-06-22 16:17:26 +01:00
9 changed files with 150 additions and 7 deletions
@@ -0,0 +1,106 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { JSONLinesLoader } from 'langchain/document_loaders/fs/json'
class Jsonlines_DocumentLoaders implements INode {
label: string
name: string
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs: INodeParams[]
constructor() {
this.label = 'Json Lines File'
this.name = 'jsonlinesFile'
this.type = 'Document'
this.icon = 'jsonlines.svg'
this.category = 'Document Loaders'
this.description = `Load data from JSON Lines files`
this.baseClasses = [this.type]
this.inputs = [
{
label: 'Jsonlines File',
name: 'jsonlinesFile',
type: 'file',
fileType: '.jsonl'
},
{
label: 'Text Splitter',
name: 'textSplitter',
type: 'TextSplitter',
optional: true
},
{
label: 'Pointer Extraction',
name: 'pointerName',
type: 'string',
placeholder: 'Enter pointer name',
optional: false
},
{
label: 'Metadata',
name: 'metadata',
type: 'json',
optional: true,
additionalParams: true
}
]
}
async init(nodeData: INodeData): Promise<any> {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const jsonLinesFileBase64 = nodeData.inputs?.jsonlinesFile as string
const pointerName = nodeData.inputs?.pointerName as string
const metadata = nodeData.inputs?.metadata
let alldocs = []
let files: string[] = []
let pointer = '/' + pointerName.trim()
if (jsonLinesFileBase64.startsWith('[') && jsonLinesFileBase64.endsWith(']')) {
files = JSON.parse(jsonLinesFileBase64)
} else {
files = [jsonLinesFileBase64]
}
for (const file of files) {
const splitDataURI = file.split(',')
splitDataURI.pop()
const bf = Buffer.from(splitDataURI.pop() || '', 'base64')
const blob = new Blob([bf])
const loader = new JSONLinesLoader(blob, pointer)
if (textSplitter) {
const docs = await loader.loadAndSplit(textSplitter)
alldocs.push(...docs)
} else {
const docs = await loader.load()
alldocs.push(...docs)
}
}
if (metadata) {
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
let finaldocs = []
for (const doc of alldocs) {
const newdoc = {
...doc,
metadata: {
...doc.metadata,
...parsedMetadata
}
}
finaldocs.push(newdoc)
}
return finaldocs
}
return alldocs
}
}
module.exports = { nodeClass: Jsonlines_DocumentLoaders }
@@ -0,0 +1,16 @@
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
<!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ -->
<g>
<title>background</title>
<rect fill="none" id="canvas_background" height="26" width="26" y="-1" x="-1"/>
<g display="none" overflow="visible" y="0" x="0" height="100%" width="100%" id="canvasGrid">
<rect fill="url(#gridpattern)" stroke-width="0" y="0" x="0" height="100%" width="100%"/>
</g>
</g>
<g>
<title>Layer 1</title>
<text font-weight="bold" stroke="#000" transform="matrix(8.682896011956823,0,0,10.412942243751806,-30.866304860177404,-63.784276261342) " xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="1" id="svg_2" y="7.062874" x="3.579384" stroke-opacity="null" stroke-width="0" fill="#000000">JSON</text>
<text font-weight="bold" stroke="#000" transform="matrix(9.059566511875573,0,0,9.893934811310315,-1.3962337706973242,-106.08964247698567) " xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="1" id="svg_3" y="12.90427" x="0.172236" stroke-opacity="null" stroke-width="0" fill="#000000">Lines</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+1
View File
@@ -1,4 +1,5 @@
PORT=3000
# FLOWISE_USERNAME=user
# FLOWISE_PASSWORD=1234
# DATABASE_PATH=/your_database_path/.flowise
# EXECUTION_MODE=child or main
+19 -5
View File
@@ -31,14 +31,28 @@ FLOWISE_PASSWORD=1234
## 📖 Documentation
Coming Soon
## 💻 Cloud Hosted
Coming Soon
[Flowise Docs](https://docs.flowiseai.com/)
## 🌐 Self Host
### [Railway](https://docs.flowiseai.com/deployment/railway)
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/YK7J0v)
### [Render](https://docs.flowiseai.com/deployment/render)
[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://docs.flowiseai.com/deployment/render)
### [AWS](https://docs.flowiseai.com/deployment/aws)
### [Azure](https://docs.flowiseai.com/deployment/azure)
### [DigitalOcean](https://docs.flowiseai.com/deployment/digital-ocean)
### [GCP](https://docs.flowiseai.com/deployment/gcp)
## 💻 Cloud Hosted
Coming Soon
## 🙋 Support
+1 -1
View File
@@ -9,7 +9,7 @@ import { getUserHome } from './utils'
let appDataSource: DataSource
export const init = async (): Promise<void> => {
const homePath = path.join(getUserHome(), '.flowise')
const homePath = process.env.DATABASE_PATH ?? path.join(getUserHome(), '.flowise')
appDataSource = new DataSource({
type: 'sqlite',
+2
View File
@@ -18,6 +18,7 @@ export default class Start extends Command {
FLOWISE_USERNAME: Flags.string(),
FLOWISE_PASSWORD: Flags.string(),
PORT: Flags.string(),
DATABASE_PATH: Flags.string(),
EXECUTION_MODE: Flags.string()
}
@@ -53,6 +54,7 @@ export default class Start extends Command {
if (flags.FLOWISE_USERNAME) process.env.FLOWISE_USERNAME = flags.FLOWISE_USERNAME
if (flags.FLOWISE_PASSWORD) process.env.FLOWISE_PASSWORD = flags.FLOWISE_PASSWORD
if (flags.PORT) process.env.PORT = flags.PORT
if (flags.DATABASE_PATH) process.env.DATABASE_PATH = flags.DATABASE_PATH
if (flags.EXECUTION_MODE) process.env.EXECUTION_MODE = flags.EXECUTION_MODE
await (async () => {