Class that provides methods for creating and managing a collection of documents in an AnalyticDB, adding documents or vectors to the collection, performing similarity search on vectors, and creating an instance of AnalyticDBVectorStore from texts or documents.

Hierarchy

Constructors

Properties

FilterType: Record<string, any>
embeddings: Embeddings
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

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

  • Adds an array of documents to the collection. The documents are first converted to vectors using the embedDocuments method of the embeddings instance.

    Parameters

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

      Array of Document instances to be added to the collection.

    Returns Promise<void>

    Promise that resolves when the documents are added.

  • Adds an array of vectors and corresponding documents to the collection. The vectors and documents are batch inserted into the database.

    Parameters

    • vectors: number[][]

      Array of vectors to be added to the collection.

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

      Array of Document instances corresponding to the vectors.

    Returns Promise<void>

    Promise that resolves when the vectors and documents are added.

  • Creates a new collection in the database. If preDeleteCollection is true, any existing collection with the same name is deleted before the new collection is created.

    Returns Promise<void>

    Promise that resolves when the collection is created.

  • Creates a new table in the database if it does not already exist. The table is created with columns for id, embedding, document, and metadata. An index is also created on the embedding column if it does not already exist.

    Returns Promise<void>

    Promise that resolves when the table and index are created.

  • Deletes the collection from the database if it exists.

    Returns Promise<void>

    Promise that resolves when the collection is deleted.

  • Closes all the clients in the pool and terminates the pool.

    Returns Promise<void>

    Promise that resolves when all clients are closed and the pool is terminated.

  • Performs a similarity search on the vectors in the collection. The search is performed using the given query vector and returns the top k most similar vectors along with their corresponding documents and similarity scores.

    Parameters

    • query: number[]

      Query vector for the similarity search.

    • k: number

      Number of top similar vectors to return.

    • Optional filter: Record<string, any>

      Optional. Filter to apply on the metadata of the documents.

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

    Promise that resolves to an array of tuples, each containing a Document instance and its similarity score.

  • Creates an instance of AnalyticDBVectorStore from an array of texts and corresponding metadata. The texts are first converted to Document instances before being added to the collection.

    Parameters

    • texts: string[]

      Array of texts to be added to the collection.

    • metadatas: object | object[]

      Array or object of metadata corresponding to the texts.

    • embeddings: Embeddings

      Embeddings instance used to convert the texts to vectors.

    • dbConfig: AnalyticDBArgs

      Configuration for the AnalyticDB.

    Returns Promise<AnalyticDBVectorStore>

    Promise that resolves to an instance of AnalyticDBVectorStore.

  • 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