generative-ai-cdk-constructs

MongoDB Atlas Vector Store Construct Library


Stability: Experimental

All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


Language Package
Typescript Logo TypeScript @cdklabs/generative-ai-cdk-constructs
Python Logo Python cdklabs.generative_ai_cdk_constructs
Java Logo Java io.github.cdklabs.generative_ai_cdk_constructs
.Net .Net CdkLabs.GenerativeAICdkConstructs
Go Go github.com/cdklabs/generative-ai-cdk-constructs-go/generativeaicdkconstructs

MongoDBAtlasVectorStore

The MongoDBAtlasVectorStore construct allows you to define a MongoDB Atlas instance as a vector store for your Amazon Bedrock Knowledge Base.

Usage

typescript fixture=default-bedrock const vectorStore = new genaicdk.mongodbAtlas.MongoDBAtlasVectorStore({ collectionName: 'embeddings', credentialsSecretArn: 'arn:aws:secretsmanager:region:account:secret:secret-name', databaseName: 'vectordb', endpoint: 'https://your-mongodb-atlas-endpoint.mongodb.net', endpointServiceName: 'mongodb-atlas', fieldMapping: { vectorField: 'embedding', textField: 'text', metadataField: 'metadata' }, vectorIndexName: 'vector_index' });

Properties

The MongoDBAtlasVectorStore construct accepts the following properties:

Property Type Description
collectionName string The name of the collection in MongoDB Atlas
credentialsSecretArn string The ARN of the AWS Secrets Manager secret containing MongoDB Atlas credentials
databaseName string The name of the database in MongoDB Atlas
endpoint string The endpoint URL for MongoDB Atlas
endpointServiceName string The name of the endpoint service
fieldMapping MongoDbAtlasFieldMapping The mapping of fields in the MongoDB collection
vectorIndexName string The name of the vector index in MongoDB Atlas

Field Mapping

The fieldMapping property defines how fields in your MongoDB collection map to vector store concepts:

Property Type Description
vectorField string The field name for storing vector embeddings
textField string The field name for storing the original text
metadataField string The field name for storing additional metadata