mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Fix for #2386
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { ICommonObject, IDatabaseEntity, INode, INodeData, INodeOptionsValue, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
import { ICommonObject, IDatabaseEntity, INode, INodeData, INodeOptionsValue, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||||
import { DataSource } from 'typeorm'
|
import { DataSource } from 'typeorm'
|
||||||
import { Document } from '@langchain/core/documents'
|
import { Document } from '@langchain/core/documents'
|
||||||
|
import { handleEscapeCharacters } from '../../../src'
|
||||||
|
|
||||||
class DocStore_DocumentLoaders implements INode {
|
class DocStore_DocumentLoaders implements INode {
|
||||||
label: string
|
label: string
|
||||||
@@ -83,12 +84,22 @@ class DocStore_DocumentLoaders implements INode {
|
|||||||
const chunks = await appDataSource
|
const chunks = await appDataSource
|
||||||
.getRepository(databaseEntities['DocumentStoreFileChunk'])
|
.getRepository(databaseEntities['DocumentStoreFileChunk'])
|
||||||
.find({ where: { storeId: selectedStore } })
|
.find({ where: { storeId: selectedStore } })
|
||||||
|
const output = nodeData.outputs?.output as string
|
||||||
|
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
finalDocs.push(new Document({ pageContent: chunk.pageContent, metadata: JSON.parse(chunk.metadata) }))
|
finalDocs.push(new Document({ pageContent: chunk.pageContent, metadata: JSON.parse(chunk.metadata) }))
|
||||||
}
|
}
|
||||||
return finalDocs
|
|
||||||
|
if (output === 'document') {
|
||||||
|
return finalDocs
|
||||||
|
} else {
|
||||||
|
let finaltext = ''
|
||||||
|
for (const doc of finalDocs) {
|
||||||
|
finaltext += `${doc.pageContent}\n`
|
||||||
|
}
|
||||||
|
return handleEscapeCharacters(finaltext, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user