mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
add check before adding new document
This commit is contained in:
@@ -71,8 +71,10 @@ class ConversationChain_Chains implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let finalText = ''
|
let finalText = ''
|
||||||
for (let i = 0; i < finalDocs.length; i += 1) {
|
for (let i = 0; i < finalDocs.length; i += 1) {
|
||||||
|
|||||||
@@ -98,8 +98,10 @@ class ChromaUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const obj: {
|
const obj: {
|
||||||
collectionName: string
|
collectionName: string
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ class ElasicsearchUpsert_VectorStores extends ElasticSearchBase implements INode
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The following code is a workaround for a bug (Langchain Issue #1589) in the underlying library.
|
// The following code is a workaround for a bug (Langchain Issue #1589) in the underlying library.
|
||||||
// Store does not support object in metadata and fail silently
|
// Store does not support object in metadata and fail silently
|
||||||
|
|||||||
@@ -80,8 +80,10 @@ class FaissUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vectorStore = await FaissStore.fromDocuments(finalDocs, embeddings)
|
const vectorStore = await FaissStore.fromDocuments(finalDocs, embeddings)
|
||||||
await vectorStore.save(basePath)
|
await vectorStore.save(basePath)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class InMemoryVectorStore_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
if (flattenDocs[i] !== undefined && flattenDocs[i].pageContent !== undefined) {
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,8 +110,10 @@ class Milvus_Upsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vectorStore = await MilvusUpsert.fromDocuments(finalDocs, embeddings, milVusArgs)
|
const vectorStore = await MilvusUpsert.fromDocuments(finalDocs, embeddings, milVusArgs)
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,10 @@ class OpenSearchUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
nodes: [opensearchURL]
|
nodes: [opensearchURL]
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ class PineconeUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const obj: PineconeLibArgs = {
|
const obj: PineconeLibArgs = {
|
||||||
pineconeIndex
|
pineconeIndex
|
||||||
|
|||||||
@@ -143,8 +143,10 @@ class PostgresUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vectorStore = await TypeORMVectorStore.fromDocuments(finalDocs, embeddings, args)
|
const vectorStore = await TypeORMVectorStore.fromDocuments(finalDocs, embeddings, args)
|
||||||
|
|
||||||
|
|||||||
@@ -147,8 +147,10 @@ class QdrantUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const dbConfig: QdrantLibArgs = {
|
const dbConfig: QdrantLibArgs = {
|
||||||
client,
|
client,
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ class RedisUpsert_VectorStores extends RedisSearchBase implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
const document = new Document(flattenDocs[i])
|
const document = new Document(flattenDocs[i])
|
||||||
escapeAllStrings(document.metadata)
|
escapeAllStrings(document.metadata)
|
||||||
finalDocs.push(document)
|
finalDocs.push(document)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.init(nodeData, _, options, flattenDocs)
|
return super.init(nodeData, _, options, flattenDocs)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,8 +140,10 @@ class SingleStoreUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let vectorStore: SingleStoreVectorStore
|
let vectorStore: SingleStoreVectorStore
|
||||||
|
|
||||||
|
|||||||
@@ -132,8 +132,10 @@ class VectaraUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vectorStore = await VectaraStore.fromDocuments(finalDocs, embeddings, vectaraArgs)
|
const vectorStore = await VectaraStore.fromDocuments(finalDocs, embeddings, vectaraArgs)
|
||||||
|
|
||||||
|
|||||||
@@ -143,8 +143,10 @@ class WeaviateUpsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const obj: WeaviateLibArgs = {
|
const obj: WeaviateLibArgs = {
|
||||||
client,
|
client,
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ class Zep_Upsert_VectorStores implements INode {
|
|||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
|
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const zepConfig: IZepConfig = {
|
const zepConfig: IZepConfig = {
|
||||||
apiUrl: baseURL,
|
apiUrl: baseURL,
|
||||||
|
|||||||
Reference in New Issue
Block a user