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

  • VectorStore
    • AzureCosmosDBNoSQLVectorStore

Constructors

Properties

embeddings: EmbeddingsInterface
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<Record<string, any>>[]

      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<Record<string, any>>[]

      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

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

    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<Record<string, any>>[]>

    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<Record<string, any>>, number][]>

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

  • Parameters

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

  • Returns Serialized

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

    Parameters

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

      List of documents to be converted to vectors.

    • 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.

  • 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.