class AzureCosmosDBNoSQLVectorStoreAzure Cosmos DB for NoSQL vector store. To use this, you should have both:
@azure/cosmos NPM package installedYou do not need to create a database or container, it will be created automatically.
Embeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.
Initializes the AzureCosmosDBNoSQLVectorStore. Connects the client to the database and creates the container if needed.
Returns a string representing the type of vector store, which subclasses must implement to identify their specific vector storage type.
Method for adding documents to the AzureCosmosDBNoSQLVectorStore. It first converts the documents to texts and then adds them as vectors.
Method for adding vectors to the AzureCosmosDBNoSQLVectorStore.
Creates a VectorStoreRetriever instance with flexible configuration options.
Removes specified documents from the AzureCosmosDBNoSQLVectorStore. If no IDs or filter are specified, all documents will be removed.
Gets the underlying Cosmos DB container. Useful for performing direct operations on the container.
Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.
Return documents selected using the maximal marginal relevance from a vector. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.
Searches for documents similar to a text query by embedding the query and performing a similarity search on the resulting vector.
Performs a similarity search on the vectors stored in the container. Routes to the appropriate search implementation based on the search type specified in the filter or the default search type configured for the vector store.
Searches for documents similar to a text query by embedding the query, and returns results with similarity scores.
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.
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.
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.
const vectorStore = new AzureCosmosDBNoSQLVectorStore(
new OpenAIEmbeddings(),
{
databaseName: "mydb",
containerName: "vectors",
}
);
await vectorStore.addDocuments(docs);
const results = await vectorStore.similaritySearch("query", 4);