Redis Vector Store - Minor Updates to Options to better reflect the intent.

This commit is contained in:
vinodkiran 2023-10-25 10:35:50 +05:30
parent 23c62bdc0b
commit ac12aa641c
3 changed files with 9 additions and 9 deletions

View File

@ -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<Record<string, any>>[] | undefined
): Promise<VectorStore>
@ -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'

View File

@ -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<Record<string, any>>[]
): Promise<VectorStore> {
const storeConfig: RedisVectorStoreConfig = {

View File

@ -26,14 +26,14 @@ class RedisUpsert_VectorStores extends RedisSearchBase implements INode {
async constructVectorStore(
embeddings: Embeddings,
indexName: string,
deleteIndex: boolean,
replaceIndex: boolean,
docs: Document<Record<string, any>>[]
): Promise<VectorStore> {
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