Azure Cosmos DB for NoSQL vCore vector store. To use this, you should have both:

  • the @azure/cosmos NPM package installed
  • a connection string associated with a NoSQL instance

You do not need to create a database or container, it will be created automatically.

Hierarchy (view full)

  • Toolkit
    • AzureCosmosDBNoSQLVectorStore

Constructors

Properties

initialize: (() => Promise<void>)

Initializes the AzureCosmosDBNoSQLVectorStore. Connect the client to the database and create the container, creating them if needed.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

      A promise that resolves when the AzureCosmosDBNoSQLVectorStore has been initialized.

Methods

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

    Parameters

    • documents: DocumentInterface[]

      The documents to add.

    Returns Promise<string[]>

    A promise that resolves to the added documents IDs.

  • Method for adding vectors to the AzureCosmosDBNoSQLVectorStore.

    Parameters

    • vectors: number[][]

      Vectors to be added.

    • documents: DocumentInterface[]

      Corresponding documents to be added.

    Returns Promise<string[]>

    A promise that resolves to the added documents IDs.

  • Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.

    Parameters

    • query: string

      Text to look up documents similar to.

    • options: MaxMarginalRelevanceSearchOptions<this["FilterType"]>

    Returns Promise<Document[]>

    List of documents selected by maximal marginal relevance.

  • Performs a similarity search on the vectors stored in the container.

    Parameters

    • query: string

      Query text for the similarity search.

    • k: number = 4
    • filter: undefined | AzureCosmosDBNoSQLFilterType = undefined

      Optional filter options for the documents.

    Returns Promise<Document[]>

    Promise that resolves to a list of documents.

  • Performs a similarity search on the vectors stored in the container.

    Parameters

    • queryVector: number[]

      Query vector for the similarity search.

    • k: number = 4
    • filter: undefined | AzureCosmosDBNoSQLFilterType = undefined

      Optional filter options for the documents.

    Returns Promise<[Document, number][]>

    Promise that resolves to a list of documents and their corresponding similarity scores.

  • Static method to create an instance of AzureCosmosDBNoSQLVectorStore from a list of texts. It first converts the texts to vectors and then adds them to the collection.

    Parameters

    • texts: string[]

      List of texts to be converted to vectors.

    • metadatas: object | object[]

      Metadata for the texts.

    • embeddings: EmbeddingsInterface

      Embeddings to be used for conversion.

    • dbConfig: AzureCosmosDBNoSQLConfig

      Database configuration for Azure Cosmos DB for NoSQL.

    Returns Promise<AzureCosmosDBNoSQLVectorStore>

    Promise that resolves to a new instance of AzureCosmosDBNoSQLVectorStore.