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 | @cdklabs/generative-ai-cdk-constructs |
This construct library provides a class that defines a AmazonAuroraVectorStore
class for an existing Amazon Aurora to be used for a vector store for a Knowledge Base. Additionally, it provides an AmazonAuroraDefaultVectorStore
L3 resource that creates a VPC with 3 subnets (public private with NAT Gateway, private without NAT Gateway), with the Amazon Aurora Serverless V2 Cluster. The cluster has 1 writer/reader instance with PostgreSQL 15.5 version (min capacity 0.5, max capacity 4). Lambda custom resource executes required pgvector and Amazon Bedrock Knowledge Base SQL queries (see more here) against Aurora cluster during deployment. The secret containing databases credentials is being deployed and securely stored in AWS Secrets Manager. You must specify the same embeddings model that you are going to use in KnowledgeBase construct.
See the API documentation.
import { amazonaurora } from '@cdklabs/generative-ai-cdk-constructs';
new amazonaurora.AmazonAuroraVectoStore(
{
resourceArn: 'arn:aws:rds:your-region:123456789876:cluster:aurora-cluster-manual',
databaseName: 'bedrock_vector_db',
tableName: 'bedrock_integration.bedrock_kb',
credentialsSecretArn: 'arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name',
primaryKeyField: 'id',
vectorField: 'embedding',
textField: 'chunks',
metadataField: 'metadata',
});
import { amazonaurora } from '@cdklabs/generative-ai-cdk-constructs';
new amazonaurora.AmazonAuroraDefaultVectorStore(stack, 'AuroraDefaultVectorStore', {
embeddingsModel: BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3,
});