From ac12aa641c8c0df945317b1a186f1e81bd7aba93 Mon Sep 17 00:00:00 2001 From: vinodkiran Date: Wed, 25 Oct 2023 10:35:50 +0530 Subject: [PATCH] Redis Vector Store - Minor Updates to Options to better reflect the intent. --- .../nodes/vectorstores/Redis/RedisSearchBase.ts | 12 ++++++------ .../nodes/vectorstores/Redis/Redis_Existing.ts | 2 +- .../nodes/vectorstores/Redis/Redis_Upsert.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts b/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts index e7fb5f112..9d1c2ea13 100644 --- a/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts +++ b/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts @@ -53,9 +53,9 @@ export abstract class RedisSearchBase { type: 'string' }, { - label: 'Delete and Recreate the Index (will remove all contents as well) ?', - name: 'deleteIndex', - description: 'Delete the index if it already exists', + label: 'Replace Index?', + name: 'replaceIndex', + description: 'Selecting this option will delete the existing index and recreate a new one', default: false, type: 'boolean' }, @@ -113,7 +113,7 @@ export abstract class RedisSearchBase { abstract constructVectorStore( embeddings: Embeddings, indexName: string, - deleteIndex: boolean, + replaceIndex: boolean, docs: Document>[] | undefined ): Promise @@ -125,7 +125,7 @@ export abstract class RedisSearchBase { let vectorKey = nodeData.inputs?.vectorKey as string const embeddings = nodeData.inputs?.embeddings as Embeddings const topK = nodeData.inputs?.topK as string - const deleteIndex = nodeData.inputs?.deleteIndex as boolean + const replaceIndex = nodeData.inputs?.replaceIndex as boolean const k = topK ? parseFloat(topK) : 4 const output = nodeData.outputs?.output as string @@ -142,7 +142,7 @@ export abstract class RedisSearchBase { this.redisClient = createClient({ url: redisUrl }) await this.redisClient.connect() - const vectorStore = await this.constructVectorStore(embeddings, indexName, deleteIndex, docs) + const vectorStore = await this.constructVectorStore(embeddings, indexName, replaceIndex, docs) if (!contentKey || contentKey === '') contentKey = 'content' if (!metadataKey || metadataKey === '') metadataKey = 'metadata' if (!vectorKey || vectorKey === '') vectorKey = 'content_vector' diff --git a/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts b/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts index 754e46c8b..9ad472a80 100644 --- a/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts +++ b/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts @@ -23,7 +23,7 @@ class RedisExisting_VectorStores extends RedisSearchBase implements INode { embeddings: Embeddings, indexName: string, // eslint-disable-next-line unused-imports/no-unused-vars - deleteIndex: boolean, + replaceIndex: boolean, _: Document>[] ): Promise { const storeConfig: RedisVectorStoreConfig = { diff --git a/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts b/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts index 6637e703b..0ed431fb5 100644 --- a/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts +++ b/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts @@ -26,14 +26,14 @@ class RedisUpsert_VectorStores extends RedisSearchBase implements INode { async constructVectorStore( embeddings: Embeddings, indexName: string, - deleteIndex: boolean, + replaceIndex: boolean, docs: Document>[] ): Promise { const storeConfig: RedisVectorStoreConfig = { redisClient: this.redisClient, indexName: indexName } - if (deleteIndex) { + if (replaceIndex) { let response = await this.redisClient.ft.dropIndex(indexName) if (process.env.DEBUG === 'true') { // eslint-disable-next-line no-console