generativeaicdkconstructs

package module
v0.1.314 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

README

AWS Generative AI CDK Constructs

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.


View on Construct Hub

PyPI version npm version NuGet Version Maven Central Version Go Version

Terraform Amazon Bedrock Module Terraform Amazon OpenSearch Serverless Module Terraform Amazon SageMaker Endpoint Module Terraform Streamlit Module

Table of contents

Introduction

The AWS Generative AI Constructs Library is an open-source extension of the AWS Cloud Development Kit (AWS CDK) that provides multi-service, well-architected patterns for quickly defining solutions in code to create predictable and repeatable infrastructure, called constructs. The goal of AWS Generative AI CDK Constructs is to help developers build generative AI solutions using pattern-based definitions for their architecture.

The patterns defined in AWS Generative AI CDK Constructs are high level, multi-service abstractions of AWS CDK constructs that have default configurations based on well-architected best practices. The library is organized into logical modules using object-oriented techniques to create each architectural pattern model.

CDK Versions

AWS Generative AI CDK Constructs and the AWS CDK are independent teams and have different release schedules. Each release of AWS Generative AI CDK Constructs is built against a specific version of the AWS CDK. The CHANGELOG.md file lists the CDK version associated with each AWS Generative AI Constructs release. For instance, AWS Generative AI CDK Constructs v0.0.0 was built against AWS CDK v2.96.2. This means that to use AWS Generative AI CDK Constructs v0.0.0, your application must include AWS CDK v2.96.2 or later. You can continue to use the latest AWS CDK versions and upgrade the your AWS Generative AI CDK Constructs version when new releases become available.

Contributing

Contributions of all kinds are welcome! Check out our contributor guide

Design guidelines and Development guide

If you want to add a new construct to the library, check out our design guidelines, then follow the development guide

Getting Started

TypeScript
  • Create or use an existing CDK application in TypeScript.

    • cdk init app --language typescript
  • Run npm install @cdklabs/generative-ai-cdk-constructs

  • The package should be added to your package.json.

  • Import the library:

    • import * as genai from '@cdklabs/generative-ai-cdk-constructs';
Python
  • Create or use an existing CDK application in Python

    • cdk init app --language python
  • Install the package:

    • pip install cdklabs.generative-ai-cdk-constructs
  • Import the library:

    • import cdklabs.generative_ai_cdk_constructs
NuGet
  • Create or use an existing CDK application in Python

    • cdk init app --language csharp
  • Install the package while in the Visual Studio project:

    • dotnet add package CdkLabs.GenerativeAICdkConstructs
  • Use the namespace:

    • using Cdklabs.GenerativeAiCdkConstructs;
Go
  • Create or use an existing CDK application in Python

    • cdk init app --language go
  • Get the module:

    • go get github.com/cdklabs/generative-ai-cdk-constructs-go/generative-ai-cdk-constructs
  • Import the library:

    • import "github.com/cdklabs/generative-ai-cdk-constructs-go/generative-ai-cdk-constructs"

NOTE: The Go distribution repository, distributes the JSII tar gzipped versioned source from the source repository

Java
  • Create or use an existing CDK application in Java

    • cdk init app --language java
  • Add the dependency into the pom.xml

<dependency>
    <groupId>io.github.cdklabs</groupId>
    <artifactId>generative-ai-cdk-constructs</artifactId>
    <version>Get the latest version and insert it here</version>
</dependency>

Refer to the documentation for additional guidance on a particular construct: Catalog

Catalog

The following constructs are available in the library:

L3 constructs
Construct Description AWS Services used
SageMaker model deployment (JumpStart) Deploy a foundation model from Amazon SageMaker JumpStart to an Amazon SageMaker endpoint. Amazon SageMaker
SageMaker model deployment (Hugging Face) Deploy a foundation model from Hugging Face to an Amazon SageMaker endpoint. Amazon SageMaker
SageMaker model deployment (Custom) Deploy a foundation model from an S3 location to an Amazon SageMaker endpoint. Amazon SageMaker
Amazon Bedrock Monitoring (Amazon CloudWatch Dashboard) Amazon CloudWatch dashboard to monitor model usage from Amazon Bedrock. Amazon CloudWatch
Bedrock Data Automation Use Amazon bedrock data automation client to to build and manage intelligent document processing, media analysis, and other multimodal data-centric automation solutions AWS Lambda, Amazon S3 bucket
Bedrock Batch Step Functions Manage Bedrock model invocation jobs(batch inference) in AWS Step Functions state machines AWS Step Functions, AWS Lambda, AWS EventBridge, Amazon Bedrock, AWS IAM
L2 Constructs

