Redis Vector Store - Minor Updates to Options to better reflect the intent.
This commit is contained in:
parent
23c62bdc0b
commit
ac12aa641c
|
|
@ -53,9 +53,9 @@ export abstract class RedisSearchBase {
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Delete and Recreate the Index (will remove all contents as well) ?',
|
label: 'Replace Index?',
|
||||||
name: 'deleteIndex',
|
name: 'replaceIndex',
|
||||||
description: 'Delete the index if it already exists',
|
description: 'Selecting this option will delete the existing index and recreate a new one',
|
||||||
default: false,
|
default: false,
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
},
|
},
|
||||||
|
|
@ -113,7 +113,7 @@ export abstract class RedisSearchBase {
|
||||||
abstract constructVectorStore(
|
abstract constructVectorStore(
|
||||||
embeddings: Embeddings,
|
embeddings: Embeddings,
|
||||||
indexName: string,
|
indexName: string,
|
||||||
deleteIndex: boolean,
|
replaceIndex: boolean,
|
||||||
docs: Document<Record<string, any>>[] | undefined
|
docs: Document<Record<string, any>>[] | undefined
|
||||||
): Promise<VectorStore>
|
): Promise<VectorStore>
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ export abstract class RedisSearchBase {
|
||||||
let vectorKey = nodeData.inputs?.vectorKey as string
|
let vectorKey = nodeData.inputs?.vectorKey as string
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
const topK = nodeData.inputs?.topK as string
|
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 k = topK ? parseFloat(topK) : 4
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ export abstract class RedisSearchBase {
|
||||||
this.redisClient = createClient({ url: redisUrl })
|
this.redisClient = createClient({ url: redisUrl })
|
||||||
await this.redisClient.connect()
|
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 (!contentKey || contentKey === '') contentKey = 'content'
|
||||||
if (!metadataKey || metadataKey === '') metadataKey = 'metadata'
|
if (!metadataKey || metadataKey === '') metadataKey = 'metadata'
|
||||||
if (!vectorKey || vectorKey === '') vectorKey = 'content_vector'
|
if (!vectorKey || vectorKey === '') vectorKey = 'content_vector'
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class RedisExisting_VectorStores extends RedisSearchBase implements INode {
|
||||||
embeddings: Embeddings,
|
embeddings: Embeddings,
|
||||||
indexName: string,
|
indexName: string,
|
||||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
||||||
deleteIndex: boolean,
|
replaceIndex: boolean,
|
||||||
_: Document<Record<string, any>>[]
|
_: Document<Record<string, any>>[]
|
||||||
): Promise<VectorStore> {
|
): Promise<VectorStore> {
|
||||||
const storeConfig: RedisVectorStoreConfig = {
|
const storeConfig: RedisVectorStoreConfig = {
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ class RedisUpsert_VectorStores extends RedisSearchBase implements INode {
|
||||||
async constructVectorStore(
|
async constructVectorStore(
|
||||||
embeddings: Embeddings,
|
embeddings: Embeddings,
|
||||||
indexName: string,
|
indexName: string,
|
||||||
deleteIndex: boolean,
|
replaceIndex: boolean,
|
||||||
docs: Document<Record<string, any>>[]
|
docs: Document<Record<string, any>>[]
|
||||||
): Promise<VectorStore> {
|
): Promise<VectorStore> {
|
||||||
const storeConfig: RedisVectorStoreConfig = {
|
const storeConfig: RedisVectorStoreConfig = {
|
||||||
redisClient: this.redisClient,
|
redisClient: this.redisClient,
|
||||||
indexName: indexName
|
indexName: indexName
|
||||||
}
|
}
|
||||||
if (deleteIndex) {
|
if (replaceIndex) {
|
||||||
let response = await this.redisClient.ft.dropIndex(indexName)
|
let response = await this.redisClient.ft.dropIndex(indexName)
|
||||||
if (process.env.DEBUG === 'true') {
|
if (process.env.DEBUG === 'true') {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue