diff --git a/.gitignore b/.gitignore index aa64e376..ea31e4fd 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,14 @@ junit.xml !/.eslintrc.json .jsii tsconfig.json +test/integ/chatprompt.integ.snapshot/asset.* +test/integ/chatprompt.integ.snapshot/**/asset.* +test/integ/chatprompt.integ.snapshot/cdk.out +test/integ/chatprompt.integ.snapshot/**/cdk.out +test/integ/chatprompt.integ.snapshot/manifest.json +test/integ/chatprompt.integ.snapshot/**/manifest.json +test/integ/chatprompt.integ.snapshot/tree.json +test/integ/chatprompt.integ.snapshot/**/tree.json test/integ/.tmp test/integ/inference-profiles.integ.snapshot/asset.* test/integ/inference-profiles.integ.snapshot/**/asset.* diff --git a/.npmignore b/.npmignore index 19d6a6b9..31b2a725 100644 --- a/.npmignore +++ b/.npmignore @@ -22,6 +22,7 @@ dist tsconfig.tsbuildinfo /.eslintrc.json !.jsii +test/integ/chatprompt.integ.snapshot test/integ/.tmp test/integ/inference-profiles.integ.snapshot test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/.tmp diff --git a/.projen/deps.json b/.projen/deps.json index 2d0bf626..c4696be7 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -6,7 +6,7 @@ }, { "name": "@aws-cdk/integ-tests-alpha", - "version": "2.166.0-alpha.0", + "version": "2.174.0-alpha.0", "type": "build" }, { @@ -137,7 +137,7 @@ }, { "name": "aws-cdk-lib", - "version": "^2.166.0", + "version": "^2.174.0", "type": "peer" }, { diff --git a/.projen/tasks.json b/.projen/tasks.json index 5b1a35db..014f8c5e 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -290,6 +290,69 @@ } ] }, + "integ:chatprompt:assert": { + "name": "integ:chatprompt:assert", + "description": "assert the snapshot of integration test 'chatprompt'", + "steps": [ + { + "exec": "[ -d \"test/integ/chatprompt.integ.snapshot\" ] || (echo \"No snapshot available for integration test 'chatprompt'. Run 'projen integ:chatprompt:deploy' to capture.\" && exit 1)" + }, + { + "exec": "cdk synth --app \"ts-node -P tsconfig.dev.json test/integ/chatprompt.integ.ts\" --no-notices --no-version-reporting --no-asset-metadata --no-path-metadata -o test/integ/.tmp/chatprompt.integ/assert.cdk.out > /dev/null" + }, + { + "exec": "diff -r -x asset.* -x cdk.out -x manifest.json -x tree.json test/integ/chatprompt.integ.snapshot/ test/integ/.tmp/chatprompt.integ/assert.cdk.out/" + } + ] + }, + "integ:chatprompt:deploy": { + "name": "integ:chatprompt:deploy", + "description": "deploy integration test 'chatprompt' and capture snapshot", + "steps": [ + { + "exec": "rm -fr test/integ/.tmp/chatprompt.integ/deploy.cdk.out" + }, + { + "exec": "cdk deploy --app \"ts-node -P tsconfig.dev.json test/integ/chatprompt.integ.ts\" --no-notices --no-version-reporting --no-asset-metadata --no-path-metadata '**' --require-approval=never -o test/integ/.tmp/chatprompt.integ/deploy.cdk.out" + }, + { + "exec": "rm -fr test/integ/chatprompt.integ.snapshot" + }, + { + "exec": "mv test/integ/.tmp/chatprompt.integ/deploy.cdk.out test/integ/chatprompt.integ.snapshot" + }, + { + "spawn": "integ:chatprompt:destroy" + } + ] + }, + "integ:chatprompt:destroy": { + "name": "integ:chatprompt:destroy", + "description": "destroy integration test 'chatprompt'", + "steps": [ + { + "exec": "cdk destroy --app test/integ/chatprompt.integ.snapshot '**' --no-version-reporting" + } + ] + }, + "integ:chatprompt:snapshot": { + "name": "integ:chatprompt:snapshot", + "description": "update snapshot for integration test \"chatprompt\"", + "steps": [ + { + "exec": "cdk synth --app \"ts-node -P tsconfig.dev.json test/integ/chatprompt.integ.ts\" --no-notices --no-version-reporting --no-asset-metadata --no-path-metadata -o test/integ/chatprompt.integ.snapshot > /dev/null" + } + ] + }, + "integ:chatprompt:watch": { + "name": "integ:chatprompt:watch", + "description": "watch integration test 'chatprompt' (without updating snapshots)", + "steps": [ + { + "exec": "cdk watch --app \"ts-node -P tsconfig.dev.json test/integ/chatprompt.integ.ts\" --no-notices --no-version-reporting --no-asset-metadata --no-path-metadata '**' -o test/integ/.tmp/chatprompt.integ/deploy.cdk.out" + } + ] + }, "integ:inference-profiles:assert": { "name": "integ:inference-profiles:assert", "description": "assert the snapshot of integration test 'inference-profiles'", @@ -357,6 +420,9 @@ "name": "integ:snapshot-all", "description": "update snapshot for all integration tests", "steps": [ + { + "spawn": "integ:chatprompt:snapshot" + }, { "spawn": "integ:inference-profiles:snapshot" }, @@ -493,6 +559,9 @@ { "spawn": "eslint" }, + { + "spawn": "integ:chatprompt:assert" + }, { "spawn": "integ:inference-profiles:assert" }, diff --git a/.projenrc.ts b/.projenrc.ts index d5e981fa..4bb9d1aa 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -29,11 +29,17 @@ import { const GITHUB_USER = 'awslabs'; const PUBLICATION_NAMESPACE = 'cdklabs'; const PROJECT_NAME = 'generative-ai-cdk-constructs'; -const CDK_VERSION: string = '2.166.0'; +const CDK_VERSION: string = '2.174.0'; function camelCaseIt(input: string): string { // Hypens and dashes to spaces and then CamelCase... - return input.replace(/-/g, ' ').replace(/_/g, ' ').replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, _) { if (+match === 0) return ''; return match.toUpperCase(); }); + return input + .replace(/-/g, ' ') + .replace(/_/g, ' ') + .replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, _) { + if (+match === 0) return ''; + return match.toUpperCase(); + }); } const project = new awscdk.AwsCdkConstructLibrary({ @@ -65,14 +71,8 @@ const project = new awscdk.AwsCdkConstructLibrary({ '@aws-cdk/assert', `@aws-cdk/integ-tests-alpha@${CDK_VERSION}-alpha.0`, ], - deps: [ - 'cdk-nag', - - - ], - bundledDeps: [ - 'deepmerge', - ], + deps: ['cdk-nag'], + bundledDeps: ['deepmerge'], // Keep synchronized with https://github.com/nodejs/release#release-schedule minNodeVersion: '18.12.0', // 'MAINTENANCE' (first LTS) maxNodeVersion: '20.x', // 'CURRENT' @@ -83,7 +83,7 @@ const project = new awscdk.AwsCdkConstructLibrary({ publishToPypi: { distName: PUBLICATION_NAMESPACE + '.' + PROJECT_NAME, - module: (PUBLICATION_NAMESPACE.replace(/-/g, '_')) + '.' + (PROJECT_NAME.replace(/-/g, '_')), // PEP 8, convert hypens + module: PUBLICATION_NAMESPACE.replace(/-/g, '_') + '.' + PROJECT_NAME.replace(/-/g, '_'), // PEP 8, convert hypens // twineRegistryUrl: '${{ secrets.TWINE_REGISTRY_URL }}', }, @@ -109,7 +109,8 @@ const project = new awscdk.AwsCdkConstructLibrary({ githubOptions: { pullRequestLintOptions: { - contributorStatement: 'By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.', + contributorStatement: + 'By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.', contributorStatementOptions: { exemptUsers: [ 'amazon-auto', @@ -127,15 +128,7 @@ const project = new awscdk.AwsCdkConstructLibrary({ license: 'Apache-2.0', copyrightPeriod: '2023-', copyrightOwner: 'Amazon.com, Inc. or its affiliates. All Rights Reserved.', - gitignore: [ - '*.DS_STORE', - '!.node-version', - '*.pyc', - '__pycache__/', - '!.ort.yml', - '.idea', - '.vscode', - ], + gitignore: ['*.DS_STORE', '!.node-version', '*.pyc', '__pycache__/', '!.ort.yml', '.idea', '.vscode'], stability: 'experimental', sampleCode: false, stale: true, @@ -164,16 +157,23 @@ if (workflowUpgradeMain) { } // Update Snapshots -project.upgradeWorkflow?.postUpgradeTask.spawn( - project.tasks.tryFind('integ:snapshot-all')!, -); +project.upgradeWorkflow?.postUpgradeTask.spawn(project.tasks.tryFind('integ:snapshot-all')!); // Add specific overrides https://projen.io/docs/integrations/github/#actions-versions project.github?.actions.set('actions/checkout@v3', 'actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11'); // https://github.com/projen/projen/issues/3529 project.github?.actions.set('actions/checkout@v4', 'actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11'); -project.github?.actions.set('actions/download-artifact@v3', 'actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379'); // https://github.com/projen/projen/issues/3529 -project.github?.actions.set('actions/download-artifact@v4', 'actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379'); -project.github?.actions.set('actions/github-script@v6', 'actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410'); +project.github?.actions.set( + 'actions/download-artifact@v3', + 'actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379', +); // https://github.com/projen/projen/issues/3529 +project.github?.actions.set( + 'actions/download-artifact@v4', + 'actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379', +); +project.github?.actions.set( + 'actions/github-script@v6', + 'actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410', +); project.github?.actions.set('actions/setup-dotnet@v3', 'actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3'); project.github?.actions.set('actions/setup-dotnet@v4', 'actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3'); project.github?.actions.set('actions/setup-go@v5', 'actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32'); @@ -184,22 +184,67 @@ project.github?.actions.set('actions/setup-python@v5', 'actions/setup-python@82c project.github?.actions.set('actions/setup-java@v3', 'actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9'); project.github?.actions.set('actions/setup-java@v4', 'actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9'); project.github?.actions.set('actions/stale@v4', 'actions/stale@a20b814fb01b71def3bd6f56e7494d667ddf28da'); -project.github?.actions.set('actions/upload-artifact@v3', 'actions/upload-artifact@18bf333cd2249fbbbdb605fd9d9ed57efd7adf34'); // https://github.com/projen/projen/issues/3529 -project.github?.actions.set('actions/upload-artifact@v4', 'actions/upload-artifact@18bf333cd2249fbbbdb605fd9d9ed57efd7adf34'); -project.github?.actions.set('amannn/action-semantic-pull-request@v5.0.2', 'amannn/action-semantic-pull-request@01d5fd8a8ebb9aafe902c40c53f0f4744f7381eb'); -project.github?.actions.set('amannn/action-semantic-pull-request@v5.4.0', 'amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f'); -project.github?.actions.set('aws-github-ops/github-merit-badger@main', 'aws-github-ops/github-merit-badger@70d1c47f7051d6e324d4ddc48d676ba61ef69a3e'); -project.github?.actions.set('codecov/codecov-action@v3', 'codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed'); // https://github.com/projen/projen/issues/3529 -project.github?.actions.set('codecov/codecov-action@v4', 'codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed'); +project.github?.actions.set( + 'actions/upload-artifact@v3', + 'actions/upload-artifact@18bf333cd2249fbbbdb605fd9d9ed57efd7adf34', +); // https://github.com/projen/projen/issues/3529 +project.github?.actions.set( + 'actions/upload-artifact@v4', + 'actions/upload-artifact@18bf333cd2249fbbbdb605fd9d9ed57efd7adf34', +); +project.github?.actions.set( + 'amannn/action-semantic-pull-request@v5.0.2', + 'amannn/action-semantic-pull-request@01d5fd8a8ebb9aafe902c40c53f0f4744f7381eb', +); +project.github?.actions.set( + 'amannn/action-semantic-pull-request@v5.4.0', + 'amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f', +); +project.github?.actions.set( + 'aws-github-ops/github-merit-badger@main', + 'aws-github-ops/github-merit-badger@70d1c47f7051d6e324d4ddc48d676ba61ef69a3e', +); +project.github?.actions.set( + 'codecov/codecov-action@v3', + 'codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed', +); // https://github.com/projen/projen/issues/3529 +project.github?.actions.set( + 'codecov/codecov-action@v4', + 'codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed', +); project.github?.actions.set('github/issue-metrics@v2', 'github/issue-metrics@6bc5254e72971dbb7462db077779f1643f772afd'); -project.github?.actions.set('hmarr/auto-approve-action@v4.0.0', 'hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363'); -project.github?.actions.set('minicli/action-contributors@v3.3', 'minicli/action-contributors@20ec03af008cb51110a3137fbf77f59a4fd7ff5a'); -project.github?.actions.set('oss-review-toolkit/ort-ci-github-action@v1', 'oss-review-toolkit/ort-ci-github-action@7f23c1f8d169dad430e41df223d3b8409c7a156e'); -project.github?.actions.set('peter-evans/create-issue-from-file@v4', 'peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f'); -project.github?.actions.set('peter-evans/create-pull-request@v4', 'peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54'); -project.github?.actions.set('peter-evans/create-pull-request@v5', 'peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38'); -project.github?.actions.set('peter-evans/create-pull-request@v6', 'peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50'); -project.github?.actions.set('aws-actions/configure-aws-credentials@v4.0.2', 'aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502'); +project.github?.actions.set( + 'hmarr/auto-approve-action@v4.0.0', + 'hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363', +); +project.github?.actions.set( + 'minicli/action-contributors@v3.3', + 'minicli/action-contributors@20ec03af008cb51110a3137fbf77f59a4fd7ff5a', +); +project.github?.actions.set( + 'oss-review-toolkit/ort-ci-github-action@v1', + 'oss-review-toolkit/ort-ci-github-action@7f23c1f8d169dad430e41df223d3b8409c7a156e', +); +project.github?.actions.set( + 'peter-evans/create-issue-from-file@v4', + 'peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f', +); +project.github?.actions.set( + 'peter-evans/create-pull-request@v4', + 'peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54', +); +project.github?.actions.set( + 'peter-evans/create-pull-request@v5', + 'peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38', +); +project.github?.actions.set( + 'peter-evans/create-pull-request@v6', + 'peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50', +); +project.github?.actions.set( + 'aws-actions/configure-aws-credentials@v4.0.2', + 'aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502', +); project.github?.actions.set('imjohnbo/issue-bot@v3', 'imjohnbo/issue-bot@3daae12aa54d38685d7ff8459fc8a2aee8cea98b'); // We don't want to package certain things @@ -240,7 +285,19 @@ project.eslint?.addIgnorePattern('DockerLambdaCustomProps.ts'); new ProjenStruct(project, { name: 'DockerLambdaCustomProps', filePath: 'src/common/props/DockerLambdaCustomProps.ts' }) .mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.DockerImageFunctionProps')) .withoutDeprecated() - .omit('tracing', 'functionName', 'description', 'role', 'vpc', 'vpcSubnets', 'securityGroups', 'role', 'layers', 'allowPublicSubnet', 'allowAllOutbound'); + .omit( + 'tracing', + 'functionName', + 'description', + 'role', + 'vpc', + 'vpcSubnets', + 'securityGroups', + 'role', + 'layers', + 'allowPublicSubnet', + 'allowAllOutbound', + ); const packageJson = project.tryFindObjectFile('package.json'); packageJson?.patch(JsonPatch.add('/scripts/prepare', 'husky install')); // yarn 1 @@ -274,7 +331,9 @@ project.addTask('generate-models-containers', { const postCompile = project.tasks.tryFind('post-compile'); if (postCompile) { - postCompile.exec('npx typedoc --plugin typedoc-plugin-markdown --out apidocs --readme none --categoryOrder "Namespaces,Classes,Interfaces,*" --disableSources ./src/index.ts'); + postCompile.exec( + 'npx typedoc --plugin typedoc-plugin-markdown --out apidocs --readme none --categoryOrder "Namespaces,Classes,Interfaces,*" --disableSources ./src/index.ts', + ); } project.synth(); diff --git a/CHANGELOG.md b/CHANGELOG.md index ed629d71..8bbafe9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# CDK Generative AI Constructs V0.1.289 (2025-01-08) + +Based on CDK library version 2.174.0 + # CDK Generative AI Constructs V0.1.283 (2024-11-20) Based on CDK library version 2.166.0 diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 9118b64b..e6e43fb9 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -16,7 +16,7 @@ Default output format [None]: json ``` - [Node](https://nodejs.org/en) >= v20.9.0 -- [AWS CDK](https://github.com/aws/aws-cdk/releases/tag/v2.166.0) >= 2.166.0 +- [AWS CDK](https://github.com/aws/aws-cdk/releases/tag/v2.174.0) >= 2.174.0 - [Python](https://www.python.org/downloads/) >=3.9 - [Projen](https://github.com/projen/projen) >= 0.78.8 - [Yarn](https://classic.yarnpkg.com/lang/en/docs/cli/install/) >= 1.22.19 diff --git a/apidocs/interfaces/DockerLambdaCustomProps.md b/apidocs/interfaces/DockerLambdaCustomProps.md index 94f22777..330cc7ec 100644 --- a/apidocs/interfaces/DockerLambdaCustomProps.md +++ b/apidocs/interfaces/DockerLambdaCustomProps.md @@ -669,7 +669,7 @@ stable > `readonly` `optional` **snapStart**: `SnapStartConf` Enable SnapStart for Lambda Function. -SnapStart is currently supported only for Java 11, 17 runtime +SnapStart is currently supported for Java 11, Java 17, Python 3.12, Python 3.13, and .NET 8 runtime #### Default diff --git a/apidocs/namespaces/bedrock/README.md b/apidocs/namespaces/bedrock/README.md index 35115dc6..59734f9a 100644 --- a/apidocs/namespaces/bedrock/README.md +++ b/apidocs/namespaces/bedrock/README.md @@ -12,6 +12,7 @@ ## Enumerations +- [ChatMessageRole](enumerations/ChatMessageRole.md) - [ConfluenceDataSourceAuthType](enumerations/ConfluenceDataSourceAuthType.md) - [ConfluenceObjectType](enumerations/ConfluenceObjectType.md) - [ContentFilterStrength](enumerations/ContentFilterStrength.md) @@ -43,6 +44,7 @@ - [ApiSchema](classes/ApiSchema.md) - [ApplicationInferenceProfile](classes/ApplicationInferenceProfile.md) - [BedrockFoundationModel](classes/BedrockFoundationModel.md) +- [ChatMessage](classes/ChatMessage.md) - [ChunkingStrategy](classes/ChunkingStrategy.md) - [ConfluenceDataSource](classes/ConfluenceDataSource.md) - [CrossRegionInferenceProfile](classes/CrossRegionInferenceProfile.md) @@ -64,6 +66,7 @@ - [S3DataSource](classes/S3DataSource.md) - [SalesforceDataSource](classes/SalesforceDataSource.md) - [SharePointDataSource](classes/SharePointDataSource.md) +- [ToolChoice](classes/ToolChoice.md) - [Topic](classes/Topic.md) - [WebCrawlerDataSource](classes/WebCrawlerDataSource.md) @@ -73,11 +76,13 @@ - [AddAgentAliasProps](interfaces/AddAgentAliasProps.md) - [AgentActionGroupProps](interfaces/AgentActionGroupProps.md) - [AgentAliasProps](interfaces/AgentAliasProps.md) +- [AgentPromptVariantProps](interfaces/AgentPromptVariantProps.md) - [AgentProps](interfaces/AgentProps.md) - [ApiSchemaConfig](interfaces/ApiSchemaConfig.md) - [ApplicationInferenceProfileAttributes](interfaces/ApplicationInferenceProfileAttributes.md) - [ApplicationInferenceProfileProps](interfaces/ApplicationInferenceProfileProps.md) - [BedrockFoundationModelProps](interfaces/BedrockFoundationModelProps.md) +- [ChatPromptVariantProps](interfaces/ChatPromptVariantProps.md) - [CommonPromptVariantProps](interfaces/CommonPromptVariantProps.md) - [ConfluenceCrawlingFilters](interfaces/ConfluenceCrawlingFilters.md) - [ConfluenceDataSourceAssociationProps](interfaces/ConfluenceDataSourceAssociationProps.md) @@ -121,6 +126,7 @@ - [SharePointDataSourceAssociationProps](interfaces/SharePointDataSourceAssociationProps.md) - [SharePointDataSourceProps](interfaces/SharePointDataSourceProps.md) - [TextPromptVariantProps](interfaces/TextPromptVariantProps.md) +- [ToolConfiguration](interfaces/ToolConfiguration.md) - [WebCrawlerDataSourceAssociationProps](interfaces/WebCrawlerDataSourceAssociationProps.md) - [WebCrawlerDataSourceProps](interfaces/WebCrawlerDataSourceProps.md) diff --git a/apidocs/namespaces/bedrock/classes/ChatMessage.md b/apidocs/namespaces/bedrock/classes/ChatMessage.md new file mode 100644 index 00000000..37131074 --- /dev/null +++ b/apidocs/namespaces/bedrock/classes/ChatMessage.md @@ -0,0 +1,86 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ChatMessage + +# Class: ChatMessage + +## Constructors + +### new ChatMessage() + +> **new ChatMessage**(`role`, `text`): [`ChatMessage`](ChatMessage.md) + +#### Parameters + +##### role + +[`ChatMessageRole`](../enumerations/ChatMessageRole.md) + +##### text + +`string` + +#### Returns + +[`ChatMessage`](ChatMessage.md) + +## Properties + +### role + +> `readonly` **role**: [`ChatMessageRole`](../enumerations/ChatMessageRole.md) + +*** + +### text + +> `readonly` **text**: `string` + +## Methods + +### \_\_render() + +> **\_\_render**(): `MessageProperty` + +**`Internal`** + +Renders as Cfn Property + This is an internal core function and should not be called directly. + +#### Returns + +`MessageProperty` + +*** + +### assistant() + +> `static` **assistant**(`text`): [`ChatMessage`](ChatMessage.md) + +#### Parameters + +##### text + +`string` + +#### Returns + +[`ChatMessage`](ChatMessage.md) + +*** + +### user() + +> `static` **user**(`text`): [`ChatMessage`](ChatMessage.md) + +#### Parameters + +##### text + +`string` + +#### Returns + +[`ChatMessage`](ChatMessage.md) diff --git a/apidocs/namespaces/bedrock/classes/PromptVariant.md b/apidocs/namespaces/bedrock/classes/PromptVariant.md index 2f94156e..ffdcd0b2 100644 --- a/apidocs/namespaces/bedrock/classes/PromptVariant.md +++ b/apidocs/namespaces/bedrock/classes/PromptVariant.md @@ -22,6 +22,14 @@ You can optimize the prompt for specific use cases and models. ## Properties +### genAiResource? + +> `abstract` `optional` **genAiResource**: `PromptGenAiResourceProperty` + +The template configuration. + +*** + ### inferenceConfiguration? > `abstract` `optional` **inferenceConfiguration**: `PromptInferenceConfigurationProperty` @@ -56,12 +64,51 @@ The template configuration. ### templateType -> `abstract` **templateType**: [`TEXT`](../enumerations/PromptTemplateType.md#text) +> `abstract` **templateType**: [`PromptTemplateType`](../enumerations/PromptTemplateType.md) The type of prompt template. ## Methods +### agent() + +> `static` **agent**(`props`): [`PromptVariant`](PromptVariant.md) + +Static method to create an agent prompt template. + +#### Parameters + +##### props + +[`AgentPromptVariantProps`](../interfaces/AgentPromptVariantProps.md) + +#### Returns + +[`PromptVariant`](PromptVariant.md) + +*** + +### chat() + +> `static` **chat**(`props`): [`PromptVariant`](PromptVariant.md) + +Static method to create a chat template. Use this template type when +the model supports the Converse API or the AnthropicClaude Messages API. +This allows you to include a System prompt and previous User messages +and Assistant messages for context. + +#### Parameters + +##### props + +[`ChatPromptVariantProps`](../interfaces/ChatPromptVariantProps.md) + +#### Returns + +[`PromptVariant`](PromptVariant.md) + +*** + ### text() > `static` **text**(`props`): [`PromptVariant`](PromptVariant.md) diff --git a/apidocs/namespaces/bedrock/classes/ToolChoice.md b/apidocs/namespaces/bedrock/classes/ToolChoice.md new file mode 100644 index 00000000..e1228f50 --- /dev/null +++ b/apidocs/namespaces/bedrock/classes/ToolChoice.md @@ -0,0 +1,95 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ToolChoice + +# Class: ToolChoice + +## Constructors + +### new ToolChoice() + +> **new ToolChoice**(`any`, `auto`, `tool`?): [`ToolChoice`](ToolChoice.md) + +#### Parameters + +##### any + +`any` + +##### auto + +`any` + +##### tool? + +`string` + +#### Returns + +[`ToolChoice`](ToolChoice.md) + +## Properties + +### any? + +> `readonly` `optional` **any**: `any` + +*** + +### auto? + +> `readonly` `optional` **auto**: `any` + +*** + +### tool? + +> `readonly` `optional` **tool**: `string` + +*** + +### ANY + +> `readonly` `static` **ANY**: [`ToolChoice`](ToolChoice.md) + +The model must request at least one tool (no text is generated) + +*** + +### AUTO + +> `readonly` `static` **AUTO**: [`ToolChoice`](ToolChoice.md) + +(Default). The Model automatically decides if a tool should be called or whether to generate text instead. + +## Methods + +### \_\_render() + +> **\_\_render**(): `ToolChoiceProperty` + +**`Internal`** + +#### Returns + +`ToolChoiceProperty` + +*** + +### specificTool() + +> `static` **specificTool**(`toolName`): [`ToolChoice`](ToolChoice.md) + +The Model must request the specified tool. Only supported by some models like Anthropic Claude 3 models. + +#### Parameters + +##### toolName + +`string` + +#### Returns + +[`ToolChoice`](ToolChoice.md) diff --git a/apidocs/namespaces/bedrock/enumerations/ChatMessageRole.md b/apidocs/namespaces/bedrock/enumerations/ChatMessageRole.md new file mode 100644 index 00000000..bb70cccc --- /dev/null +++ b/apidocs/namespaces/bedrock/enumerations/ChatMessageRole.md @@ -0,0 +1,25 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ChatMessageRole + +# Enumeration: ChatMessageRole + +## Enumeration Members + +### ASSISTANT + +> **ASSISTANT**: `"assistant"` + +This is the role of the model itself, responding to user inputs based on +the context set by the system. + +*** + +### USER + +> **USER**: `"user"` + +This role represents the human user in the conversation. Inputs from the +user guide the conversation and prompt responses from the assistant. diff --git a/apidocs/namespaces/bedrock/enumerations/PromptTemplateType.md b/apidocs/namespaces/bedrock/enumerations/PromptTemplateType.md index 4117f820..48923c86 100644 --- a/apidocs/namespaces/bedrock/enumerations/PromptTemplateType.md +++ b/apidocs/namespaces/bedrock/enumerations/PromptTemplateType.md @@ -8,6 +8,12 @@ ## Enumeration Members +### CHAT + +> **CHAT**: `"CHAT"` + +*** + ### TEXT > **TEXT**: `"TEXT"` diff --git a/apidocs/namespaces/bedrock/interfaces/AgentPromptVariantProps.md b/apidocs/namespaces/bedrock/interfaces/AgentPromptVariantProps.md new file mode 100644 index 00000000..af6985f0 --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/AgentPromptVariantProps.md @@ -0,0 +1,65 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / AgentPromptVariantProps + +# Interface: AgentPromptVariantProps + +## Extends + +- [`CommonPromptVariantProps`](CommonPromptVariantProps.md) + +## Properties + +### agentAlias + +> `readonly` **agentAlias**: [`IAgentAlias`](IAgentAlias.md) + +An alias pointing to the agent version to be used. + +*** + +### model + +> `readonly` **model**: [`IInvokable`](IInvokable.md) + +The model which is used to run the prompt. The model could be a foundation +model, a custom model, or a provisioned model. + +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`model`](CommonPromptVariantProps.md#model) + +*** + +### promptText + +> `readonly` **promptText**: `string` + +The text prompt. Variables are used by enclosing its name with double curly braces +as in `{{variable_name}}`. + +*** + +### promptVariables? + +> `readonly` `optional` **promptVariables**: `string`[] + +The variables in the prompt template that can be filled in at runtime. + +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`promptVariables`](CommonPromptVariantProps.md#promptvariables) + +*** + +### variantName + +> `readonly` **variantName**: `string` + +The name of the prompt variant. + +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`variantName`](CommonPromptVariantProps.md#variantname) diff --git a/apidocs/namespaces/bedrock/interfaces/ChatPromptVariantProps.md b/apidocs/namespaces/bedrock/interfaces/ChatPromptVariantProps.md new file mode 100644 index 00000000..658a4ffa --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/ChatPromptVariantProps.md @@ -0,0 +1,82 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ChatPromptVariantProps + +# Interface: ChatPromptVariantProps + +## Extends + +- [`CommonPromptVariantProps`](CommonPromptVariantProps.md) + +## Properties + +### inferenceConfiguration? + +> `readonly` `optional` **inferenceConfiguration**: `PromptModelInferenceConfigurationProperty` + +Inference configuration for the Text Prompt + +*** + +### messages + +> `readonly` **messages**: [`ChatMessage`](../classes/ChatMessage.md)[] + +Inference configuration for the Chat Prompt. +Must include at least one User Message. +The messages should alternate between User and Assistant. + +*** + +### model + +> `readonly` **model**: [`IInvokable`](IInvokable.md) + +The model which is used to run the prompt. The model could be a foundation +model, a custom model, or a provisioned model. + +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`model`](CommonPromptVariantProps.md#model) + +*** + +### promptVariables? + +> `readonly` `optional` **promptVariables**: `string`[] + +The variables in the prompt template that can be filled in at runtime. + +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`promptVariables`](CommonPromptVariantProps.md#promptvariables) + +*** + +### system? + +> `readonly` `optional` **system**: `string` + +Context or instructions for the model to consider before generating a response. + +*** + +### toolConfiguration? + +> `readonly` `optional` **toolConfiguration**: [`ToolConfiguration`](ToolConfiguration.md) + +The configuration with available tools to the model and how it must use them. + +*** + +### variantName + +> `readonly` **variantName**: `string` + +The name of the prompt variant. + +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`variantName`](CommonPromptVariantProps.md#variantname) diff --git a/apidocs/namespaces/bedrock/interfaces/CommonPromptVariantProps.md b/apidocs/namespaces/bedrock/interfaces/CommonPromptVariantProps.md index ed91a405..1d5b6423 100644 --- a/apidocs/namespaces/bedrock/interfaces/CommonPromptVariantProps.md +++ b/apidocs/namespaces/bedrock/interfaces/CommonPromptVariantProps.md @@ -9,6 +9,8 @@ ## Extended by - [`TextPromptVariantProps`](TextPromptVariantProps.md) +- [`ChatPromptVariantProps`](ChatPromptVariantProps.md) +- [`AgentPromptVariantProps`](AgentPromptVariantProps.md) ## Properties @@ -21,6 +23,14 @@ model, a custom model, or a provisioned model. *** +### promptVariables? + +> `readonly` `optional` **promptVariables**: `string`[] + +The variables in the prompt template that can be filled in at runtime. + +*** + ### variantName > `readonly` **variantName**: `string` diff --git a/apidocs/namespaces/bedrock/interfaces/TextPromptVariantProps.md b/apidocs/namespaces/bedrock/interfaces/TextPromptVariantProps.md index 081885f6..ecfc7062 100644 --- a/apidocs/namespaces/bedrock/interfaces/TextPromptVariantProps.md +++ b/apidocs/namespaces/bedrock/interfaces/TextPromptVariantProps.md @@ -37,17 +37,21 @@ model, a custom model, or a provisioned model. > `readonly` **promptText**: `string` -The text prompt. Variables are used by encolsing its name with double curly braces +The text prompt. Variables are used by enclosing its name with double curly braces as in `{{variable_name}}`. *** -### promptVariables +### promptVariables? -> `readonly` **promptVariables**: `string`[] +> `readonly` `optional` **promptVariables**: `string`[] The variables in the prompt template that can be filled in at runtime. +#### Inherited from + +[`CommonPromptVariantProps`](CommonPromptVariantProps.md).[`promptVariables`](CommonPromptVariantProps.md#promptvariables) + *** ### variantName diff --git a/apidocs/namespaces/bedrock/interfaces/ToolConfiguration.md b/apidocs/namespaces/bedrock/interfaces/ToolConfiguration.md new file mode 100644 index 00000000..a62ca4b4 --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/ToolConfiguration.md @@ -0,0 +1,19 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ToolConfiguration + +# Interface: ToolConfiguration + +## Properties + +### toolChoice + +> `readonly` **toolChoice**: [`ToolChoice`](../classes/ToolChoice.md) + +*** + +### tools + +> `readonly` **tools**: `ToolProperty`[] diff --git a/package.json b/package.json index 70f0bdc7..3e295790 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,11 @@ "integ:aws-llama-index-data-loader:destroy": "npx projen integ:aws-llama-index-data-loader:destroy", "integ:aws-llama-index-data-loader:snapshot": "npx projen integ:aws-llama-index-data-loader:snapshot", "integ:aws-llama-index-data-loader:watch": "npx projen integ:aws-llama-index-data-loader:watch", + "integ:chatprompt:assert": "npx projen integ:chatprompt:assert", + "integ:chatprompt:deploy": "npx projen integ:chatprompt:deploy", + "integ:chatprompt:destroy": "npx projen integ:chatprompt:destroy", + "integ:chatprompt:snapshot": "npx projen integ:chatprompt:snapshot", + "integ:chatprompt:watch": "npx projen integ:chatprompt:watch", "integ:inference-profiles:assert": "npx projen integ:inference-profiles:assert", "integ:inference-profiles:deploy": "npx projen integ:inference-profiles:deploy", "integ:inference-profiles:destroy": "npx projen integ:inference-profiles:destroy", @@ -59,7 +64,7 @@ }, "devDependencies": { "@aws-cdk/assert": "^2.68.0", - "@aws-cdk/integ-tests-alpha": "2.166.0-alpha.0", + "@aws-cdk/integ-tests-alpha": "2.174.0-alpha.0", "@commitlint/config-conventional": "^18.6.3", "@mrgrain/jsii-struct-builder": "^0.7.43", "@types/jest": "^29.5.14", @@ -67,7 +72,7 @@ "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", "aws-cdk": "^2", - "aws-cdk-lib": "2.166.0", + "aws-cdk-lib": "2.174.0", "aws-sdk-mock": "^5.9.0", "commitlint": "^18.6.1", "constructs": "10.3.0", @@ -92,7 +97,7 @@ "typescript": "^5.7.2" }, "peerDependencies": { - "aws-cdk-lib": "^2.166.0", + "aws-cdk-lib": "^2.174.0", "constructs": "^10.3.0" }, "dependencies": { diff --git a/src/cdk-lib/bedrock/README.md b/src/cdk-lib/bedrock/README.md index 6c52eb1e..56a992da 100644 --- a/src/cdk-lib/bedrock/README.md +++ b/src/cdk-lib/bedrock/README.md @@ -53,20 +53,20 @@ Example of `OpenSearch Serverless`: TypeScript ```ts -import * as s3 from "aws-cdk-lib/aws-s3"; -import { bedrock } from "@cdklabs/generative-ai-cdk-constructs"; +import * as s3 from 'aws-cdk-lib/aws-s3'; +import { bedrock } from '@cdklabs/generative-ai-cdk-constructs'; -const kb = new bedrock.KnowledgeBase(this, "KnowledgeBase", { +const kb = new bedrock.KnowledgeBase(this, 'KnowledgeBase', { embeddingsModel: bedrock.BedrockFoundationModel.TITAN_EMBED_TEXT_V1, - instruction: "Use this knowledge base to answer questions about books. " + "It contains the full text of novels.", + instruction: 'Use this knowledge base to answer questions about books. ' + 'It contains the full text of novels.', }); -const docBucket = new s3.Bucket(this, "DocBucket"); +const docBucket = new s3.Bucket(this, 'DocBucket'); -new bedrock.S3DataSource(this, "DataSource", { +new bedrock.S3DataSource(this, 'DataSource', { bucket: docBucket, knowledgeBase: kb, - dataSourceName: "books", + dataSourceName: 'books', chunkingStrategy: bedrock.ChunkingStrategy.fixedSize({ maxTokens: 500, overlapPercentage: 20, @@ -107,27 +107,27 @@ Example of `Amazon RDS Aurora PostgreSQL`: TypeScript ```ts -import * as s3 from "aws-cdk-lib/aws-s3"; -import { amazonaurora, bedrock } from "@cdklabs/generative-ai-cdk-constructs"; +import * as s3 from 'aws-cdk-lib/aws-s3'; +import { amazonaurora, bedrock } from '@cdklabs/generative-ai-cdk-constructs'; // Dimension of your vector embedding embeddingsModelVectorDimension = 1024; -const auroraDb = new amazonaurora.AmazonAuroraVectorStore(stack, "AuroraDefaultVectorStore", { +const auroraDb = new amazonaurora.AmazonAuroraVectorStore(stack, 'AuroraDefaultVectorStore', { embeddingsModelVectorDimension: embeddingsModelVectorDimension, }); -const kb = new bedrock.KnowledgeBase(this, "KnowledgeBase", { +const kb = new bedrock.KnowledgeBase(this, 'KnowledgeBase', { vectorStore: auroraDb, embeddingsModelVectorDimension: embeddingsModelVectorDimension, - instruction: "Use this knowledge base to answer questions about books. " + "It contains the full text of novels.", + instruction: 'Use this knowledge base to answer questions about books. ' + 'It contains the full text of novels.', }); -const docBucket = new s3.Bucket(this, "DocBucket"); +const docBucket = new s3.Bucket(this, 'DocBucket'); -new bedrock.S3DataSource(this, "DataSource", { +new bedrock.S3DataSource(this, 'DataSource', { bucket: docBucket, knowledgeBase: kb, - dataSourceName: "books", + dataSourceName: 'books', chunkingStrategy: bedrock.ChunkingStrategy.FIXED_SIZE, }); ``` @@ -292,28 +292,28 @@ Example of `Pinecone` (manual, you must have Pinecone vector store created): TypeScript ```ts -import * as s3 from "aws-cdk-lib/aws-s3"; -import { pinecone, bedrock } from "@cdklabs/generative-ai-cdk-constructs"; +import * as s3 from 'aws-cdk-lib/aws-s3'; +import { pinecone, bedrock } from '@cdklabs/generative-ai-cdk-constructs'; const pineconeds = new pinecone.PineconeVectorStore({ - connectionString: "https://your-index-1234567.svc.gcp-starter.pinecone.io", - credentialsSecretArn: "arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name", - textField: "question", - metadataField: "metadata", + connectionString: 'https://your-index-1234567.svc.gcp-starter.pinecone.io', + credentialsSecretArn: 'arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + textField: 'question', + metadataField: 'metadata', }); -const kb = new bedrock.KnowledgeBase(this, "KnowledgeBase", { +const kb = new bedrock.KnowledgeBase(this, 'KnowledgeBase', { vectorStore: pineconeds, embeddingsModel: bedrock.BedrockFoundationModel.TITAN_EMBED_TEXT_V1, - instruction: "Use this knowledge base to answer questions about books. " + "It contains the full text of novels.", + instruction: 'Use this knowledge base to answer questions about books. ' + 'It contains the full text of novels.', }); -const docBucket = new s3.Bucket(this, "DocBucket"); +const docBucket = new s3.Bucket(this, 'DocBucket'); -new bedrock.S3DataSource(this, "DataSource", { +new bedrock.S3DataSource(this, 'DataSource', { bucket: docBucket, knowledgeBase: kb, - dataSourceName: "books", + dataSourceName: 'books', chunkingStrategy: bedrock.ChunkingStrategy.FIXED_SIZE, }); ``` @@ -377,25 +377,25 @@ Typescript ```ts const app = new cdk.App(); -const stack = new cdk.Stack(app, "aws-cdk-bedrock-data-sources-integ-test"); +const stack = new cdk.Stack(app, 'aws-cdk-bedrock-data-sources-integ-test'); -const kb = new KnowledgeBase(stack, "MyKnowledgeBase", { - name: "MyKnowledgeBase", +const kb = new KnowledgeBase(stack, 'MyKnowledgeBase', { + name: 'MyKnowledgeBase', embeddingsModel: BedrockFoundationModel.COHERE_EMBED_MULTILINGUAL_V3, }); -const bucket = new Bucket(stack, "Bucket", {}); -const lambdaFunction = new Function(stack, "MyFunction", { +const bucket = new Bucket(stack, 'Bucket', {}); +const lambdaFunction = new Function(stack, 'MyFunction', { runtime: cdk.aws_lambda.Runtime.PYTHON_3_9, - handler: "index.handler", + handler: 'index.handler', code: cdk.aws_lambda.Code.fromInline('print("Hello, World!")'), }); -const secret = new Secret(stack, "Secret"); -const key = new Key(stack, "Key"); +const secret = new Secret(stack, 'Secret'); +const key = new Key(stack, 'Key'); kb.addWebCrawlerDataSource({ - sourceUrls: ["https://docs.aws.amazon.com/"], + sourceUrls: ['https://docs.aws.amazon.com/'], chunkingStrategy: ChunkingStrategy.HIERARCHICAL_COHERE, customTransformation: CustomTransformation.lambda({ lambdaFunction: lambdaFunction, @@ -412,59 +412,59 @@ kb.addS3DataSource({ }); kb.addConfluenceDataSource({ - dataSourceName: "TestDataSource", + dataSourceName: 'TestDataSource', authSecret: secret, kmsKey: key, - confluenceUrl: "https://example.atlassian.net", + confluenceUrl: 'https://example.atlassian.net', filters: [ { objectType: ConfluenceObjectType.ATTACHMENT, - includePatterns: [".*\\.pdf"], - excludePatterns: [".*private.*\\.pdf"], + includePatterns: ['.*\\.pdf'], + excludePatterns: ['.*private.*\\.pdf'], }, { objectType: ConfluenceObjectType.PAGE, - includePatterns: [".*public.*\\.pdf"], - excludePatterns: [".*confidential.*\\.pdf"], + includePatterns: ['.*public.*\\.pdf'], + excludePatterns: ['.*confidential.*\\.pdf'], }, ], }); kb.addSalesforceDataSource({ authSecret: secret, - endpoint: "https://your-instance.my.salesforce.com", + endpoint: 'https://your-instance.my.salesforce.com', kmsKey: key, filters: [ { objectType: SalesforceObjectType.ATTACHMENT, - includePatterns: [".*\\.pdf"], - excludePatterns: [".*private.*\\.pdf"], + includePatterns: ['.*\\.pdf'], + excludePatterns: ['.*private.*\\.pdf'], }, { objectType: SalesforceObjectType.CONTRACT, - includePatterns: [".*public.*\\.pdf"], - excludePatterns: [".*confidential.*\\.pdf"], + includePatterns: ['.*public.*\\.pdf'], + excludePatterns: ['.*confidential.*\\.pdf'], }, ], }); kb.addSharePointDataSource({ - dataSourceName: "SharepointDataSource", + dataSourceName: 'SharepointDataSource', authSecret: secret, kmsKey: key, - domain: "yourdomain", - siteUrls: ["https://yourdomain.sharepoint.com/sites/mysite"], - tenantId: "888d0b57-69f1-4fb8-957f-e1f0bedf64de", + domain: 'yourdomain', + siteUrls: ['https://yourdomain.sharepoint.com/sites/mysite'], + tenantId: '888d0b57-69f1-4fb8-957f-e1f0bedf64de', filters: [ { objectType: SharePointObjectType.PAGE, - includePatterns: [".*\\.pdf"], - excludePatterns: [".*private.*\\.pdf"], + includePatterns: ['.*\\.pdf'], + excludePatterns: ['.*private.*\\.pdf'], }, { objectType: SharePointObjectType.FILE, - includePatterns: [".*public.*\\.pdf"], - excludePatterns: [".*confidential.*\\.pdf"], + includePatterns: ['.*public.*\\.pdf'], + excludePatterns: ['.*confidential.*\\.pdf'], }, ], }); @@ -778,9 +778,9 @@ The following example creates an Agent with a simple instruction and default pro TypeScript ```ts -const agent = new bedrock.Agent(this, "Agent", { +const agent = new bedrock.Agent(this, 'Agent', { foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, - instruction: "You are a helpful and friendly agent that answers questions about literature.", + instruction: 'You are a helpful and friendly agent that answers questions about literature.', }); agent.addKnowledgeBase(kb); @@ -810,11 +810,12 @@ const cris = bedrock.CrossRegionInferenceProfile.fromConfig({ const agent = new bedrock.Agent(this, 'Agent', { foundationModel: cris, - instruction: 'You are a helpful and friendly agent that answers questions about agriculture.' + instruction: 'You are a helpful and friendly agent that answers questions about agriculture.', }); - ``` + Python + ```python cris = bedrock.CrossRegionInferenceProfile.from_config( geo_region= bedrock.CrossRegionInferenceProfileRegion.US, @@ -836,19 +837,19 @@ For more information on cross region inference, please refer to [System defined An action group defines functions your agent can call. The functions are Lambda functions. The action group uses an OpenAPI schema to tell the agent what your functions do and how to call them. ```ts -const actionGroupFunction = new lambda_python.PythonFunction(this, "ActionGroupFunction", { +const actionGroupFunction = new lambda_python.PythonFunction(this, 'ActionGroupFunction', { runtime: lambda.Runtime.PYTHON_3_12, - entry: path.join(__dirname, "../lambda/action-group"), + entry: path.join(__dirname, '../lambda/action-group'), }); -const actionGroup = new bedrock.AgentActionGroup(this, "MyActionGroup", { - actionGroupName: "query-library", - description: "Use these functions to get information about the books in the library.", +const actionGroup = new bedrock.AgentActionGroup(this, 'MyActionGroup', { + actionGroupName: 'query-library', + description: 'Use these functions to get information about the books in the library.', actionGroupExecutor: { lambda: actionGroupFunction, }, - actionGroupState: "ENABLED", - apiSchema: bedrock.ApiSchema.fromAsset(path.join(__dirname, "action-group.yaml")), + actionGroupState: 'ENABLED', + apiSchema: bedrock.ApiSchema.fromAsset(path.join(__dirname, 'action-group.yaml')), }); agent.addActionGroup(actionGroup); @@ -893,25 +894,25 @@ Bedrock Agents allows you to customize the prompts and LLM configuration for its TypeScript ```ts -import { readFileSync } from "fs"; +import { readFileSync } from 'fs'; -const orchestration = readFileSync("prompts/orchestration.txt", "utf-8"); -const agent = new bedrock.Agent(this, "Agent", { +const orchestration = readFileSync('prompts/orchestration.txt', 'utf-8'); +const agent = new bedrock.Agent(this, 'Agent', { foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, - instruction: "You are a helpful and friendly agent that answers questions about literature.", + instruction: 'You are a helpful and friendly agent that answers questions about literature.', promptOverrideConfiguration: { promptConfigurations: [ { promptType: bedrock.PromptType.PRE_PROCESSING, promptState: bedrock.PromptState.DISABLED, promptCreationMode: bedrock.PromptCreationMode.OVERRIDDEN, - basePromptTemplate: "disabled", + basePromptTemplate: 'disabled', inferenceConfiguration: { temperature: 0.0, topP: 1, topK: 250, maximumLength: 1, - stopSequences: ["\n\nHuman:"], + stopSequences: ['\n\nHuman:'], }, }, { @@ -924,7 +925,7 @@ const agent = new bedrock.Agent(this, "Agent", { topP: 1, topK: 250, maximumLength: 2048, - stopSequences: ["", "", ""], + stopSequences: ['', '', ''], }, }, ], @@ -987,11 +988,11 @@ The `Agent` resource optionally takes an `aliasName` property that, if defined, TypeScript ```ts -const agent = new bedrock.Agent(this, "Agent", { +const agent = new bedrock.Agent(this, 'Agent', { foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, - instruction: "You are a helpful and friendly agent that answers questions about literature.", + instruction: 'You are a helpful and friendly agent that answers questions about literature.', knowledgeBases: [kb], - aliasName: "latest", + aliasName: 'latest', }); ``` @@ -1016,8 +1017,8 @@ TypeScript ```ts agent.addAlias({ - aliasName: "prod", - agentVersion: "12", + aliasName: 'prod', + agentVersion: '12', }); ``` @@ -1035,10 +1036,10 @@ Alternatively, you can use the `AgentAlias` resource if you want to create an Al TypeScript ```ts -const alias = new bedrock.AgentAlias(this, "ProdAlias", { - agentId: "ABCDE12345", - aliasName: "prod", - agentVersion: "12", +const alias = new bedrock.AgentAlias(this, 'ProdAlias', { + agentId: 'ABCDE12345', + aliasName: 'prod', + agentVersion: '12', }); ``` @@ -1071,9 +1072,9 @@ You can create a Guardrail with a minimum blockedInputMessaging ,blockedOutputsM TypeScript ```ts -const guardrails = new bedrock.Guardrail(this, "bedrockGuardrails", { - name: "my-BedrockGuardrails", - description: "Legal ethical guardrails.", +const guardrails = new bedrock.Guardrail(this, 'bedrockGuardrails', { + name: 'my-BedrockGuardrails', + description: 'Legal ethical guardrails.', }); // Optional - Add Sensitive information filters @@ -1084,9 +1085,9 @@ guardrail.addPIIFilter({ }); guardrail.addRegexFilter({ - name: "TestRegexFilter", - description: "This is a test regex filter", - pattern: "/^[A-Z]{2}d{6}$/", + name: 'TestRegexFilter', + description: 'This is a test regex filter', + pattern: '/^[A-Z]{2}d{6}$/', action: bedrock.GuardrailAction.ANONYMIZE, }); @@ -1107,43 +1108,43 @@ guardrail.addContextualGroundingFilter({ guardrail.addDeniedTopicFilter(Topic.FINANCIAL_ADVICE); guardrail.addDeniedTopicFilter( Topic.custom({ - name: "Legal_Advice", + name: 'Legal_Advice', definition: - "Offering guidance or suggestions on legal matters, legal actions, interpretation of laws, or legal rights and responsibilities.", + 'Offering guidance or suggestions on legal matters, legal actions, interpretation of laws, or legal rights and responsibilities.', examples: [ - "Can I sue someone for this?", - "What are my legal rights in this situation?", - "Is this action against the law?", - "What should I do to file a legal complaint?", - "Can you explain this law to me?", + 'Can I sue someone for this?', + 'What are my legal rights in this situation?', + 'Is this action against the law?', + 'What should I do to file a legal complaint?', + 'Can you explain this law to me?', ], }) ); // Optional - Add Word filters. You can upload words from a file with addWordFilterFromFile function. -guardrail.addWordFilter("drugs"); +guardrail.addWordFilter('drugs'); guardrail.addManagedWordListFilter(ManagedWordFilterType.PROFANITY); -guardrails.addWordFilterFromFile("./scripts/wordsPolicy.csv"); +guardrails.addWordFilterFromFile('./scripts/wordsPolicy.csv'); // versioning - if you change any guardrail configuration, a new version will be created -guardrails.createVersion("testversion"); +guardrails.createVersion('testversion'); // Importing existing guardrail -const importedGuardrail = bedrock.Guardrail.fromGuardrailAttributes(stack, "TestGuardrail", { - guardrailArn: "arn:aws:bedrock:us-east-1:123456789012:guardrail/oygh3o8g7rtl", - guardrailVersion: "1", //optional +const importedGuardrail = bedrock.Guardrail.fromGuardrailAttributes(stack, 'TestGuardrail', { + guardrailArn: 'arn:aws:bedrock:us-east-1:123456789012:guardrail/oygh3o8g7rtl', + guardrailVersion: '1', //optional kmsKey: kmsKey, //optional }); // Importing Guardrails created through the L1 CDK CfnGuardrail construct -const cfnGuardrail = new CfnGuardrail(this, "MyCfnGuardrail", { - blockedInputMessaging: "blockedInputMessaging", - blockedOutputsMessaging: "blockedOutputsMessaging", - name: "namemycfnguardrails", +const cfnGuardrail = new CfnGuardrail(this, 'MyCfnGuardrail', { + blockedInputMessaging: 'blockedInputMessaging', + blockedOutputsMessaging: 'blockedOutputsMessaging', + name: 'namemycfnguardrails', wordPolicyConfig: { wordsConfig: [ { - text: "drugs", + text: 'drugs', }, ], }, @@ -1246,19 +1247,19 @@ time by applying the same prompt to different workflows. You can include variabl adjust the prompt for different use case. The `Prompt` resource allows you to create a new prompt. -Example of `Prompt`: +Example of a basic Text `Prompt`: **TypeScript** ```ts -const cmk = new kms.Key(this, "cmk", {}); +const cmk = new kms.Key(this, 'cmk', {}); const claudeModel = BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_V1_0; const variant1 = PromptVariant.text({ - variantName: "variant1", + variantName: 'variant1', model: claudeModel, - promptVariables: ["topic"], - promptText: "This is my first text prompt. Please summarize our conversation on: {{topic}}.", + promptVariables: ['topic'], + promptText: 'This is my first text prompt. Please summarize our conversation on: {{topic}}.', inferenceConfiguration: { temperature: 1.0, topP: 0.999, @@ -1266,15 +1267,68 @@ const variant1 = PromptVariant.text({ }, }); -const prompt1 = new Prompt(this, "prompt1", { - promptName: "prompt1", - description: "my first prompt", +const prompt1 = new Prompt(this, 'prompt1', { + promptName: 'prompt1', + description: 'my first prompt', defaultVariant: variant1, variants: [variant1], encryptionKey: cmk, }); ``` +Example of a "Chat" `Prompt`. Use this template type when the model supports the Converse API or the Anthropic Claude Messages API. +This allows you to include a System prompt and previous User messages and Assistant messages for context. + +**TypeScript** + +```ts +const cmk = new kms.Key(this, 'cmk', {}); + +const variantChat = PromptVariant.chat({ + variantName: 'variant1', + model: BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0, + messages: [ + ChatMessage.userMessage('From now on, you speak Japanese!'), + ChatMessage.assistantMessage('Konnichiwa!'), + ChatMessage.userMessage('From now on, you speak {{language}}!'), + ], + system: 'You are a helpful assistant that only speaks the language you`re told.', + promptVariables: ['language'], + toolConfiguration: { + toolChoice: ToolChoice.AUTO, + tools: [ + { + toolSpec: { + name: 'top_song', + description: 'Get the most popular song played on a radio station.', + inputSchema: { + json: { + type: 'object', + properties: { + sign: { + type: 'string', + description: + 'The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR.', + }, + }, + required: ['sign'], + }, + }, + }, + }, + ], + }, +}); + +new Prompt(stack, 'prompt1', { + promptName: 'prompt-chat', + description: 'my first chat prompt', + defaultVariant: variantChat, + variants: [variantChat], + kmsKey: cmk, +}); +``` + ### Prompt Variants Prompt variants in the context of Amazon Bedrock refer to alternative configurations of a prompt, @@ -1320,27 +1374,27 @@ to update the version whenever a certain configuration property changes. **TypeScript** ```ts -new PromptVersion(prompt1, "my first version"); +new PromptVersion(prompt1, 'my first version'); ``` or alternatively: ```ts -prompt1.createVersion("my first version"); +prompt1.createVersion('my first version'); ``` ## System defined inference profiles You can build a CrossRegionInferenceProfile using a system defined inference profile. The inference profile will route requests to the Regions defined in the cross region (system-defined) inference profile that you choose. You can find the system defined inference profiles by navigating to your console (Amazon Bedrock -> Cross-region inference) or programmatically, for instance using [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock/client/list_inference_profiles.html). -Before using creating a CrossRegionInferenceProfile, ensure that you have access to the models and regions defined in the inference profiles. For instance, if you see the system defined inference profile "us.anthropic.claude-3-5-sonnet-20241022-v2:0" defined in your region, the table mentions that inference requests will be routed to US East (Virginia) us-east-1, US East (Ohio) us-east-2 and US West (Oregon) us-west-2. Thus, you need to have model access enabled in those regions for the model ```anthropic.claude-3-5-sonnet-20241022-v2:0```. You can then create the CrossRegionInferenceProfile as follows: +Before using creating a CrossRegionInferenceProfile, ensure that you have access to the models and regions defined in the inference profiles. For instance, if you see the system defined inference profile "us.anthropic.claude-3-5-sonnet-20241022-v2:0" defined in your region, the table mentions that inference requests will be routed to US East (Virginia) us-east-1, US East (Ohio) us-east-2 and US West (Oregon) us-west-2. Thus, you need to have model access enabled in those regions for the model `anthropic.claude-3-5-sonnet-20241022-v2:0`. You can then create the CrossRegionInferenceProfile as follows: TypeScript ```ts const cris = bedrock.CrossRegionInferenceProfile.fromConfig({ geoRegion: bedrock.CrossRegionInferenceProfileRegion.US, - model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0 + model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0, }); ``` @@ -1360,17 +1414,20 @@ You can create an application inference profile with one or more Regions to trac To create an application inference profile for one Region, specify a foundation model. Usage and costs for requests made to that Region with that model will be tracked. To create an application inference profile for multiple Regions, specify a cross region (system-defined) inference profile. The inference profile will route requests to the Regions defined in the cross region (system-defined) inference profile that you choose. Usage and costs for requests made to the Regions in the inference profile will be tracked. You can find the system defined inference profiles by navigating to your console (Amazon Bedrock -> Cross-region inference) or programmatically, for instance using [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock/client/list_inference_profiles.html): + ``` bedrock = session.client("bedrock", region_name="us-east-1") bedrock.list_inference_profiles(typeEquals='SYSTEM_DEFINED') ``` Before using application inference profiles, ensure that: + - You have appropriate IAM permissions - You have access to the models and regions defined in the inference profiles - Ensure proper configuration of the required API permissions for inference profile-related actions Specifically the role you are assuming needs to have permissions for following actions in the IAM policy + ``` "Action": [ "bedrock:GetInferenceProfile", @@ -1381,7 +1438,9 @@ Specifically the role you are assuming needs to have permissions for following a "bedrock:ListTagsForResource" ] ``` + You can restrict to specific resources by applying "Resources" tag in the IAM policy. + ``` "Resource": ["arn:aws:bedrock:*:*:application-inference-profile/*"] ``` @@ -1394,18 +1453,18 @@ TypeScript const appInfProfile1 = new ApplicationInferenceProfile(this, 'myapplicationprofile', { inferenceProfileName: 'claude 3 sonnet v1', modelSource: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_V1_0, - tags: [{key: 'test', value: 'test'}] + tags: [{ key: 'test', value: 'test' }], }); // To create an application inference profile across regions, specify the cross region inference profile const cris = bedrock.CrossRegionInferenceProfile.fromConfig({ geoRegion: bedrock.CrossRegionInferenceProfileRegion.US, - model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0 + model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0, }); const appInfProfile2 = new ApplicationInferenceProfile(this, 'myapplicationprofile2', { inferenceProfileName: 'claude 3 sonnet v1', - modelSource: cris + modelSource: cris, }); // Import a Cfn L1 construct created application inference profile @@ -1423,7 +1482,6 @@ const appInfProfile4 = bedrock.ApplicationInferenceProfile.fromApplicationInfere inferenceProfileArn: 'arn:aws:bedrock:us-east-1:XXXXX:application-inference-profile/ID', inferenceProfileIdentifier: 'arn:aws:bedrock:us-east-1:XXXXXXX:application-inference-profile/ID', }); - ``` Python @@ -1438,7 +1496,7 @@ appInfProfile1 = bedrock.ApplicationInferenceProfile(self, 'myapplicationprofile tags=[CfnTag( key="key", value="value" - )] + )] ) # To create an application inference profile across regions, specify the cross region inference profile @@ -1467,4 +1525,4 @@ cfnaip = CfnApplicationInferenceProfile(this, 'mytestaip4', ) appInfProfile4 = bedrock.ApplicationInferenceProfile.from_cfn_application_inference_profile(cfnaip); -``` \ No newline at end of file +``` diff --git a/src/cdk-lib/bedrock/index.ts b/src/cdk-lib/bedrock/index.ts index a97272e5..74183ead 100644 --- a/src/cdk-lib/bedrock/index.ts +++ b/src/cdk-lib/bedrock/index.ts @@ -21,6 +21,7 @@ export * from './guardrails/guardrails'; export * from './models'; export * from './prompts/prompt'; export * from './prompts/prompt-version'; +export * from './prompts/prompt-variant'; export * from './data-sources/base-data-source'; export * from './data-sources/chunking'; export * from './data-sources/parsing'; diff --git a/src/cdk-lib/bedrock/prompts/prompt-variant.ts b/src/cdk-lib/bedrock/prompts/prompt-variant.ts new file mode 100644 index 00000000..24bbc3b0 --- /dev/null +++ b/src/cdk-lib/bedrock/prompts/prompt-variant.ts @@ -0,0 +1,293 @@ +/** + * 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. + */ +import { aws_bedrock as bedrock } from 'aws-cdk-lib'; +import { CfnPrompt } from 'aws-cdk-lib/aws-bedrock'; +import { IAgentAlias } from '../agent-alias'; +import { IInvokable } from '../models'; + +// ------------------------------------------------------ +// COMMON +// ------------------------------------------------------ +export enum PromptTemplateType { + TEXT = 'TEXT', + CHAT = 'CHAT', +} + +export interface CommonPromptVariantProps { + /** + * The name of the prompt variant. + */ + readonly variantName: string; + /** + * The model which is used to run the prompt. The model could be a foundation + * model, a custom model, or a provisioned model. + */ + readonly model: IInvokable; + /** + * The variables in the prompt template that can be filled in at runtime. + */ + readonly promptVariables?: string[]; +} + +// ------------------------------------------------------ +// TEXT +// ------------------------------------------------------ +export interface TextPromptVariantProps extends CommonPromptVariantProps { + /** + * Inference configuration for the Text Prompt + */ + readonly inferenceConfiguration?: bedrock.CfnPrompt.PromptModelInferenceConfigurationProperty; + /** + * The text prompt. Variables are used by enclosing its name with double curly braces + * as in `{{variable_name}}`. + */ + readonly promptText: string; +} + +// ------------------------------------------------------ +// CHAT +// ------------------------------------------------------ +export interface ChatPromptVariantProps extends CommonPromptVariantProps { + /** + * Inference configuration for the Chat Prompt. + * Must include at least one User Message. + * The messages should alternate between User and Assistant. + */ + readonly messages: ChatMessage[]; + /** + * Context or instructions for the model to consider before generating a response. + */ + readonly system?: string; + /** + * The configuration with available tools to the model and how it must use them. + */ + readonly toolConfiguration?: ToolConfiguration; + /** + * Inference configuration for the Text Prompt + */ + readonly inferenceConfiguration?: bedrock.CfnPrompt.PromptModelInferenceConfigurationProperty; +} + +export enum ChatMessageRole { + /** + * This role represents the human user in the conversation. Inputs from the + * user guide the conversation and prompt responses from the assistant. + */ + USER = 'user', + /** + * This is the role of the model itself, responding to user inputs based on + * the context set by the system. + */ + ASSISTANT = 'assistant', +} + +export class ChatMessage { + public static user(text: string) { + return new ChatMessage(ChatMessageRole.USER, text); + } + public static assistant(text: string) { + return new ChatMessage(ChatMessageRole.ASSISTANT, text); + } + public readonly role: ChatMessageRole; + public readonly text: string; + + constructor(role: ChatMessageRole, text: string) { + (this.role = role), (this.text = text); + } + /** + * Renders as Cfn Property + * @internal This is an internal core function and should not be called directly. + */ + public __render(): CfnPrompt.MessageProperty { + return { + role: this.role, + content: [ + { + text: this.text, + }, + ], + }; + } +} + +export interface ToolConfiguration { + readonly toolChoice: ToolChoice; + readonly tools: CfnPrompt.ToolProperty[]; +} + +export class ToolChoice { + /** The model must request at least one tool (no text is generated) */ + public static readonly ANY = new ToolChoice({}, undefined, undefined); + /** (Default). The Model automatically decides if a tool should be called or whether to generate text instead.*/ + public static readonly AUTO = new ToolChoice(undefined, {}, undefined); + /** The Model must request the specified tool. Only supported by some models like Anthropic Claude 3 models. */ + public static specificTool(toolName: string) { + return new ToolChoice(undefined, undefined, toolName); + } + public readonly any?: any; + public readonly auto?: any; + public readonly tool?: string; + + constructor(any: any, auto: any, tool?: string) { + (this.any = any), (this.auto = auto), (this.tool = tool); + } + /** + * + * @internal + */ + public __render(): CfnPrompt.ToolChoiceProperty { + return { + any: this.any, + auto: this.auto, + tool: this.tool ? { name: this.tool } : undefined, + }; + } +} +// ------------------------------------------------------ +// AGENT +// ------------------------------------------------------ + +export interface AgentPromptVariantProps extends CommonPromptVariantProps { + /** + * An alias pointing to the agent version to be used. + */ + readonly agentAlias: IAgentAlias; + /** + * The text prompt. Variables are used by enclosing its name with double curly braces + * as in `{{variable_name}}`. + */ + readonly promptText: string; +} + +// ------------------------------------------------------ +// VARIANTS +// ------------------------------------------------------ +/** + * Variants are specific sets of inputs that guide FMs on Amazon Bedrock to + * generate an appropriate response or output for a given task or instruction. + * You can optimize the prompt for specific use cases and models. + */ +export abstract class PromptVariant { + // ------------------------------------------------------ + // Static Methods + // ------------------------------------------------------ + /** + * Static method to create a text template + */ + public static text(props: TextPromptVariantProps): PromptVariant { + return { + name: props.variantName, + templateType: PromptTemplateType.TEXT, + modelId: props.model.invokableArn, + inferenceConfiguration: { + text: { ...props.inferenceConfiguration }, + }, + templateConfiguration: { + text: { + inputVariables: props.promptVariables?.flatMap((variable: string) => { + return { name: variable }; + }), + text: props.promptText, + }, + }, + }; + } + + /** + * Static method to create a chat template. Use this template type when + * the model supports the Converse API or the AnthropicClaude Messages API. + * This allows you to include a System prompt and previous User messages + * and Assistant messages for context. + */ + public static chat(props: ChatPromptVariantProps): PromptVariant { + return { + name: props.variantName, + templateType: PromptTemplateType.CHAT, + modelId: props.model.invokableArn, + inferenceConfiguration: { + text: { ...props.inferenceConfiguration }, + }, + templateConfiguration: { + chat: { + inputVariables: props.promptVariables?.flatMap((variable: string) => { + return { name: variable }; + }), + messages: props.messages?.flatMap(m => m.__render()), + system: props.system ? [{ text: props.system }] : undefined, + toolConfiguration: props.toolConfiguration + ? { + toolChoice: props.toolConfiguration.toolChoice.__render(), + tools: props.toolConfiguration.tools, + } + : undefined, + }, + }, + }; + } + + /** + * Static method to create an agent prompt template. + */ + public static agent(props: AgentPromptVariantProps): PromptVariant { + return { + name: props.variantName, + templateType: PromptTemplateType.TEXT, + genAiResource: { + agent: { + agentIdentifier: props.agentAlias.aliasArn, + }, + }, + templateConfiguration: { + text: { + inputVariables: props.promptVariables?.flatMap((variable: string) => { + return { name: variable }; + }), + text: props.promptText, + }, + }, + }; + } + + // ------------------------------------------------------ + // Properties + // ------------------------------------------------------ + /** + * The name of the prompt variant. + */ + public abstract name: string; + /** + * The type of prompt template. + */ + public abstract templateType: PromptTemplateType; + /** + * The inference configuration. + */ + public abstract inferenceConfiguration?: bedrock.CfnPrompt.PromptInferenceConfigurationProperty; + /** + * The unique identifier of the model with which to run inference on the prompt. + */ + public abstract modelId?: string; + /** + * The template configuration. + */ + public abstract templateConfiguration: bedrock.CfnPrompt.PromptTemplateConfigurationProperty; + /** + * The template configuration. + */ + public abstract genAiResource?: bedrock.CfnPrompt.PromptGenAiResourceProperty; + + // ------------------------------------------------------ + // Constructor + // ------------------------------------------------------ + protected constructor() {} +} diff --git a/src/cdk-lib/bedrock/prompts/prompt.ts b/src/cdk-lib/bedrock/prompts/prompt.ts index 1a9b2a3e..35f3ca91 100644 --- a/src/cdk-lib/bedrock/prompts/prompt.ts +++ b/src/cdk-lib/bedrock/prompts/prompt.ts @@ -16,99 +16,7 @@ import { Grant, IGrantable } from 'aws-cdk-lib/aws-iam'; import { IKey } from 'aws-cdk-lib/aws-kms'; import { md5hash } from 'aws-cdk-lib/core/lib/helpers-internal'; import { Construct } from 'constructs'; -import { IInvokable } from '../models'; - -export enum PromptTemplateType { - TEXT = 'TEXT', -} - -export interface CommonPromptVariantProps { - /** - * The name of the prompt variant. - */ - readonly variantName: string; - /** - * The model which is used to run the prompt. The model could be a foundation - * model, a custom model, or a provisioned model. - */ - readonly model: IInvokable; -} - -export interface TextPromptVariantProps extends CommonPromptVariantProps { - /** - * Inference configuration for the Text Prompt - */ - readonly inferenceConfiguration?: bedrock.CfnPrompt.PromptModelInferenceConfigurationProperty; - /** - * The variables in the prompt template that can be filled in at runtime. - */ - readonly promptVariables: string[]; - /** - * The text prompt. Variables are used by encolsing its name with double curly braces - * as in `{{variable_name}}`. - */ - readonly promptText: string; -} - -/** - * Variants are specific sets of inputs that guide FMs on Amazon Bedrock to - * generate an appropriate response or output for a given task or instruction. - * You can optimize the prompt for specific use cases and models. - */ -export abstract class PromptVariant { - // ------------------------------------------------------ - // Static Methods - // ------------------------------------------------------ - /** - * Static method to create a text template - */ - public static text(props: TextPromptVariantProps): PromptVariant { - return { - name: props.variantName, - templateType: PromptTemplateType.TEXT, - modelId: props.model.invokableArn, - inferenceConfiguration: { - text: { ...props.inferenceConfiguration }, - }, - templateConfiguration: { - text: { - inputVariables: props.promptVariables.flatMap((variable: string) => { - return { name: variable }; - }), - text: props.promptText, - }, - }, - }; - } - // ------------------------------------------------------ - // Properties - // ------------------------------------------------------ - /** - * The name of the prompt variant. - */ - public abstract name: string; - /** - * The type of prompt template. - */ - public abstract templateType: PromptTemplateType; - /** - * The inference configuration. - */ - public abstract inferenceConfiguration?: bedrock.CfnPrompt.PromptInferenceConfigurationProperty; - /** - * The unique identifier of the model with which to run inference on the prompt. - */ - public abstract modelId?: string; - /** - * The template configuration. - */ - public abstract templateConfiguration: bedrock.CfnPrompt.PromptTemplateConfigurationProperty; - - // ------------------------------------------------------ - // Constructor - // ------------------------------------------------------ - protected constructor() {} -} +import { PromptVariant } from './prompt-variant'; /****************************************************************************** * COMMON @@ -308,7 +216,7 @@ export class Prompt extends Construct implements IPrompt { }), }; - // Hash calculation useful for versioning of the guardrail + // Hash calculation useful for versioning this._hash = md5hash(JSON.stringify(cfnProps)); // ------------------------------------------------------ @@ -347,10 +255,11 @@ export class Prompt extends Construct implements IPrompt { * Validates whether the number of prompt variants is respected. */ private validatePromptVariants() { + const MAX_VARIANTS = 3; const errors: string[] = []; - if (this.variants.length > 3) { + if (this.variants.length > MAX_VARIANTS) { errors.push( - `Error: Too many variants specified. The maximum allowed is 3, but you have provided ${this.variants.length} variants.`, + `Error: Too many variants specified. The maximum allowed is ${MAX_VARIANTS}, but you have provided ${this.variants.length} variants.`, ); } return errors; diff --git a/src/common/helpers/custom-resource-provider-helper.ts b/src/common/helpers/custom-resource-provider-helper.ts index 9fa21c19..5b73e140 100644 --- a/src/common/helpers/custom-resource-provider-helper.ts +++ b/src/common/helpers/custom-resource-provider-helper.ts @@ -143,6 +143,17 @@ export function buildCustomResourceProvider(props: CRProviderProps): ICRProvider this.serviceToken = this.provider.serviceToken; + NagSuppressions.addResourceSuppressions( + customResourceFunction, + [ + { + id: 'AwsSolutions-L1', + reason: 'Lambda runtime version is managed upstream by CDK.', + }, + ], + true, + ); + NagSuppressions.addResourceSuppressionsByPath( cdk.Stack.of(this), `${this.provider.node.path}/framework-onEvent/Resource`, diff --git a/src/common/props/DockerLambdaCustomProps.ts b/src/common/props/DockerLambdaCustomProps.ts index 2523169a..2f691ac8 100644 --- a/src/common/props/DockerLambdaCustomProps.ts +++ b/src/common/props/DockerLambdaCustomProps.ts @@ -29,7 +29,7 @@ export interface DockerLambdaCustomProps { readonly systemLogLevelV2?: aws_lambda.SystemLogLevel; /** * Enable SnapStart for Lambda Function. - * SnapStart is currently supported only for Java 11, 17 runtime + * SnapStart is currently supported for Java 11, Java 17, Python 3.12, Python 3.13, and .NET 8 runtime * @default - No snapstart * @stability stable */ diff --git a/test/cdk-lib/bedrock/prompts.test.ts b/test/cdk-lib/bedrock/prompts.test.ts index 3b55c44f..911e6557 100644 --- a/test/cdk-lib/bedrock/prompts.test.ts +++ b/test/cdk-lib/bedrock/prompts.test.ts @@ -16,8 +16,15 @@ import { expect as cdkExpect, haveResource, haveResourceLike } from '@aws-cdk/as import * as cdk from 'aws-cdk-lib'; import { aws_bedrock as cdk_bedrock } from 'aws-cdk-lib'; import * as kms from 'aws-cdk-lib/aws-kms'; -import { BedrockFoundationModel, CrossRegionInferenceProfile, CrossRegionInferenceProfileRegion } from '../../../src/cdk-lib/bedrock'; -import { Prompt, PromptVariant } from '../../../src/cdk-lib/bedrock/prompts/prompt'; +import { + BedrockFoundationModel, + ChatMessage, + CrossRegionInferenceProfile, + CrossRegionInferenceProfileRegion, + PromptVariant, + Prompt, + ToolChoice, +} from '../../../src/cdk-lib/bedrock'; describe('Prompt', () => { let app: cdk.App; @@ -102,7 +109,7 @@ describe('Prompt', () => { ); }); - test('creates a Prompt with one variant - BedrockFoundationModel', () => { + test('creates a Prompt with one TEXT variant - BedrockFoundationModel', () => { // GIVEN const variant1 = PromptVariant.text({ variantName: 'variant1', @@ -152,6 +159,145 @@ describe('Prompt', () => { ); }); + test('creates a Prompt with one CHAT variant - BedrockFoundationModel', () => { + // GIVEN + const variant1 = PromptVariant.chat({ + variantName: 'variantChat', + model: BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0, + inferenceConfiguration: { + temperature: 1.0, + topP: 0.999, + maxTokens: 2000, + }, + messages: [ + ChatMessage.user('From now on, you speak Japanese!'), + ChatMessage.assistant('Konnichiwa!'), + ChatMessage.user('From now on, you speak {{language}}!'), + ], + system: 'You are a helpful assistant that only speaks the language you`re told.', + promptVariables: ['language'], + toolConfiguration: { + toolChoice: ToolChoice.AUTO, + tools: [ + { + toolSpec: { + name: 'top_song', + description: 'Get the most popular song played on a radio station.', + inputSchema: { + json: { + type: 'object', + properties: { + sign: { + type: 'string', + description: + 'The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR.', + }, + }, + required: ['sign'], + }, + }, + }, + }, + ], + }, + }); + + new Prompt(stack, 'prompt1', { + promptName: 'promptChat', + description: 'my chat prompt', + defaultVariant: variant1, + variants: [variant1], + }); + // WHEN & THEN + + cdkExpect(stack).to( + haveResourceLike('AWS::Bedrock::Prompt', { + Name: 'promptChat', + Description: 'my chat prompt', + DefaultVariant: 'variantChat', + Variants: [ + { + InferenceConfiguration: { + Text: { + MaxTokens: 2000, + Temperature: 1, + TopP: 0.999, + }, + }, + Name: 'variantChat', + TemplateConfiguration: { + Chat: { + InputVariables: [ + { + Name: 'language', + }, + ], + Messages: [ + { + Content: [ + { + Text: 'From now on, you speak Japanese!', + }, + ], + Role: 'user', + }, + { + Content: [ + { + Text: 'Konnichiwa!', + }, + ], + Role: 'assistant', + }, + { + Content: [ + { + Text: 'From now on, you speak {{language}}!', + }, + ], + Role: 'user', + }, + ], + System: [ + { + Text: 'You are a helpful assistant that only speaks the language you`re told.', + }, + ], + ToolConfiguration: { + ToolChoice: { + Auto: {}, + }, + Tools: [ + { + ToolSpec: { + Description: 'Get the most popular song played on a radio station.', + InputSchema: { + Json: { + type: 'object', + properties: { + sign: { + type: 'string', + description: + 'The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR.', + }, + }, + required: ['sign'], + }, + }, + Name: 'top_song', + }, + }, + ], + }, + }, + }, + TemplateType: 'CHAT', + }, + ], + }), + ); + }); + test('creates a Prompt with one variant - CRIS', () => { // GIVEN const cris = CrossRegionInferenceProfile.fromConfig({ @@ -245,7 +391,7 @@ describe('Prompt', () => { // -------------------------------------------------------------------------- test('throws on invalid prompt variant number', () => { //GIVEN - const variants = [1, 2, 3, 4].map((id) => + const variants = [1, 2, 3, 4].map(id => PromptVariant.text({ variantName: `variant${id}`, model: BedrockFoundationModel.fromCdkFoundationModelId( diff --git a/test/integ/chatprompt.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json b/test/integ/chatprompt.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json new file mode 100644 index 00000000..79bdb016 --- /dev/null +++ b/test/integ/chatprompt.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "ServiceTestDefaultTestDeployAssertE49B1ECE.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/test/integ/chatprompt.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.template.json b/test/integ/chatprompt.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.template.json new file mode 100644 index 00000000..ad9d0fb7 --- /dev/null +++ b/test/integ/chatprompt.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/test/integ/chatprompt.integ.snapshot/aws-cdk-bedrock-chat-prompts-integ-test.assets.json b/test/integ/chatprompt.integ.snapshot/aws-cdk-bedrock-chat-prompts-integ-test.assets.json new file mode 100644 index 00000000..bd445007 --- /dev/null +++ b/test/integ/chatprompt.integ.snapshot/aws-cdk-bedrock-chat-prompts-integ-test.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "751d9794e310a8381601a052b2743bed074e67856b55e6a04bcd73280b8f5284": { + "source": { + "path": "aws-cdk-bedrock-chat-prompts-integ-test.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "751d9794e310a8381601a052b2743bed074e67856b55e6a04bcd73280b8f5284.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/test/integ/chatprompt.integ.snapshot/aws-cdk-bedrock-chat-prompts-integ-test.template.json b/test/integ/chatprompt.integ.snapshot/aws-cdk-bedrock-chat-prompts-integ-test.template.json new file mode 100644 index 00000000..38aec3d0 --- /dev/null +++ b/test/integ/chatprompt.integ.snapshot/aws-cdk-bedrock-chat-prompts-integ-test.template.json @@ -0,0 +1,223 @@ +{ + "Resources": { + "cmk01DE03DA": { + "Type": "AWS::KMS::Key", + "Properties": { + "KeyPolicy": { + "Statement": [ + { + "Action": "kms:*", + "Effect": "Allow", + "Principal": { + "AWS": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::", + { + "Ref": "AWS::AccountId" + }, + ":root" + ] + ] + } + }, + "Resource": "*" + } + ], + "Version": "2012-10-17" + } + }, + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "prompt1Prompt7E73129C": { + "Type": "AWS::Bedrock::Prompt", + "Properties": { + "CustomerEncryptionKeyArn": { + "Fn::GetAtt": [ + "cmk01DE03DA", + "Arn" + ] + }, + "DefaultVariant": "variant1", + "Description": "my first chat prompt", + "Name": "prompt-chat", + "Variants": [ + { + "InferenceConfiguration": { + "Text": {} + }, + "ModelId": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":bedrock:", + { + "Ref": "AWS::Region" + }, + "::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0" + ] + ] + }, + "Name": "variant1", + "TemplateConfiguration": { + "Chat": { + "InputVariables": [ + { + "Name": "language" + } + ], + "Messages": [ + { + "Content": [ + { + "Text": "From now on, you speak Japanese!" + } + ], + "Role": "user" + }, + { + "Content": [ + { + "Text": "Konnichiwa!" + } + ], + "Role": "assistant" + }, + { + "Content": [ + { + "Text": "From now on, you speak {{language}}!" + } + ], + "Role": "user" + } + ], + "System": [ + { + "Text": "You are a helpful assistant that only speaks the language you`re told." + } + ], + "ToolConfiguration": { + "ToolChoice": { + "Auto": {} + }, + "Tools": [ + { + "ToolSpec": { + "Description": "Get the most popular song played on a radio station.", + "InputSchema": { + "Json": { + "type": "object", + "properties": { + "sign": { + "type": "string", + "description": "The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR." + } + }, + "required": [ + "sign" + ] + } + }, + "Name": "top_song" + } + } + ] + } + } + }, + "TemplateType": "CHAT" + } + ] + } + }, + "prompt2PromptEEA87227": { + "Type": "AWS::Bedrock::Prompt", + "Properties": { + "CustomerEncryptionKeyArn": { + "Fn::GetAtt": [ + "cmk01DE03DA", + "Arn" + ] + }, + "DefaultVariant": "variant1", + "Description": "my first text prompt", + "Name": "prompt-text", + "Variants": [ + { + "InferenceConfiguration": { + "Text": {} + }, + "ModelId": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":bedrock:", + { + "Ref": "AWS::Region" + }, + "::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0" + ] + ] + }, + "Name": "variant1", + "TemplateConfiguration": { + "Text": { + "Text": "Hey" + } + }, + "TemplateType": "TEXT" + } + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/test/integ/chatprompt.integ.snapshot/integ.json b/test/integ/chatprompt.integ.snapshot/integ.json new file mode 100644 index 00000000..aa48cbac --- /dev/null +++ b/test/integ/chatprompt.integ.snapshot/integ.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "testCases": { + "ServiceTest/DefaultTest": { + "stacks": [ + "aws-cdk-bedrock-chat-prompts-integ-test" + ], + "cdkCommandOptions": { + "destroy": { + "args": { + "force": true + } + } + }, + "assertionStack": "ServiceTest/DefaultTest/DeployAssert", + "assertionStackName": "ServiceTestDefaultTestDeployAssertE49B1ECE" + } + } +} \ No newline at end of file diff --git a/test/integ/chatprompt.integ.ts b/test/integ/chatprompt.integ.ts new file mode 100644 index 00000000..37eabcb4 --- /dev/null +++ b/test/integ/chatprompt.integ.ts @@ -0,0 +1,93 @@ +/** + * 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. + */ +import * as integ from '@aws-cdk/integ-tests-alpha'; +import * as cdk from 'aws-cdk-lib'; + +import * as kms from 'aws-cdk-lib/aws-kms'; +import { PromptVariant, Prompt, BedrockFoundationModel, ChatMessage, ToolChoice } from '../../src/cdk-lib/bedrock'; +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'aws-cdk-bedrock-chat-prompts-integ-test'); + +const cmk = new kms.Key(stack, 'cmk', {}); + +const variantChat = PromptVariant.chat({ + variantName: 'variant1', + model: BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0, + messages: [ + ChatMessage.user('From now on, you speak Japanese!'), + ChatMessage.assistant('Konnichiwa!'), + ChatMessage.user('From now on, you speak {{language}}!'), + ], + system: 'You are a helpful assistant that only speaks the language you`re told.', + promptVariables: ['language'], + toolConfiguration: { + toolChoice: ToolChoice.AUTO, + tools: [ + { + toolSpec: { + name: 'top_song', + description: 'Get the most popular song played on a radio station.', + inputSchema: { + json: { + type: 'object', + properties: { + sign: { + type: 'string', + description: + 'The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR.', + }, + }, + required: ['sign'], + }, + }, + }, + }, + ], + }, +}); + +new Prompt(stack, 'prompt1', { + promptName: 'prompt-chat', + description: 'my first chat prompt', + defaultVariant: variantChat, + variants: [variantChat], + kmsKey: cmk, +}); + +const variantText = PromptVariant.text({ + variantName: 'variant1', + model: BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0, + promptText: 'Hey', +}); + +new Prompt(stack, 'prompt2', { + promptName: 'prompt-text', + description: 'my first text prompt', + defaultVariant: variantText, + variants: [variantText], + kmsKey: cmk, +}); + +// const integ_case = +new integ.IntegTest(app, 'ServiceTest', { + testCases: [stack], + cdkCommandOptions: { + destroy: { + args: { + force: true, + }, + }, + }, +}); + +app.synth(); diff --git a/test/integ/inference-profiles.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json b/test/integ/inference-profiles.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json index 4adbb7de..79bdb016 100644 --- a/test/integ/inference-profiles.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json +++ b/test/integ/inference-profiles.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/test/integ/inference-profiles.integ.snapshot/aws-cdk-bedrock-guardrails-integ-test.assets.json b/test/integ/inference-profiles.integ.snapshot/aws-cdk-bedrock-guardrails-integ-test.assets.json index d9732249..748303f4 100644 --- a/test/integ/inference-profiles.integ.snapshot/aws-cdk-bedrock-guardrails-integ-test.assets.json +++ b/test/integ/inference-profiles.integ.snapshot/aws-cdk-bedrock-guardrails-integ-test.assets.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "files": { "91dac6b16ba4df2701f08f5f6d386e6409d930f45d5e0c62fdcaad8a37cc69b0": { "source": { diff --git a/test/integ/inference-profiles.integ.snapshot/integ.json b/test/integ/inference-profiles.integ.snapshot/integ.json index 48d7dfb3..85db2a8b 100644 --- a/test/integ/inference-profiles.integ.snapshot/integ.json +++ b/test/integ/inference-profiles.integ.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "testCases": { "ServiceTest/DefaultTest": { "stacks": [ diff --git a/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json b/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json index 4adbb7de..79bdb016 100644 --- a/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json +++ b/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/aws-cdk-aoss-dashboard-integ-test.assets.json b/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/aws-cdk-aoss-dashboard-integ-test.assets.json index b1b45db2..80876ab4 100644 --- a/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/aws-cdk-aoss-dashboard-integ-test.assets.json +++ b/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/aws-cdk-aoss-dashboard-integ-test.assets.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "files": { "181da6986985d46e23b14751019080abbf03bbc0a08672bc1215ed7b0913386c": { "source": { diff --git a/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/integ.json b/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/integ.json index bddbe2d0..18a0a264 100644 --- a/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/integ.json +++ b/test/patterns/gen-ai/aws-aoss-cw-dashboard/integ-tests/aws-aoss-cw-dashboard.integ.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "testCases": { "ServiceTest/DefaultTest": { "stacks": [ diff --git a/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json b/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json index 4adbb7de..79bdb016 100644 --- a/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json +++ b/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/ServiceTestDefaultTestDeployAssertE49B1ECE.assets.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/aws-llama-index-data-loader-integ-test.assets.json b/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/aws-llama-index-data-loader-integ-test.assets.json index 6f82b4a2..f3cd84dc 100644 --- a/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/aws-llama-index-data-loader-integ-test.assets.json +++ b/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/aws-llama-index-data-loader-integ-test.assets.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "files": { "faa95a81ae7d7373f3e1f242268f904eb748d8d0fdd306e8a6fe515a1905a7d6": { "source": { diff --git a/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/integ.json b/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/integ.json index 2d280671..ad4023b7 100644 --- a/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/integ.json +++ b/test/patterns/gen-ai/aws-llama-index-data-loader/integ-tests/aws-llama-index-data-loader.integ.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "38.0.1", + "version": "39.0.0", "testCases": { "ServiceTest/DefaultTest": { "stacks": [ diff --git a/yarn.lock b/yarn.lock index cfccfb93..135ee2d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -40,10 +40,10 @@ fs-extra "^9.1.0" md5 "^2.3.0" -"@aws-cdk/cloud-assembly-schema@^38.0.1": - version "38.0.1" - resolved "https://registry.yarnpkg.com/@aws-cdk/cloud-assembly-schema/-/cloud-assembly-schema-38.0.1.tgz#cdf4684ae8778459e039cd44082ea644a3504ca9" - integrity sha512-KvPe+NMWAulfNVwY7jenFhzhuLhLqJ/OPy5jx7wUstbjnYnjRVLpUHPU3yCjXFE0J8cuJVdx95BJ4rOs66Pi9w== +"@aws-cdk/cloud-assembly-schema@^39.0.1": + version "39.1.38" + resolved "https://registry.yarnpkg.com/@aws-cdk/cloud-assembly-schema/-/cloud-assembly-schema-39.1.38.tgz#7232f922e91e34f1225b5b41d318b77eed377fd0" + integrity sha512-T5nc7+y3pmfXD/LNft1mA8E8Q6IdsE0mta5nC1FZu5sQd+LUo9xGd0BwdzJpR54cgTW/bNcIs5ARoc6kWoRJaA== dependencies: jsonschema "^1.4.1" semver "^7.6.3" @@ -60,10 +60,10 @@ string-width "^4.2.3" table "^6.8.1" -"@aws-cdk/integ-tests-alpha@2.166.0-alpha.0": - version "2.166.0-alpha.0" - resolved "https://registry.yarnpkg.com/@aws-cdk/integ-tests-alpha/-/integ-tests-alpha-2.166.0-alpha.0.tgz#fc82a90c422cd0ff90ee4b3f72026b6eb900cd1b" - integrity sha512-ksM64XQP0FzzGxmVFQQDF8JIJKJpcfUoFWTvRghDMDNq8IBi/KsP4/gXpHDyl4jtS58EPOMBpsy0SRCFyOCVvw== +"@aws-cdk/integ-tests-alpha@2.174.0-alpha.0": + version "2.174.0-alpha.0" + resolved "https://registry.yarnpkg.com/@aws-cdk/integ-tests-alpha/-/integ-tests-alpha-2.174.0-alpha.0.tgz#9c55e4dc9c09ced3bf4a61573bab05a2b8caaaff" + integrity sha512-+Z0qNhVl41PL0ZJJB8lO3+Fxe6yQ2gsjS0IarsRx8WOWYdRypsjXQx+/mUwVC7nwC9+dKYrfBj7RcP9GvI4z4A== "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0", "@babel/code-frame@^7.26.2": version "7.26.2" @@ -1408,15 +1408,15 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" -aws-cdk-lib@2.166.0: - version "2.166.0" - resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.166.0.tgz#279343451cc9391d52d77121e2a3feb2c756e3be" - integrity sha512-FAsIz/CpczbMrcShgvTWNp3kcGN6IDojJWNLqHioTRsTekcyN3OPmKvQJXUNWL0fnhTd8biFXC2esg6kM19xZw== +aws-cdk-lib@2.174.0: + version "2.174.0" + resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.174.0.tgz#d43ad7ed927ba9c4badff1c141b1583baca19f9f" + integrity sha512-OHBJcsg0i4KftWVeUzw1AkG7onZWNNM/DH7NQnbDOs0Ap716VvtcTUubUpeFrazDWe9Opfn1essTjv6gaVyHBw== dependencies: "@aws-cdk/asset-awscli-v1" "^2.2.208" "@aws-cdk/asset-kubectl-v20" "^2.1.3" "@aws-cdk/asset-node-proxy-agent-v6" "^2.1.0" - "@aws-cdk/cloud-assembly-schema" "^38.0.1" + "@aws-cdk/cloud-assembly-schema" "^39.0.1" "@balena/dockerignore" "^1.0.2" case "1.6.3" fs-extra "^11.2.0"