Skip to content

Commit 95f1090

Browse files
authored
BugFix FlowiseAI#2386: Double quotes are not escaped, flow crashes (FlowiseAI#2448)
Fix for FlowiseAI#2386
1 parent 5733a80 commit 95f1090

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/components/nodes/documentloaders/DocumentStore/DocStoreLoader.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ICommonObject, IDatabaseEntity, INode, INodeData, INodeOptionsValue, INodeOutputsValue, INodeParams } from '../../../src/Interface'
22
import { DataSource } from 'typeorm'
33
import { Document } from '@langchain/core/documents'
4+
import { handleEscapeCharacters } from '../../../src'
45

56
class DocStore_DocumentLoaders implements INode {
67
label: string
@@ -83,12 +84,22 @@ class DocStore_DocumentLoaders implements INode {
8384
const chunks = await appDataSource
8485
.getRepository(databaseEntities['DocumentStoreFileChunk'])
8586
.find({ where: { storeId: selectedStore } })
87+
const output = nodeData.outputs?.output as string
8688

8789
const finalDocs = []
8890
for (const chunk of chunks) {
8991
finalDocs.push(new Document({ pageContent: chunk.pageContent, metadata: JSON.parse(chunk.metadata) }))
9092
}
91-
return finalDocs
93+
94+
if (output === 'document') {
95+
return finalDocs
96+
} else {
97+
let finaltext = ''
98+
for (const doc of finalDocs) {
99+
finaltext += `${doc.pageContent}\n`
100+
}
101+
return handleEscapeCharacters(finaltext, false)
102+
}
92103
}
93104
}
94105

0 commit comments

Comments
 (0)