[!WARNING] Important: Amazon Bedrock L2 constructs are transitioning to the AWS CDK core repository. You can now find these constructs at: https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk/aws-bedrock-alpha. Please migrate to the alpha package, as Bedrock L2 constructs in this repository are now deprecated and will no longer receive updates.

Construct Description AWS Services used
Amazon Bedrock CDK L2 Constructs for Amazon Bedrock. Amazon Bedrock, Amazon OpenSearch Serverless, AWS Lambda
Amazon OpenSearch Serverless Vector Collection CDK L2 Constructs to create a vector collection. Amazon OpenSearch Vector Index
Amazon OpenSearch Vector Index CDK L1 Custom Resource to create a vector index. Amazon OpenSearch Serverless, AWS Lambda
Amazon Aurora DSQL CDK L2 Constructs for Amazon Aurora DSQL. Amazon Aurora DSQL
Amazon S3 Vectors CDK L2 Constructs for Amazon S3 vectors. Amazon S3 Vectors

Sample Use Cases

The official samples repository includes a collection of functional use case implementations to demonstrate the usage of AWS Generative AI CDK Constructs. These can be used in the same way as architectural patterns, and can be conceptualized as an additional "higher-level" abstraction of those patterns. Those patterns (constructs) are composed together into stacks, forming a "CDK app".

Additional Resources

Resource Type Description
AWS re:Invent 2023 - Keynote with Dr. Werner Vogels Keynote Dr. Werner Vogels, Amazon.com's VP and CTO, announces the AWS Generative AI CDK Constructs during his AWS re:Invent 2023 keynote.
Workshop - Building Generative AI Apps on AWS with CDK Workshop In this workshop, you will explore how to build a sample generative AI app on AWS using CDK and Generative AI CDK Constructs.
Workshop - Hands on AWS CDK Generative AI Constructs Workshop In this workshop you will deploy projects that use CDK constructs from this library. Projects are from the amazon-bedrock-samples Github Repository.
Build generative AI applications with Amazon Titan Text Premier, Amazon Bedrock, and AWS CDK Blog post + Code sample Blog post exploring building and deploying two sample applications powered by Amazon Titan Text Premier using the Generative AI CDK constructs.
aws-cdk-stack-builder-tool Code sample AWS CDK Builder is a browser-based tool designed to streamline bootstrapping of Infrastructure as Code (IaC) projects using the AWS Cloud Development Kit (CDK).
CDK Live! Building generative AI applications and architectures leveraging AWS CDK Constructs! Video CDK Live! episode focused on building and deploying generative AI applications and architectures on AWS using the AWS Cloud Development Kit (CDK) and the AWS Generative AI CDK Constructs.
Announcing AWS Generative AI CDK Constructs! Blog post Blog post announcing the release of the AWS Generative AI CDK Constructs.
Streamline insurance underwriting with generative AI using Amazon Bedrock Blog post + Code sample Blog post and code sample discussing how to use AWS generative artificial intelligence (AI) solutions like Amazon Bedrock to improve the underwriting process, including rule validation, underwriting guidelines adherence, and decision justification.
aws-genai-llm-chatbot Code sample Multi-Model and Multi-RAG Powered Chatbot Using AWS CDK on AWS allowing you to experiment with a variety of Large Language Models and Multimodal Language Models, settings and prompts in your own AWS account.
bedrock-claude-chat Code sample AWS-native chatbot using Bedrock + Claude (+Mistral).
amazon-bedrock-rag Code sample Fully managed RAG solution using Knowledge Bases for Amazon Bedrock.
Amazon Bedrock Multimodal Search Code sample Multimodal product search app built using Amazon Titan Multimodal Embeddings model.
Amazon Bedrock Knowledge Bases with Private Data Blog post + Code sample Blog post and associated code sample demonstrating how to integrate Knowledge Bases into Amazon Bedrock to provide foundational models with contextual data from private data sources.
Automating tasks using Amazon Bedrock Agents and AI Blog post + Code sample Blog post and associated code sample demonstrating how to deploy an Amazon Bedrock Agent and a Knowledge Base through a hotel and spa use case.
Agents for Amazon Bedrock - Powertools for AWS Lambda (Python) Code sample Create Agents for Amazon Bedrock using event handlers and auto generation of OpenAPI schemas.
Text to SQL Bedrock Agent Code sample Harnessing the power of natural language processing, the "Text to SQL Bedrock Agent" facilitates the automatic transformation of natural language questions into executable SQL queries.
Dynamic Text-to-SQL for Enterprise Workloads with Amazon Bedrock Agent Code sample Elevate your data analysis with an end-to-end agentic Text-to-SQL solution, built on AWS for enterprise-scale adaptability and resilience. Ideal for complex scenarios like fraud detection in financial services.

