mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Chore/LC v0.3 (#3517)
* bump langchain version to 0.3, upgrades on all chat models * update all docs loader to have documents and text output options * fix pnpm lock file
This commit is contained in:
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
|
||||
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import jsonpointer from 'jsonpointer'
|
||||
import { getFileFromStorage } from '../../../src'
|
||||
import { getFileFromStorage, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
|
||||
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import type { readFile as ReadFileT } from 'node:fs/promises'
|
||||
@@ -37,11 +37,12 @@ class Jsonlines_DocumentLoaders implements INode {
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
outputs: INodeOutputsValue[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Json Lines File'
|
||||
this.name = 'jsonlinesFile'
|
||||
this.version = 2.0
|
||||
this.version = 3.0
|
||||
this.type = 'Document'
|
||||
this.icon = 'jsonlines.svg'
|
||||
this.category = 'Document Loaders'
|
||||
@@ -93,6 +94,20 @@ class Jsonlines_DocumentLoaders implements INode {
|
||||
additionalParams: true
|
||||
}
|
||||
]
|
||||
this.outputs = [
|
||||
{
|
||||
label: 'Document',
|
||||
name: 'document',
|
||||
description: 'Array of document objects containing metadata and pageContent',
|
||||
baseClasses: [...this.baseClasses, 'json']
|
||||
},
|
||||
{
|
||||
label: 'Text',
|
||||
name: 'text',
|
||||
description: 'Concatenated string from pageContent of documents',
|
||||
baseClasses: ['string', 'json']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
@@ -101,6 +116,7 @@ class Jsonlines_DocumentLoaders implements INode {
|
||||
const pointerName = nodeData.inputs?.pointerName as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
|
||||
const output = nodeData.outputs?.output as string
|
||||
|
||||
let omitMetadataKeys: string[] = []
|
||||
if (_omitMetadataKeys) {
|
||||
@@ -193,7 +209,15 @@ class Jsonlines_DocumentLoaders implements INode {
|
||||
}))
|
||||
}
|
||||
|
||||
return docs
|
||||
if (output === 'document') {
|
||||
return docs
|
||||
} else {
|
||||
let finaltext = ''
|
||||
for (const doc of docs) {
|
||||
finaltext += `${doc.pageContent}\n`
|
||||
}
|
||||
return handleEscapeCharacters(finaltext, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user