Class representing a RedisVectorStore. It extends the VectorStore class and includes methods for adding documents and vectors, performing similarity searches, managing the index, and more.

Hierarchy

Constructors

Properties

contentKey: string
createIndexOptions: CreateOptions
embeddings: Embeddings
indexName: string
keyPrefix: string
lc_kwargs: SerializedFields
lc_namespace: string[] = ...

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

lc_serializable: boolean = false
metadataKey: string
vectorKey: string

Accessors

  • get lc_aliases(): undefined | {
        [key: string]: string;
    }
  • A map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.

    Returns undefined | {
        [key: string]: string;
    }

  • get lc_attributes(): undefined | SerializedFields
  • A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.

    Returns undefined | SerializedFields

  • get lc_secrets(): undefined | {
        [key: string]: string;
    }
  • A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.

    Returns undefined | {
        [key: string]: string;
    }

Methods

  • Method for adding documents to the RedisVectorStore. It first converts the documents to texts and then adds them as vectors.

    Parameters

    • documents: Document<Record<string, any>>[]

      The documents to add.

    • Optional options: RedisAddOptions

      Optional parameters for adding the documents.

    Returns Promise<void>

    A promise that resolves when the documents have been added.

  • Method for adding vectors to the RedisVectorStore. It checks if the index exists and creates it if it doesn't, then adds the vectors in batches.

    Parameters

    • vectors: number[][]

      The vectors to add.

    • documents: Document<Record<string, any>>[]

      The documents associated with the vectors.

    • __namedParameters: RedisAddOptions = {}

    Returns Promise<void>

    A promise that resolves when the vectors have been added.

  • Method for checking if an index exists in the RedisVectorStore.

    Returns Promise<boolean>

    A promise that resolves to a boolean indicating whether the index exists.

  • Method for creating an index in the RedisVectorStore. If the index already exists, it does nothing.

    Parameters

    • dimensions: number = 1536

      The dimensions of the index

    Returns Promise<void>

    A promise that resolves when the index has been created.

  • Deletes vectors from the vector store.

    Parameters

    • params: {
          deleteAll: boolean;
      }

      The parameters for deleting vectors.

      • deleteAll: boolean

    Returns Promise<void>

    A promise that resolves when the vectors have been deleted.

  • Method for dropping an index from the RedisVectorStore.

    Parameters

    • Optional deleteDocuments: boolean

      Optional boolean indicating whether to drop the associated documents.

    Returns Promise<boolean>

    A promise that resolves to a boolean indicating whether the index was dropped.

  • Method for performing a similarity search in the RedisVectorStore. It returns the documents and their scores.

    Parameters

    • query: number[]

      The query vector.

    • k: number

      The number of nearest neighbors to return.

    • Optional filter: RedisVectorStoreFilterType

      Optional filter to apply to the search.

    Returns Promise<[Document<Record<string, any>>, number][]>

    A promise that resolves to an array of documents and their scores.

  • Static method for creating a new instance of RedisVectorStore from texts. It creates documents from the texts and metadata, then adds them to the RedisVectorStore.

    Parameters

    • texts: string[]

      The texts to add.

    • metadatas: object | object[]

      The metadata associated with the texts.

    • embeddings: Embeddings

      The embeddings to use.

    • dbConfig: RedisVectorStoreConfig

      The configuration for the RedisVectorStore.

    Returns Promise<RedisVectorStore>

    A promise that resolves to a new instance of RedisVectorStore.

  • The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

    Implemented as a static method to support loading logic.

    Returns string

Generated using TypeDoc