Contributors

contributors

Operational Metrics Collection

Generative AI CDK Constructs may collect anonymous operational metrics, including: the region a construct is deployed, the name and version of the construct deployed, and related information. We may use the metrics to maintain, provide, develop, and improve the constructs and AWS services.

Roadmap

Roadmap is available through the GitHub Project

Deprecation

To understand our deprecation process, please refer to the dedicated documentation

License

Apache-2.0

You should consider doing your own independent assessment before using the content in this library for production purposes. This may include (amongst other things) testing, securing, and optimizing the CDK constructs and other content, provided in this library, based on your specific quality control practices and standards.


© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Documentation

Overview

AWS Generative AI CDK Constructs is a library for well-architected generative AI patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseClass_IsConstruct

func BaseClass_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func BaseClass_SetUsageMetricMap

func BaseClass_SetUsageMetricMap(val *map[string]*float64)

func BaseClass_UsageMetricMap

func BaseClass_UsageMetricMap() *map[string]*float64

func NewBaseClass_Override

func NewBaseClass_Override(b BaseClass, scope constructs.Construct, id *string)

Experimental.

Types

type BaseClass

type BaseClass interface {
	constructs.Construct
	// construct usage metric , added in template description.
	// Experimental.
	ConstructUsageMetric() *string
	// enable disable xray tracing.
	// Default: true.
	//
	// Experimental.
	Enablexray() *bool
	// Experimental.
	SetEnablexray(val *bool)
	// Default  log config for all constructs.
	// Experimental.
	FieldLogLevel() awsappsync.FieldLogLevel
	// Experimental.
	SetFieldLogLevel(val awsappsync.FieldLogLevel)
	// enable disable lambda tracing.
	// Default: Active.
	//
	// Experimental.
	LambdaTracing() awslambda.Tracing
	// Experimental.
	SetLambdaTracing(val awslambda.Tracing)
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// Default  log retention config for all constructs.
	// Experimental.
	Retention() awslogs.RetentionDays
	// Experimental.
	SetRetention(val awslogs.RetentionDays)
	// Value will be appended to resources name.
	// Default: _dev.
	//
	// Experimental.
	Stage() *string
	// Experimental.
	SetStage(val *string)
	// Experimental.
	AddObservabilityToConstruct(props *BaseClassProps)
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
	// update template description with construct usage metric and add AWS_SDK_UA_APP_ID to user agent on aws sdk.
	// Experimental.
	UpdateConstructUsageMetricCode(props *BaseClassProps, scope constructs.Construct, lambdaFunctions *[]awslambda.DockerImageFunction)
	// Experimental.
	UpdateEnvSuffix(props *BaseClassProps)
}

Experimental.

func NewBaseClass

func NewBaseClass(scope constructs.Construct, id *string) BaseClass

Experimental.

type BaseClassProps

type BaseClassProps struct {
	// construct id.
	// Experimental.
	ConstructId *string `field:"required" json:"constructId" yaml:"constructId"`
	// name of the construct.
	// Experimental.
	ConstructName ConstructName `field:"required" json:"constructName" yaml:"constructName"`
	// Enable observability.
	//
	// Warning: associated cost with the services
	// used. Best practice to enable by default.
	// Default: true.
	//
	// Experimental.
	Observability *bool `field:"optional" json:"observability" yaml:"observability"`
	// Value will be appended to resources name.
	// Default: _dev.
	//
	// Experimental.
	Stage *string `field:"optional" json:"stage" yaml:"stage"`
}

Experimental.

type ConstructName

type ConstructName string

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://www.apache.org/licenses/LICENSE-2.0

or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License. Experimental.

const (
	// Experimental.
	ConstructName_AWSMODELDEPLOYMENTSAGEMAKER ConstructName = "AWSMODELDEPLOYMENTSAGEMAKER"
	// Experimental.
	ConstructName_CUSTOMSAGEMAKERENDPOINT ConstructName = "CUSTOMSAGEMAKERENDPOINT"
	// Experimental.
	ConstructName_HUGGINGFACESAGEMAKERENDPOINT ConstructName = "HUGGINGFACESAGEMAKERENDPOINT"
	// Experimental.
	ConstructName_JUMPSTARTSAGEMAKERENDPOINT ConstructName = "JUMPSTARTSAGEMAKERENDPOINT"
)

Directories

Path Synopsis
bda
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL