diff --git a/apidocs/namespaces/bedrock/README.md b/apidocs/namespaces/bedrock/README.md index 949695f7..8750597c 100644 --- a/apidocs/namespaces/bedrock/README.md +++ b/apidocs/namespaces/bedrock/README.md @@ -8,22 +8,27 @@ ## Index +### Namespaces + +- [GuardrailSampleTopics](namespaces/GuardrailSampleTopics/README.md) +- [PIIType](namespaces/PIIType/README.md) + ### Enumerations -- [CanadaSpecific](enumerations/CanadaSpecific.md) - [ConfluenceDataSourceAuthType](enumerations/ConfluenceDataSourceAuthType.md) - [ConfluenceObjectType](enumerations/ConfluenceObjectType.md) +- [ContentFilterStrength](enumerations/ContentFilterStrength.md) +- [ContentFilterType](enumerations/ContentFilterType.md) - [ContextualGroundingFilterConfigType](enumerations/ContextualGroundingFilterConfigType.md) +- [ContextualGroundingFilterType](enumerations/ContextualGroundingFilterType.md) - [CrawlingScope](enumerations/CrawlingScope.md) - [DataDeletionPolicy](enumerations/DataDeletionPolicy.md) - [DataSourceType](enumerations/DataSourceType.md) - [FiltersConfigStrength](enumerations/FiltersConfigStrength.md) - [FiltersConfigType](enumerations/FiltersConfigType.md) -- [Finance](enumerations/Finance.md) -- [General](enumerations/General.md) -- [InformationTechnology](enumerations/InformationTechnology.md) +- [GuardrailAction](enumerations/GuardrailAction.md) +- [ManagedWordFilterType](enumerations/ManagedWordFilterType.md) - [ParserMode](enumerations/ParserMode.md) -- [PiiEntitiesConfigAction](enumerations/PiiEntitiesConfigAction.md) - [PromptCreationMode](enumerations/PromptCreationMode.md) - [PromptState](enumerations/PromptState.md) - [PromptTemplateType](enumerations/PromptTemplateType.md) @@ -33,8 +38,6 @@ - [SharePointDataSourceAuthType](enumerations/SharePointDataSourceAuthType.md) - [SharePointObjectType](enumerations/SharePointObjectType.md) - [TransformationStep](enumerations/TransformationStep.md) -- [UKSpecific](enumerations/UKSpecific.md) -- [USASpecific](enumerations/USASpecific.md) ### Classes @@ -51,7 +54,7 @@ - [DataSourceBase](classes/DataSourceBase.md) - [DataSourceNew](classes/DataSourceNew.md) - [Guardrail](classes/Guardrail.md) -- [GuardrailVersion](classes/GuardrailVersion.md) +- [GuardrailBase](classes/GuardrailBase.md) - [InlineApiSchema](classes/InlineApiSchema.md) - [KnowledgeBase](classes/KnowledgeBase.md) - [ParsingStategy](classes/ParsingStategy.md) @@ -61,9 +64,7 @@ - [S3ApiSchema](classes/S3ApiSchema.md) - [S3DataSource](classes/S3DataSource.md) - [SalesforceDataSource](classes/SalesforceDataSource.md) -- [SensitiveInformationPolicyConfig](classes/SensitiveInformationPolicyConfig.md) - [SharePointDataSource](classes/SharePointDataSource.md) -- [Topic](classes/Topic.md) - [WebCrawlerDataSource](classes/WebCrawlerDataSource.md) ### Interfaces @@ -79,41 +80,49 @@ - [ConfluenceCrawlingFilters](interfaces/ConfluenceCrawlingFilters.md) - [ConfluenceDataSourceAssociationProps](interfaces/ConfluenceDataSourceAssociationProps.md) - [ConfluenceDataSourceProps](interfaces/ConfluenceDataSourceProps.md) +- [ContentFilter](interfaces/ContentFilter.md) - [ContentPolicyConfigProps](interfaces/ContentPolicyConfigProps.md) +- [ContextualGroundingFilter](interfaces/ContextualGroundingFilter.md) - [ContextualGroundingPolicyConfigProps](interfaces/ContextualGroundingPolicyConfigProps.md) - [CrawlingFilters](interfaces/CrawlingFilters.md) - [DataSourceAssociationProps](interfaces/DataSourceAssociationProps.md) +- [DeniedTopic](interfaces/DeniedTopic.md) - [FoundationModelParsingStategyProps](interfaces/FoundationModelParsingStategyProps.md) - [GuardrailConfiguration](interfaces/GuardrailConfiguration.md) - [GuardrailProps](interfaces/GuardrailProps.md) - [HierarchicalChunkingProps](interfaces/HierarchicalChunkingProps.md) - [IAgentAlias](interfaces/IAgentAlias.md) - [IDataSource](interfaces/IDataSource.md) +- [IGuardrail](interfaces/IGuardrail.md) - [IKnowledgeBase](interfaces/IKnowledgeBase.md) - [InferenceConfiguration](interfaces/InferenceConfiguration.md) - [IPrompt](interfaces/IPrompt.md) - [KnowledgeBaseAttributes](interfaces/KnowledgeBaseAttributes.md) - [KnowledgeBaseProps](interfaces/KnowledgeBaseProps.md) - [LambdaCustomTransformationProps](interfaces/LambdaCustomTransformationProps.md) +- [PIIFilter](interfaces/PIIFilter.md) - [PromptConfiguration](interfaces/PromptConfiguration.md) - [PromptOverrideConfiguration](interfaces/PromptOverrideConfiguration.md) - [PromptProps](interfaces/PromptProps.md) - [PromptVersionProps](interfaces/PromptVersionProps.md) +- [RegexFilter](interfaces/RegexFilter.md) - [S3DataSourceAssociationProps](interfaces/S3DataSourceAssociationProps.md) - [S3DataSourceProps](interfaces/S3DataSourceProps.md) - [S3Identifier](interfaces/S3Identifier.md) - [SalesforceCrawlingFilters](interfaces/SalesforceCrawlingFilters.md) - [SalesforceDataSourceAssociationProps](interfaces/SalesforceDataSourceAssociationProps.md) - [SalesforceDataSourceProps](interfaces/SalesforceDataSourceProps.md) -- [SensitiveInformationPolicyConfigProps](interfaces/SensitiveInformationPolicyConfigProps.md) - [SharePointCrawlingFilters](interfaces/SharePointCrawlingFilters.md) - [SharePointDataSourceAssociationProps](interfaces/SharePointDataSourceAssociationProps.md) - [SharePointDataSourceProps](interfaces/SharePointDataSourceProps.md) - [TextPromptVariantProps](interfaces/TextPromptVariantProps.md) -- [TopicProps](interfaces/TopicProps.md) - [WebCrawlerDataSourceAssociationProps](interfaces/WebCrawlerDataSourceAssociationProps.md) - [WebCrawlerDataSourceProps](interfaces/WebCrawlerDataSourceProps.md) +### Type Aliases + +- [WordFilter](type-aliases/WordFilter.md) + ### Functions - [validateInferenceConfiguration](functions/validateInferenceConfiguration.md) diff --git a/apidocs/namespaces/bedrock/classes/Guardrail.md b/apidocs/namespaces/bedrock/classes/Guardrail.md index a08f1ac2..cdd0b862 100644 --- a/apidocs/namespaces/bedrock/classes/Guardrail.md +++ b/apidocs/namespaces/bedrock/classes/Guardrail.md @@ -6,11 +6,11 @@ # Class: Guardrail -Deploy bedrock guardrail . +Class to create a Guardrail with CDK. ## Extends -- `Construct` +- [`GuardrailBase`](GuardrailBase.md) ## Constructors @@ -32,60 +32,121 @@ Deploy bedrock guardrail . #### Overrides -`Construct.constructor` +[`GuardrailBase`](GuardrailBase.md).[`constructor`](GuardrailBase.md#constructors) ## Properties -### guardrailId +### contentFilters -> `readonly` **guardrailId**: `string` +> `readonly` **contentFilters**: [`ContentFilter`](../interfaces/ContentFilter.md)[] -guardrail Id +The content filters applied by the guardrail. -#### Default +*** -```ts +### contextualGroundingFilters -``` +> `readonly` **contextualGroundingFilters**: [`ContextualGroundingFilter`](../interfaces/ContextualGroundingFilter.md)[] + +The contextual grounding filters applied by the guardrail. *** -### guardrailInstance +### deniedTopics + +> `readonly` **deniedTopics**: [`DeniedTopic`](../interfaces/DeniedTopic.md)[] + +The denied topic filters applied by the guardrail. + +*** + +### env + +> `readonly` **env**: `ResourceEnvironment` + +The environment this resource belongs to. +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`env`](GuardrailBase.md#env) -> `readonly` **guardrailInstance**: `CfnGuardrail` +*** + +### guardrailArn + +> `readonly` **guardrailArn**: `string` + +The ARN of the guardrail. + +#### Overrides + +[`GuardrailBase`](GuardrailBase.md).[`guardrailArn`](GuardrailBase.md#guardrailarn) + +*** + +### guardrailId + +> `readonly` **guardrailId**: `string` + +The ID of the guardrail. + +#### Overrides -Instance of guardrail +[`GuardrailBase`](GuardrailBase.md).[`guardrailId`](GuardrailBase.md#guardrailid) *** ### guardrailVersion -> `readonly` **guardrailVersion**: `string` +> **guardrailVersion**: `string` -guardrail version +The version of the guardrail. +By default, this value will always be `DRAFT` unless an explicit version is created. #### Default ```ts - +- "DRAFT" ``` *** -### kmsKeyArn +### hash + +> `readonly` **hash**: `string` + +The computed hash of the guardrail properties. + +*** + +### kmsKey? -> `readonly` **kmsKeyArn**: `string` +> `readonly` `optional` **kmsKey**: `IKey` -The ARN of the AWS KMS key used to encrypt the guardrail. +The KMS key used to encrypt data. #### Default ```ts - +undefined - "Data is encrypted by default with a key that AWS owns and manages for you" ``` *** +### managedWordListFilters + +> `readonly` **managedWordListFilters**: [`PROFANITY`](../enumerations/ManagedWordFilterType.md#profanity)[] + +The managed word list filters applied by the guardrail. + +*** + ### name > `readonly` **name**: `string` @@ -102,17 +163,97 @@ The tree node. #### Inherited from -`Construct.node` +[`GuardrailBase`](GuardrailBase.md).[`node`](GuardrailBase.md#node) + +*** + +### physicalName + +> `protected` `readonly` **physicalName**: `string` + +Returns a string-encoded token that resolves to the physical name that +should be passed to the CloudFormation resource. + +This value will resolve to one of the following: +- a concrete value (e.g. `"my-awesome-bucket"`) +- `undefined`, when a name should be generated by CloudFormation +- a concrete name generated automatically during synthesis, in + cross-environment scenarios. + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`physicalName`](GuardrailBase.md#physicalname) + +*** + +### piiFilters + +> `readonly` **piiFilters**: [`PIIFilter`](../interfaces/PIIFilter.md)[] + +The PII filters applied by the guardrail. + +*** + +### regexFilters + +> `readonly` **regexFilters**: [`RegexFilter`](../interfaces/RegexFilter.md)[] + +The regex filters applied by the guardrail. + +*** + +### stack + +> `readonly` **stack**: `Stack` + +The stack in which this resource is defined. + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`stack`](GuardrailBase.md#stack) + +*** + +### wordFilters + +> `readonly` **wordFilters**: `string`[] + +The word filters applied by the guardrail. ## Methods -### addContextualGroundingPolicyConfig() +### \_enableCrossEnvironment() + +> **\_enableCrossEnvironment**(): `void` + +**`Internal`** + +Called when this resource is referenced across environments +(account/region) to order to request that a physical name will be generated +for this resource during synthesis, so the resource can be referenced +through its absolute name/arn. + +#### Returns + +`void` + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`_enableCrossEnvironment`](GuardrailBase.md#_enablecrossenvironment) + +*** -> **addContextualGroundingPolicyConfig**(`props`): `void` +### addContentFilter() + +> **addContentFilter**(`filter`): `void` + +Adds a content filter to the guardrail. #### Parameters -• **props**: [`ContextualGroundingPolicyConfigProps`](../interfaces/ContextualGroundingPolicyConfigProps.md)[] +• **filter**: [`ContentFilter`](../interfaces/ContentFilter.md) + +The content filter to add. #### Returns @@ -120,15 +261,17 @@ The tree node. *** -### addSensitiveInformationPolicyConfig() +### addContextualGroundingFilter() + +> **addContextualGroundingFilter**(`filter`): `void` -> **addSensitiveInformationPolicyConfig**(`props`, `guardrailRegexesConfig`): `void` +Adds a contextual grounding filter to the guardrail. #### Parameters -• **props**: [`SensitiveInformationPolicyConfigProps`](../interfaces/SensitiveInformationPolicyConfigProps.md)[] +• **filter**: [`ContextualGroundingFilter`](../interfaces/ContextualGroundingFilter.md) -• **guardrailRegexesConfig**: `RegexConfigProperty` +The contextual grounding filter to add. #### Returns @@ -136,13 +279,35 @@ The tree node. *** -### addTags() +### addDeniedTopicFilter() -> **addTags**(`props`): `void` +> **addDeniedTopicFilter**(`filter`): `void` + +Adds a denied topic filter to the guardrail. #### Parameters -• **props**: [`GuardrailProps`](../interfaces/GuardrailProps.md) +• **filter**: [`DeniedTopic`](../interfaces/DeniedTopic.md) + +The denied topic filter to add. + +#### Returns + +`void` + +*** + +### addManagedWordListFilter() + +> **addManagedWordListFilter**(`filter`): `void` + +Adds a managed word list filter to the guardrail. + +#### Parameters + +• **filter**: [`PROFANITY`](../enumerations/ManagedWordFilterType.md#profanity) + +The managed word list filter to add. #### Returns @@ -150,13 +315,17 @@ The tree node. *** -### addTopicPolicyConfig() +### addPIIFilter() -> **addTopicPolicyConfig**(`topic`): `void` +> **addPIIFilter**(`filter`): `void` + +Adds a PII filter to the guardrail. #### Parameters -• **topic**: [`Topic`](Topic.md) +• **filter**: [`PIIFilter`](../interfaces/PIIFilter.md) + +The PII filter to add. #### Returns @@ -164,36 +333,184 @@ The tree node. *** -### addVersion() +### addRegexFilter() -> **addVersion**(`id`, `description`?): [`GuardrailVersion`](GuardrailVersion.md) +> **addRegexFilter**(`filter`): `void` -Creates a version of the guardrail. +Adds a regex filter to the guardrail. #### Parameters -• **id**: `string` +• **filter**: [`RegexFilter`](../interfaces/RegexFilter.md) -• **description?**: `string` +The regex filter to add. + +#### Returns + +`void` + +*** + +### addWordFilter() + +> **addWordFilter**(`filter`): `void` + +Adds a word filter to the guardrail. + +#### Parameters + +• **filter**: `string` + +The word filter to add. + +#### Returns + +`void` + +*** + +### addWordFilterFromFile() + +> **addWordFilterFromFile**(`filePath`): `void` + +Adds a word filter to the guardrail. + +#### Parameters + +• **filePath**: `string` + +The location of the word filter file. #### Returns -[`GuardrailVersion`](GuardrailVersion.md) +`void` *** -### addWordPolicyConfig() +### applyRemovalPolicy() + +> **applyRemovalPolicy**(`policy`): `void` -> **addWordPolicyConfig**(`wordsFilter`?): `void` +Apply the given removal policy to this resource + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). #### Parameters -• **wordsFilter?**: `WordConfigProperty`[] +• **policy**: `RemovalPolicy` #### Returns `void` +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`applyRemovalPolicy`](GuardrailBase.md#applyremovalpolicy) + +*** + +### createVersion() + +> **createVersion**(`description`?): `string` + +Create a version for the guardrail. + +#### Parameters + +• **description?**: `string` + +The description of the version. + +#### Returns + +`string` + +The guardrail version. + +*** + +### generatePhysicalName() + +> `protected` **generatePhysicalName**(): `string` + +#### Returns + +`string` + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`generatePhysicalName`](GuardrailBase.md#generatephysicalname) + +*** + +### getResourceArnAttribute() + +> `protected` **getResourceArnAttribute**(`arnAttr`, `arnComponents`): `string` + +Returns an environment-sensitive token that should be used for the +resource's "ARN" attribute (e.g. `bucket.bucketArn`). + +Normally, this token will resolve to `arnAttr`, but if the resource is +referenced across environments, `arnComponents` will be used to synthesize +a concrete ARN with the resource's physical name. Make sure to reference +`this.physicalName` in `arnComponents`. + +#### Parameters + +• **arnAttr**: `string` + +The CFN attribute which resolves to the ARN of the resource. +Commonly it will be called "Arn" (e.g. `resource.attrArn`), but sometimes +it's the CFN resource's `ref`. + +• **arnComponents**: `ArnComponents` + +The format of the ARN of this resource. You must +reference `this.physicalName` somewhere within the ARN in order for +cross-environment references to work. + +#### Returns + +`string` + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`getResourceArnAttribute`](GuardrailBase.md#getresourcearnattribute) + +*** + +### getResourceNameAttribute() + +> `protected` **getResourceNameAttribute**(`nameAttr`): `string` + +Returns an environment-sensitive token that should be used for the +resource's "name" attribute (e.g. `bucket.bucketName`). + +Normally, this token will resolve to `nameAttr`, but if the resource is +referenced across environments, it will be resolved to `this.physicalName`, +which will be a concrete name. + +#### Parameters + +• **nameAttr**: `string` + +The CFN attribute which resolves to the resource's name. +Commonly this is the resource's `ref`. + +#### Returns + +`string` + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`getResourceNameAttribute`](GuardrailBase.md#getresourcenameattribute) + *** ### toString() @@ -208,21 +525,47 @@ Returns a string representation of this construct. #### Inherited from -`Construct.toString` +[`GuardrailBase`](GuardrailBase.md).[`toString`](GuardrailBase.md#tostring) + +*** + +### fromGuardrailArn() + +> `static` **fromGuardrailArn**(`scope`, `id`, `guardrailArn`): [`IGuardrail`](../interfaces/IGuardrail.md) + +Import a guardrail given an ARN. + +#### Parameters + +• **scope**: `Construct` + +• **id**: `string` + +• **guardrailArn**: `string` + +#### Returns + +[`IGuardrail`](../interfaces/IGuardrail.md) *** -### uploadWordPolicyFromFile() +### fromGuardrailId() -> **uploadWordPolicyFromFile**(`filePath`): `Promise`\<`void`\> +> `static` **fromGuardrailId**(`scope`, `id`, `guardrailId`): [`IGuardrail`](../interfaces/IGuardrail.md) + +Import a guardrail given an ID. #### Parameters -• **filePath**: `string` +• **scope**: `Construct` + +• **id**: `string` + +• **guardrailId**: `string` #### Returns -`Promise`\<`void`\> +[`IGuardrail`](../interfaces/IGuardrail.md) *** @@ -260,4 +603,44 @@ true if `x` is an object created from a class which extends `Construct`. #### Inherited from -`Construct.isConstruct` +[`GuardrailBase`](GuardrailBase.md).[`isConstruct`](GuardrailBase.md#isconstruct) + +*** + +### isOwnedResource() + +> `static` **isOwnedResource**(`construct`): `boolean` + +Returns true if the construct was created by CDK, and false otherwise + +#### Parameters + +• **construct**: `IConstruct` + +#### Returns + +`boolean` + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`isOwnedResource`](GuardrailBase.md#isownedresource) + +*** + +### isResource() + +> `static` **isResource**(`construct`): `construct is Resource` + +Check whether the given construct is a Resource + +#### Parameters + +• **construct**: `IConstruct` + +#### Returns + +`construct is Resource` + +#### Inherited from + +[`GuardrailBase`](GuardrailBase.md).[`isResource`](GuardrailBase.md#isresource) diff --git a/apidocs/namespaces/bedrock/classes/GuardrailBase.md b/apidocs/namespaces/bedrock/classes/GuardrailBase.md new file mode 100644 index 00000000..dc20ea04 --- /dev/null +++ b/apidocs/namespaces/bedrock/classes/GuardrailBase.md @@ -0,0 +1,366 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / GuardrailBase + +# Class: `abstract` GuardrailBase + +Abstract base class for a Guardrail. +Contains methods and attributes valid for Guardrails either created with CDK or imported. + +## Extends + +- `Resource` + +## Extended by + +- [`Guardrail`](Guardrail.md) + +## Implements + +- [`IGuardrail`](../interfaces/IGuardrail.md) + +## Constructors + +### new GuardrailBase() + +> **new GuardrailBase**(`scope`, `id`, `props`?): [`GuardrailBase`](GuardrailBase.md) + +#### Parameters + +• **scope**: `Construct` + +• **id**: `string` + +• **props?**: `ResourceProps` + +#### Returns + +[`GuardrailBase`](GuardrailBase.md) + +#### Inherited from + +`Resource.constructor` + +## Properties + +### env + +> `readonly` **env**: `ResourceEnvironment` + +The environment this resource belongs to. +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +#### Implementation of + +[`IGuardrail`](../interfaces/IGuardrail.md).[`env`](../interfaces/IGuardrail.md#env) + +#### Inherited from + +`Resource.env` + +*** + +### guardrailArn + +> `abstract` `readonly` **guardrailArn**: `string` + +The ARN of the guardrail. + +#### Implementation of + +[`IGuardrail`](../interfaces/IGuardrail.md).[`guardrailArn`](../interfaces/IGuardrail.md#guardrailarn) + +*** + +### guardrailId + +> `abstract` `readonly` **guardrailId**: `string` + +The ID of the guardrail. + +#### Implementation of + +[`IGuardrail`](../interfaces/IGuardrail.md).[`guardrailId`](../interfaces/IGuardrail.md#guardrailid) + +*** + +### node + +> `readonly` **node**: `Node` + +The tree node. + +#### Implementation of + +[`IGuardrail`](../interfaces/IGuardrail.md).[`node`](../interfaces/IGuardrail.md#node) + +#### Inherited from + +`Resource.node` + +*** + +### physicalName + +> `protected` `readonly` **physicalName**: `string` + +Returns a string-encoded token that resolves to the physical name that +should be passed to the CloudFormation resource. + +This value will resolve to one of the following: +- a concrete value (e.g. `"my-awesome-bucket"`) +- `undefined`, when a name should be generated by CloudFormation +- a concrete name generated automatically during synthesis, in + cross-environment scenarios. + +#### Inherited from + +`Resource.physicalName` + +*** + +### stack + +> `readonly` **stack**: `Stack` + +The stack in which this resource is defined. + +#### Implementation of + +[`IGuardrail`](../interfaces/IGuardrail.md).[`stack`](../interfaces/IGuardrail.md#stack) + +#### Inherited from + +`Resource.stack` + +## Methods + +### \_enableCrossEnvironment() + +> **\_enableCrossEnvironment**(): `void` + +**`Internal`** + +Called when this resource is referenced across environments +(account/region) to order to request that a physical name will be generated +for this resource during synthesis, so the resource can be referenced +through its absolute name/arn. + +#### Returns + +`void` + +#### Inherited from + +`Resource._enableCrossEnvironment` + +*** + +### applyRemovalPolicy() + +> **applyRemovalPolicy**(`policy`): `void` + +Apply the given removal policy to this resource + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +#### Parameters + +• **policy**: `RemovalPolicy` + +#### Returns + +`void` + +#### Implementation of + +[`IGuardrail`](../interfaces/IGuardrail.md).[`applyRemovalPolicy`](../interfaces/IGuardrail.md#applyremovalpolicy) + +#### Inherited from + +`Resource.applyRemovalPolicy` + +*** + +### generatePhysicalName() + +> `protected` **generatePhysicalName**(): `string` + +#### Returns + +`string` + +#### Inherited from + +`Resource.generatePhysicalName` + +*** + +### getResourceArnAttribute() + +> `protected` **getResourceArnAttribute**(`arnAttr`, `arnComponents`): `string` + +Returns an environment-sensitive token that should be used for the +resource's "ARN" attribute (e.g. `bucket.bucketArn`). + +Normally, this token will resolve to `arnAttr`, but if the resource is +referenced across environments, `arnComponents` will be used to synthesize +a concrete ARN with the resource's physical name. Make sure to reference +`this.physicalName` in `arnComponents`. + +#### Parameters + +• **arnAttr**: `string` + +The CFN attribute which resolves to the ARN of the resource. +Commonly it will be called "Arn" (e.g. `resource.attrArn`), but sometimes +it's the CFN resource's `ref`. + +• **arnComponents**: `ArnComponents` + +The format of the ARN of this resource. You must +reference `this.physicalName` somewhere within the ARN in order for +cross-environment references to work. + +#### Returns + +`string` + +#### Inherited from + +`Resource.getResourceArnAttribute` + +*** + +### getResourceNameAttribute() + +> `protected` **getResourceNameAttribute**(`nameAttr`): `string` + +Returns an environment-sensitive token that should be used for the +resource's "name" attribute (e.g. `bucket.bucketName`). + +Normally, this token will resolve to `nameAttr`, but if the resource is +referenced across environments, it will be resolved to `this.physicalName`, +which will be a concrete name. + +#### Parameters + +• **nameAttr**: `string` + +The CFN attribute which resolves to the resource's name. +Commonly this is the resource's `ref`. + +#### Returns + +`string` + +#### Inherited from + +`Resource.getResourceNameAttribute` + +*** + +### toString() + +> **toString**(): `string` + +Returns a string representation of this construct. + +#### Returns + +`string` + +#### Inherited from + +`Resource.toString` + +*** + +### isConstruct() + +> `static` **isConstruct**(`x`): `x is Construct` + +Checks if `x` is a construct. + +Use this method instead of `instanceof` to properly detect `Construct` +instances, even when the construct library is symlinked. + +Explanation: in JavaScript, multiple copies of the `constructs` library on +disk are seen as independent, completely different libraries. As a +consequence, the class `Construct` in each copy of the `constructs` library +is seen as a different class, and an instance of one class will not test as +`instanceof` the other class. `npm install` will not create installations +like this, but users may manually symlink construct libraries together or +use a monorepo tool: in those cases, multiple copies of the `constructs` +library can be accidentally installed, and `instanceof` will behave +unpredictably. It is safest to avoid using `instanceof`, and using +this type-testing method instead. + +#### Parameters + +• **x**: `any` + +Any object + +#### Returns + +`x is Construct` + +true if `x` is an object created from a class which extends `Construct`. + +#### Inherited from + +`Resource.isConstruct` + +*** + +### isOwnedResource() + +> `static` **isOwnedResource**(`construct`): `boolean` + +Returns true if the construct was created by CDK, and false otherwise + +#### Parameters + +• **construct**: `IConstruct` + +#### Returns + +`boolean` + +#### Inherited from + +`Resource.isOwnedResource` + +*** + +### isResource() + +> `static` **isResource**(`construct`): `construct is Resource` + +Check whether the given construct is a Resource + +#### Parameters + +• **construct**: `IConstruct` + +#### Returns + +`construct is Resource` + +#### Inherited from + +`Resource.isResource` diff --git a/apidocs/namespaces/bedrock/classes/GuardrailVersion.md b/apidocs/namespaces/bedrock/classes/GuardrailVersion.md deleted file mode 100644 index e35e9dc2..00000000 --- a/apidocs/namespaces/bedrock/classes/GuardrailVersion.md +++ /dev/null @@ -1,112 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / GuardrailVersion - -# Class: GuardrailVersion - -Creates a version of the guardrail. - -Use this API to create a snapshot of the guardrail when you are satisfied with -a configuration, or to compare the configuration with another version. - -## Extends - -- `Construct` - -## Constructors - -### new GuardrailVersion() - -> **new GuardrailVersion**(`scope`, `id`, `props`): [`GuardrailVersion`](GuardrailVersion.md) - -#### Parameters - -• **scope**: `Construct` - -• **id**: `string` - -• **props**: `CfnGuardrailVersionProps` - -#### Returns - -[`GuardrailVersion`](GuardrailVersion.md) - -#### Overrides - -`Construct.constructor` - -## Properties - -### guardrailVersionInstance - -> `readonly` **guardrailVersionInstance**: `CfnGuardrailVersion` - -Instance of guardrail version - -*** - -### node - -> `readonly` **node**: `Node` - -The tree node. - -#### Inherited from - -`Construct.node` - -## Methods - -### toString() - -> **toString**(): `string` - -Returns a string representation of this construct. - -#### Returns - -`string` - -#### Inherited from - -`Construct.toString` - -*** - -### isConstruct() - -> `static` **isConstruct**(`x`): `x is Construct` - -Checks if `x` is a construct. - -Use this method instead of `instanceof` to properly detect `Construct` -instances, even when the construct library is symlinked. - -Explanation: in JavaScript, multiple copies of the `constructs` library on -disk are seen as independent, completely different libraries. As a -consequence, the class `Construct` in each copy of the `constructs` library -is seen as a different class, and an instance of one class will not test as -`instanceof` the other class. `npm install` will not create installations -like this, but users may manually symlink construct libraries together or -use a monorepo tool: in those cases, multiple copies of the `constructs` -library can be accidentally installed, and `instanceof` will behave -unpredictably. It is safest to avoid using `instanceof`, and using -this type-testing method instead. - -#### Parameters - -• **x**: `any` - -Any object - -#### Returns - -`x is Construct` - -true if `x` is an object created from a class which extends `Construct`. - -#### Inherited from - -`Construct.isConstruct` diff --git a/apidocs/namespaces/bedrock/classes/SensitiveInformationPolicyConfig.md b/apidocs/namespaces/bedrock/classes/SensitiveInformationPolicyConfig.md deleted file mode 100644 index 4cedfdeb..00000000 --- a/apidocs/namespaces/bedrock/classes/SensitiveInformationPolicyConfig.md +++ /dev/null @@ -1,105 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / SensitiveInformationPolicyConfig - -# Class: SensitiveInformationPolicyConfig - -## Extends - -- `Construct` - -## Constructors - -### new SensitiveInformationPolicyConfig() - -> **new SensitiveInformationPolicyConfig**(`scope`, `id`, `props`): [`SensitiveInformationPolicyConfig`](SensitiveInformationPolicyConfig.md) - -#### Parameters - -• **scope**: `Construct` - -• **id**: `string` - -• **props**: [`SensitiveInformationPolicyConfigProps`](../interfaces/SensitiveInformationPolicyConfigProps.md)[] - -#### Returns - -[`SensitiveInformationPolicyConfig`](SensitiveInformationPolicyConfig.md) - -#### Overrides - -`Construct.constructor` - -## Properties - -### node - -> `readonly` **node**: `Node` - -The tree node. - -#### Inherited from - -`Construct.node` - -*** - -### piiConfigList - -> `readonly` **piiConfigList**: `PiiEntityConfigProperty`[] = `[]` - -## Methods - -### toString() - -> **toString**(): `string` - -Returns a string representation of this construct. - -#### Returns - -`string` - -#### Inherited from - -`Construct.toString` - -*** - -### isConstruct() - -> `static` **isConstruct**(`x`): `x is Construct` - -Checks if `x` is a construct. - -Use this method instead of `instanceof` to properly detect `Construct` -instances, even when the construct library is symlinked. - -Explanation: in JavaScript, multiple copies of the `constructs` library on -disk are seen as independent, completely different libraries. As a -consequence, the class `Construct` in each copy of the `constructs` library -is seen as a different class, and an instance of one class will not test as -`instanceof` the other class. `npm install` will not create installations -like this, but users may manually symlink construct libraries together or -use a monorepo tool: in those cases, multiple copies of the `constructs` -library can be accidentally installed, and `instanceof` will behave -unpredictably. It is safest to avoid using `instanceof`, and using -this type-testing method instead. - -#### Parameters - -• **x**: `any` - -Any object - -#### Returns - -`x is Construct` - -true if `x` is an object created from a class which extends `Construct`. - -#### Inherited from - -`Construct.isConstruct` diff --git a/apidocs/namespaces/bedrock/classes/Topic.md b/apidocs/namespaces/bedrock/classes/Topic.md deleted file mode 100644 index 4d939b04..00000000 --- a/apidocs/namespaces/bedrock/classes/Topic.md +++ /dev/null @@ -1,191 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / Topic - -# Class: Topic - -## Extends - -- `Construct` - -## Constructors - -### new Topic() - -> **new Topic**(`scope`, `id`): [`Topic`](Topic.md) - -#### Parameters - -• **scope**: `Construct` - -• **id**: `string` - -#### Returns - -[`Topic`](Topic.md) - -#### Overrides - -`Construct.constructor` - -## Properties - -### node - -> `readonly` **node**: `Node` - -The tree node. - -#### Inherited from - -`Construct.node` - -## Methods - -### createTopic() - -> **createTopic**(`props`): `void` - -#### Parameters - -• **props**: [`TopicProps`](../interfaces/TopicProps.md) - -#### Returns - -`void` - -*** - -### financialAdviceTopic() - -> **financialAdviceTopic**(`props`?): `void` - -#### Parameters - -• **props?**: [`TopicProps`](../interfaces/TopicProps.md) - -#### Returns - -`void` - -*** - -### inappropriateContent() - -> **inappropriateContent**(`props`?): `void` - -#### Parameters - -• **props?**: [`TopicProps`](../interfaces/TopicProps.md) - -#### Returns - -`void` - -*** - -### legalAdvice() - -> **legalAdvice**(`props`?): `void` - -#### Parameters - -• **props?**: [`TopicProps`](../interfaces/TopicProps.md) - -#### Returns - -`void` - -*** - -### medicalAdvice() - -> **medicalAdvice**(`props`?): `void` - -#### Parameters - -• **props?**: [`TopicProps`](../interfaces/TopicProps.md) - -#### Returns - -`void` - -*** - -### politicalAdviceTopic() - -> **politicalAdviceTopic**(`props`?): `void` - -#### Parameters - -• **props?**: [`TopicProps`](../interfaces/TopicProps.md) - -#### Returns - -`void` - -*** - -### topicConfigPropertyList() - -> **topicConfigPropertyList**(): `TopicConfigProperty`[] - -#### Returns - -`TopicConfigProperty`[] - -*** - -### toString() - -> **toString**(): `string` - -Returns a string representation of this construct. - -#### Returns - -`string` - -#### Inherited from - -`Construct.toString` - -*** - -### isConstruct() - -> `static` **isConstruct**(`x`): `x is Construct` - -Checks if `x` is a construct. - -Use this method instead of `instanceof` to properly detect `Construct` -instances, even when the construct library is symlinked. - -Explanation: in JavaScript, multiple copies of the `constructs` library on -disk are seen as independent, completely different libraries. As a -consequence, the class `Construct` in each copy of the `constructs` library -is seen as a different class, and an instance of one class will not test as -`instanceof` the other class. `npm install` will not create installations -like this, but users may manually symlink construct libraries together or -use a monorepo tool: in those cases, multiple copies of the `constructs` -library can be accidentally installed, and `instanceof` will behave -unpredictably. It is safest to avoid using `instanceof`, and using -this type-testing method instead. - -#### Parameters - -• **x**: `any` - -Any object - -#### Returns - -`x is Construct` - -true if `x` is an object created from a class which extends `Construct`. - -#### Inherited from - -`Construct.isConstruct` diff --git a/apidocs/namespaces/bedrock/enumerations/CanadaSpecific.md b/apidocs/namespaces/bedrock/enumerations/CanadaSpecific.md deleted file mode 100644 index 709050af..00000000 --- a/apidocs/namespaces/bedrock/enumerations/CanadaSpecific.md +++ /dev/null @@ -1,19 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / CanadaSpecific - -# Enumeration: CanadaSpecific - -## Enumeration Members - -### CA\_HEALTH\_NUMBER - -> **CA\_HEALTH\_NUMBER**: `"CA_HEALTH_NUMBER"` - -*** - -### CA\_SOCIAL\_INSURANCE\_NUMBER - -> **CA\_SOCIAL\_INSURANCE\_NUMBER**: `"CA_SOCIAL_INSURANCE_NUMBER"` diff --git a/apidocs/namespaces/bedrock/enumerations/ContentFilterStrength.md b/apidocs/namespaces/bedrock/enumerations/ContentFilterStrength.md new file mode 100644 index 00000000..2f8c0cdd --- /dev/null +++ b/apidocs/namespaces/bedrock/enumerations/ContentFilterStrength.md @@ -0,0 +1,35 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ContentFilterStrength + +# Enumeration: ContentFilterStrength + +The strength of the content filter. As you increase the filter strength, +the likelihood of filtering harmful content increases and the probability +of seeing harmful content in your application reduces. + +## Enumeration Members + +### HIGH + +> **HIGH**: `"HIGH"` + +*** + +### LOW + +> **LOW**: `"LOW"` + +*** + +### MEDIUM + +> **MEDIUM**: `"MEDIUM"` + +*** + +### NONE + +> **NONE**: `"NONE"` diff --git a/apidocs/namespaces/bedrock/enumerations/ContentFilterType.md b/apidocs/namespaces/bedrock/enumerations/ContentFilterType.md new file mode 100644 index 00000000..3c11bd62 --- /dev/null +++ b/apidocs/namespaces/bedrock/enumerations/ContentFilterType.md @@ -0,0 +1,67 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ContentFilterType + +# Enumeration: ContentFilterType + +The type of harmful category usable in a content filter. + +## Enumeration Members + +### HATE + +> **HATE**: `"HATE"` + +Describes input prompts and model responses that discriminate, criticize, insult, +denounce, or dehumanize a person or group on the basis of an identity (such as race, +ethnicity, gender, religion, sexual orientation, ability, and national origin). + +*** + +### INSULTS + +> **INSULTS**: `"INSULTS"` + +Describes input prompts and model responses that includes demeaning, humiliating, +mocking, insulting, or belittling language. This type of language is also labeled +as bullying. + +*** + +### MISCONDUCT + +> **MISCONDUCT**: `"MISCONDUCT"` + +Describes input prompts and model responses that seeks or provides information +about engaging in misconduct activity, or harming, defrauding, or taking advantage +of a person, group or institution. + +*** + +### PROMPT\_ATTACK + +> **PROMPT\_ATTACK**: `"PROMPT_ATTACK"` + +Enable to detect and block user inputs attempting to override system instructions. +To avoid misclassifying system prompts as a prompt attack and ensure that the filters +are selectively applied to user inputs, use input tagging. + +*** + +### SEXUAL + +> **SEXUAL**: `"SEXUAL"` + +Describes input prompts and model responses that indicates sexual interest, activity, +or arousal using direct or indirect references to body parts, physical traits, or sex. + +*** + +### VIOLENCE + +> **VIOLENCE**: `"VIOLENCE"` + +Describes input prompts and model responses that includes glorification of or threats +to inflict physical pain, hurt, or injury toward a person, group or thing. diff --git a/apidocs/namespaces/bedrock/enumerations/ContextualGroundingFilterType.md b/apidocs/namespaces/bedrock/enumerations/ContextualGroundingFilterType.md new file mode 100644 index 00000000..3f3281bd --- /dev/null +++ b/apidocs/namespaces/bedrock/enumerations/ContextualGroundingFilterType.md @@ -0,0 +1,31 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ContextualGroundingFilterType + +# Enumeration: ContextualGroundingFilterType + +The type of contextual grounding filter. + +## Enumeration Members + +### GROUNDING + +> **GROUNDING**: `"GROUNDING"` + +Grounding score represents the confidence that the model response is factually +correct and grounded in the source. If the model response has a lower score than +the defined threshold, the response will be blocked and the configured blocked +message will be returned to the user. A higher threshold level blocks more responses. + +*** + +### RELEVANCE + +> **RELEVANCE**: `"RELEVANCE"` + +Relevance score represents the confidence that the model response is relevant +to the user's query. If the model response has a lower score than the defined +threshold, the response will be blocked and the configured blocked message will +be returned to the user. A higher threshold level blocks more responses. diff --git a/apidocs/namespaces/bedrock/enumerations/Finance.md b/apidocs/namespaces/bedrock/enumerations/Finance.md deleted file mode 100644 index 7dc03f62..00000000 --- a/apidocs/namespaces/bedrock/enumerations/Finance.md +++ /dev/null @@ -1,43 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / Finance - -# Enumeration: Finance - -## Enumeration Members - -### CREDIT\_DEBIT\_CARD\_CVV - -> **CREDIT\_DEBIT\_CARD\_CVV**: `"CREDIT_DEBIT_CARD_CVV"` - -*** - -### CREDIT\_DEBIT\_CARD\_EXPIRY - -> **CREDIT\_DEBIT\_CARD\_EXPIRY**: `"CREDIT_DEBIT_CARD_EXPIRY"` - -*** - -### CREDIT\_DEBIT\_CARD\_NUMBER - -> **CREDIT\_DEBIT\_CARD\_NUMBER**: `"CREDIT_DEBIT_CARD_NUMBER"` - -*** - -### INTERNATIONAL\_BANK\_ACCOUNT\_NUMBER - -> **INTERNATIONAL\_BANK\_ACCOUNT\_NUMBER**: `"INTERNATIONAL_BANK_ACCOUNT_NUMBER"` - -*** - -### PIN - -> **PIN**: `"PIN"` - -*** - -### SWIFT\_CODE - -> **SWIFT\_CODE**: `"SWIFT_CODE"` diff --git a/apidocs/namespaces/bedrock/enumerations/General.md b/apidocs/namespaces/bedrock/enumerations/General.md deleted file mode 100644 index 49f4e617..00000000 --- a/apidocs/namespaces/bedrock/enumerations/General.md +++ /dev/null @@ -1,67 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / General - -# Enumeration: General - -## Enumeration Members - -### ADDRESS - -> **ADDRESS**: `"ADDRESS"` - -*** - -### AGE - -> **AGE**: `"AGE"` - -*** - -### DRIVER\_ID - -> **DRIVER\_ID**: `"DRIVER_ID"` - -*** - -### EMAIL - -> **EMAIL**: `"EMAIL"` - -*** - -### LICENSE\_PLATE - -> **LICENSE\_PLATE**: `"LICENSE_PLATE"` - -*** - -### NAME - -> **NAME**: `"NAME"` - -*** - -### PASSWORD - -> **PASSWORD**: `"PASSWORD"` - -*** - -### PHONE - -> **PHONE**: `"PHONE"` - -*** - -### USERNAME - -> **USERNAME**: `"USERNAME"` - -*** - -### VEHICLE\_IDENTIFICATION\_NUMBER - -> **VEHICLE\_IDENTIFICATION\_NUMBER**: `"VEHICLE_IDENTIFICATION_NUMBER"` diff --git a/apidocs/namespaces/bedrock/enumerations/GuardrailAction.md b/apidocs/namespaces/bedrock/enumerations/GuardrailAction.md new file mode 100644 index 00000000..8fe5cd1b --- /dev/null +++ b/apidocs/namespaces/bedrock/enumerations/GuardrailAction.md @@ -0,0 +1,28 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / GuardrailAction + +# Enumeration: GuardrailAction + +Guardrail action when a sensitive entity is detected. + +## Enumeration Members + +### ANONYMIZE + +> **ANONYMIZE**: `"ANONYMIZE"` + +If sensitive information is detected in the model response, the guardrail masks +it with an identifier, the sensitive information is masked and replaced with +identifier tags (for example: [NAME-1], [NAME-2], [EMAIL-1], etc.). + +*** + +### BLOCK + +> **BLOCK**: `"BLOCK"` + +If sensitive information is detected in the prompt or response, the guardrail +blocks all the content and returns a message that you configure. diff --git a/apidocs/namespaces/bedrock/enumerations/InformationTechnology.md b/apidocs/namespaces/bedrock/enumerations/InformationTechnology.md deleted file mode 100644 index ff4c219e..00000000 --- a/apidocs/namespaces/bedrock/enumerations/InformationTechnology.md +++ /dev/null @@ -1,37 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / InformationTechnology - -# Enumeration: InformationTechnology - -## Enumeration Members - -### AWS\_ACCESS\_KEY - -> **AWS\_ACCESS\_KEY**: `"AWS_ACCESS_KEY"` - -*** - -### AWS\_SECRET\_KEY - -> **AWS\_SECRET\_KEY**: `"AWS_SECRET_KEY"` - -*** - -### IP\_ADDRESS - -> **IP\_ADDRESS**: `"IP_ADDRESS"` - -*** - -### MAC\_ADDRESS - -> **MAC\_ADDRESS**: `"MAC_ADDRESS"` - -*** - -### URL - -> **URL**: `"URL"` diff --git a/apidocs/namespaces/bedrock/enumerations/ManagedWordFilterType.md b/apidocs/namespaces/bedrock/enumerations/ManagedWordFilterType.md new file mode 100644 index 00000000..722af265 --- /dev/null +++ b/apidocs/namespaces/bedrock/enumerations/ManagedWordFilterType.md @@ -0,0 +1,15 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ManagedWordFilterType + +# Enumeration: ManagedWordFilterType + +The managed word type filter available for guardrails. + +## Enumeration Members + +### PROFANITY + +> **PROFANITY**: `"PROFANITY"` diff --git a/apidocs/namespaces/bedrock/enumerations/PiiEntitiesConfigAction.md b/apidocs/namespaces/bedrock/enumerations/PiiEntitiesConfigAction.md deleted file mode 100644 index 0f37146a..00000000 --- a/apidocs/namespaces/bedrock/enumerations/PiiEntitiesConfigAction.md +++ /dev/null @@ -1,19 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / PiiEntitiesConfigAction - -# Enumeration: PiiEntitiesConfigAction - -## Enumeration Members - -### ANONYMIZE - -> **ANONYMIZE**: `"ANONYMIZE"` - -*** - -### BLOCK - -> **BLOCK**: `"BLOCK"` diff --git a/apidocs/namespaces/bedrock/enumerations/UKSpecific.md b/apidocs/namespaces/bedrock/enumerations/UKSpecific.md deleted file mode 100644 index 9a98d330..00000000 --- a/apidocs/namespaces/bedrock/enumerations/UKSpecific.md +++ /dev/null @@ -1,25 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / UKSpecific - -# Enumeration: UKSpecific - -## Enumeration Members - -### UK\_NATIONAL\_HEALTH\_SERVICE\_NUMBER - -> **UK\_NATIONAL\_HEALTH\_SERVICE\_NUMBER**: `"UK_NATIONAL_HEALTH_SERVICE_NUMBER"` - -*** - -### UK\_NATIONAL\_INSURANCE\_NUMBER - -> **UK\_NATIONAL\_INSURANCE\_NUMBER**: `"UK_NATIONAL_INSURANCE_NUMBER"` - -*** - -### UK\_UNIQUE\_TAXPAYER\_REFERENCE\_NUMBER - -> **UK\_UNIQUE\_TAXPAYER\_REFERENCE\_NUMBER**: `"UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER"` diff --git a/apidocs/namespaces/bedrock/enumerations/USASpecific.md b/apidocs/namespaces/bedrock/enumerations/USASpecific.md deleted file mode 100644 index 065b1537..00000000 --- a/apidocs/namespaces/bedrock/enumerations/USASpecific.md +++ /dev/null @@ -1,37 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / USASpecific - -# Enumeration: USASpecific - -## Enumeration Members - -### US\_BANK\_ACCOUNT\_NUMBER - -> **US\_BANK\_ACCOUNT\_NUMBER**: `"US_BANK_ACCOUNT_NUMBER"` - -*** - -### US\_BANK\_ROUTING\_NUMBER - -> **US\_BANK\_ROUTING\_NUMBER**: `"US_BANK_ROUTING_NUMBER"` - -*** - -### US\_INDIVIDUAL\_TAX\_IDENTIFICATION\_NUMBER - -> **US\_INDIVIDUAL\_TAX\_IDENTIFICATION\_NUMBER**: `"US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER"` - -*** - -### US\_PASSPORT\_NUMBER - -> **US\_PASSPORT\_NUMBER**: `"US_PASSPORT_NUMBER"` - -*** - -### US\_SOCIAL\_SECURITY\_NUMBER - -> **US\_SOCIAL\_SECURITY\_NUMBER**: `"US_SOCIAL_SECURITY_NUMBER"` diff --git a/apidocs/namespaces/bedrock/interfaces/ContentFilter.md b/apidocs/namespaces/bedrock/interfaces/ContentFilter.md new file mode 100644 index 00000000..7c9e7787 --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/ContentFilter.md @@ -0,0 +1,33 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ContentFilter + +# Interface: ContentFilter + +Interface to declare a content filter. + +## Properties + +### inputStrength + +> `readonly` **inputStrength**: [`ContentFilterStrength`](../enumerations/ContentFilterStrength.md) + +The strength of the content filter to apply to prompts / user input. + +*** + +### outputStrength + +> `readonly` **outputStrength**: [`ContentFilterStrength`](../enumerations/ContentFilterStrength.md) + +The strength of the content filter to apply to model responses. + +*** + +### type + +> `readonly` **type**: [`ContentFilterType`](../enumerations/ContentFilterType.md) + +The type of harmful category that the content filter is applied to diff --git a/apidocs/namespaces/bedrock/interfaces/ContextualGroundingFilter.md b/apidocs/namespaces/bedrock/interfaces/ContextualGroundingFilter.md new file mode 100644 index 00000000..b55a0ba2 --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/ContextualGroundingFilter.md @@ -0,0 +1,27 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / ContextualGroundingFilter + +# Interface: ContextualGroundingFilter + +Interface to define a Contextual Grounding Filter. + +## Properties + +### threshold + +> `readonly` **threshold**: `number` + +The threshold for the contextual grounding filter. +- `0` (blocks nothing) +- `0.99` (blocks almost everything) + +*** + +### type + +> `readonly` **type**: [`ContextualGroundingFilterType`](../enumerations/ContextualGroundingFilterType.md) + +The type of contextual grounding filter. diff --git a/apidocs/namespaces/bedrock/interfaces/DeniedTopic.md b/apidocs/namespaces/bedrock/interfaces/DeniedTopic.md new file mode 100644 index 00000000..4e41e0aa --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/DeniedTopic.md @@ -0,0 +1,50 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / DeniedTopic + +# Interface: DeniedTopic + +Defines a topic to deny. + +## Properties + +### definition + +> `readonly` **definition**: `string` + +Provide a clear definition to detect and block user inputs and FM responses +that fall into this topic. Avoid starting with "don't". + +#### Example + +```ts +`Investment advice refers to inquiries, guidance, or recommendations +regarding the management or allocation of funds or assets with the goal of +generating returns or achieving specific financial objectives.` +``` + +*** + +### examples? + +> `readonly` `optional` **examples**: `string`[] + +Representative phrases that refer to the topic. These phrases can represent +a user input or a model response. Add up to 5 phrases, up to 100 characters +each. + +#### Example + +```ts +"Where should I invest my money?" +``` + +*** + +### name + +> `readonly` **name**: `string` + +The name of the topic to deny. diff --git a/apidocs/namespaces/bedrock/interfaces/GuardrailProps.md b/apidocs/namespaces/bedrock/interfaces/GuardrailProps.md index bf949645..dd89fc2c 100644 --- a/apidocs/namespaces/bedrock/interfaces/GuardrailProps.md +++ b/apidocs/namespaces/bedrock/interfaces/GuardrailProps.md @@ -6,7 +6,7 @@ # Interface: GuardrailProps -Bedrock guardrail props +Properties for creating a Guardrail. ## Properties @@ -16,6 +16,12 @@ Bedrock guardrail props The message to return when the guardrail blocks a prompt. +#### Default + +```ts +"Sorry, your query violates our usage policy." +``` + *** ### blockedOutputsMessaging? @@ -24,13 +30,35 @@ The message to return when the guardrail blocks a prompt. The message to return when the guardrail blocks a model response. +#### Default + +```ts +"Sorry, I am unable to answer your question because of our usage policy." +``` + *** -### contextualGroundingfiltersConfig? +### contentFilters? -> `readonly` `optional` **contextualGroundingfiltersConfig**: [`ContextualGroundingPolicyConfigProps`](ContextualGroundingPolicyConfigProps.md)[] +> `readonly` `optional` **contentFilters**: [`ContentFilter`](ContentFilter.md)[] -Contextual grounding policy config for a guardrail. +The content filters to apply to the guardrail. + +*** + +### contextualGroundingFilters? + +> `readonly` `optional` **contextualGroundingFilters**: [`ContextualGroundingFilter`](ContextualGroundingFilter.md)[] + +The contextual grounding filters to apply to the guardrail. + +*** + +### deniedTopics? + +> `readonly` `optional` **deniedTopics**: [`DeniedTopic`](DeniedTopic.md)[] + +Up to 30 denied topics to block user inputs or model responses associated with the topic. *** @@ -42,40 +70,54 @@ The description of the guardrail. *** -### filtersConfig? +### kmsKey? + +> `readonly` `optional` **kmsKey**: `IKey` + +A custom KMS key to use for encrypting data. -> `readonly` `optional` **filtersConfig**: [`ContentPolicyConfigProps`](ContentPolicyConfigProps.md)[] +#### Default -List of content filter configs in content policy. +```ts +"Your data is encrypted by default with a key that AWS owns and manages for you." +``` *** -### kmsKeyArn? +### managedWordListFilters? -> `readonly` `optional` **kmsKeyArn**: `string` +> `readonly` `optional` **managedWordListFilters**: [`PROFANITY`](../enumerations/ManagedWordFilterType.md#profanity)[] -The ARN of the AWS KMS key used to encrypt the guardrail. +The managed word filters to apply to the guardrail. *** -### name? +### name -> `readonly` `optional` **name**: `string` +> `readonly` **name**: `string` The name of the guardrail. *** -### piiConfig? +### piiFilters? + +> `readonly` `optional` **piiFilters**: [`PIIFilter`](PIIFilter.md)[] + +The PII filters to apply to the guardrail. + +*** + +### regexFilters? -> `readonly` `optional` **piiConfig**: [`SensitiveInformationPolicyConfigProps`](SensitiveInformationPolicyConfigProps.md)[] +> `readonly` `optional` **regexFilters**: [`RegexFilter`](RegexFilter.md)[] -PII fields which needs to be anonymized. +The regular expression (regex) filters to apply to the guardrail. *** -### tags? +### wordFilters? -> `readonly` `optional` **tags**: `CfnTag`[] +> `readonly` `optional` **wordFilters**: `string`[] -Metadata that you can assign to a guardrail as key-value pairs +The word filters to apply to the guardrail. diff --git a/apidocs/namespaces/bedrock/interfaces/IGuardrail.md b/apidocs/namespaces/bedrock/interfaces/IGuardrail.md new file mode 100644 index 00000000..35fb3c3d --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/IGuardrail.md @@ -0,0 +1,111 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / IGuardrail + +# Interface: IGuardrail + +Represents a Guardrail, either created with CDK or imported. + +## Extends + +- `IResource` + +## Properties + +### env + +> `readonly` **env**: `ResourceEnvironment` + +The environment this resource belongs to. +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +#### Inherited from + +`IResource.env` + +*** + +### guardrailArn + +> `readonly` **guardrailArn**: `string` + +The ARN of the guardrail. + +#### Example + +```ts +"arn:aws:bedrock:us-east-1:123456789012:guardrail/yympzo398ipq" +``` + +*** + +### guardrailId + +> `readonly` **guardrailId**: `string` + +The ID of the guardrail. + +#### Example + +```ts +"yympzo398ipq" +``` + +*** + +### node + +> `readonly` **node**: `Node` + +The tree node. + +#### Inherited from + +`IResource.node` + +*** + +### stack + +> `readonly` **stack**: `Stack` + +The stack in which this resource is defined. + +#### Inherited from + +`IResource.stack` + +## Methods + +### applyRemovalPolicy() + +> **applyRemovalPolicy**(`policy`): `void` + +Apply the given removal policy to this resource + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +#### Parameters + +• **policy**: `RemovalPolicy` + +#### Returns + +`void` + +#### Inherited from + +`IResource.applyRemovalPolicy` diff --git a/apidocs/namespaces/bedrock/interfaces/PIIFilter.md b/apidocs/namespaces/bedrock/interfaces/PIIFilter.md new file mode 100644 index 00000000..44acc368 --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/PIIFilter.md @@ -0,0 +1,25 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / PIIFilter + +# Interface: PIIFilter + +Interface to define a PII Filter. + +## Properties + +### action + +> `readonly` **action**: [`GuardrailAction`](../enumerations/GuardrailAction.md) + +The action to take when PII is detected. + +*** + +### type + +> `readonly` **type**: [`General`](../namespaces/PIIType/enumerations/General.md) \| [`Finance`](../namespaces/PIIType/enumerations/Finance.md) \| [`InformationTechnology`](../namespaces/PIIType/enumerations/InformationTechnology.md) \| [`USASpecific`](../namespaces/PIIType/enumerations/USASpecific.md) \| [`CanadaSpecific`](../namespaces/PIIType/enumerations/CanadaSpecific.md) \| [`UKSpecific`](../namespaces/PIIType/enumerations/UKSpecific.md) + +The type of PII to filter. diff --git a/apidocs/namespaces/bedrock/interfaces/RegexFilter.md b/apidocs/namespaces/bedrock/interfaces/RegexFilter.md new file mode 100644 index 00000000..a0a54ef3 --- /dev/null +++ b/apidocs/namespaces/bedrock/interfaces/RegexFilter.md @@ -0,0 +1,51 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / RegexFilter + +# Interface: RegexFilter + +A Regular expression (regex) filter for sensitive information. + +## Example + +```ts +const regexFilter: RegexFilter = { + name: "my-custom-filter", + action: SensitiveInfoGuardrailAction.BLOCK, + pattern: "\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b", +}; +``` + +## Properties + +### action + +> `readonly` **action**: [`GuardrailAction`](../enumerations/GuardrailAction.md) + +The action to take when a regex match is detected. + +*** + +### description? + +> `readonly` `optional` **description**: `string` + +The description of the regex filter. + +*** + +### name + +> `readonly` **name**: `string` + +The name of the regex filter. + +*** + +### pattern + +> `readonly` **pattern**: `string` + +The regular expression pattern to match. diff --git a/apidocs/namespaces/bedrock/interfaces/SensitiveInformationPolicyConfigProps.md b/apidocs/namespaces/bedrock/interfaces/SensitiveInformationPolicyConfigProps.md deleted file mode 100644 index a664ebdd..00000000 --- a/apidocs/namespaces/bedrock/interfaces/SensitiveInformationPolicyConfigProps.md +++ /dev/null @@ -1,19 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / SensitiveInformationPolicyConfigProps - -# Interface: SensitiveInformationPolicyConfigProps - -## Properties - -### action - -> `readonly` **action**: [`PiiEntitiesConfigAction`](../enumerations/PiiEntitiesConfigAction.md) - -*** - -### type - -> `readonly` **type**: [`General`](../enumerations/General.md) \| [`InformationTechnology`](../enumerations/InformationTechnology.md) \| [`Finance`](../enumerations/Finance.md) \| [`USASpecific`](../enumerations/USASpecific.md) \| [`CanadaSpecific`](../enumerations/CanadaSpecific.md) \| [`UKSpecific`](../enumerations/UKSpecific.md) diff --git a/apidocs/namespaces/bedrock/interfaces/TopicProps.md b/apidocs/namespaces/bedrock/interfaces/TopicProps.md deleted file mode 100644 index 616a328a..00000000 --- a/apidocs/namespaces/bedrock/interfaces/TopicProps.md +++ /dev/null @@ -1,31 +0,0 @@ -[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** - -*** - -[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / TopicProps - -# Interface: TopicProps - -## Properties - -### definition? - -> `readonly` `optional` **definition**: `string` - -*** - -### examples? - -> `readonly` `optional` **examples**: `string`[] - -*** - -### name? - -> `readonly` `optional` **name**: `string` - -*** - -### type? - -> `readonly` `optional` **type**: `string` diff --git a/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/README.md b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/README.md new file mode 100644 index 00000000..8f031ecb --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/README.md @@ -0,0 +1,21 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../README.md) / [bedrock](../../README.md) / GuardrailSampleTopics + +# GuardrailSampleTopics + +*************************************************************************** + SAMPLE TOPICS +*************************************************************************** + +## Index + +### Variables + +- [FINANCIAL\_ADVICE](variables/FINANCIAL_ADVICE.md) +- [INNOPROPRIATE\_CONTENT](variables/INNOPROPRIATE_CONTENT.md) +- [LEGAL\_ADVICE](variables/LEGAL_ADVICE.md) +- [MEDICAL\_ADVICE](variables/MEDICAL_ADVICE.md) +- [POLITICAL\_ADVICE](variables/POLITICAL_ADVICE.md) diff --git a/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/FINANCIAL_ADVICE.md b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/FINANCIAL_ADVICE.md new file mode 100644 index 00000000..e881136d --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/FINANCIAL_ADVICE.md @@ -0,0 +1,9 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [GuardrailSampleTopics](../README.md) / FINANCIAL\_ADVICE + +# Variable: FINANCIAL\_ADVICE + +> `const` **FINANCIAL\_ADVICE**: [`DeniedTopic`](../../../interfaces/DeniedTopic.md) diff --git a/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/INNOPROPRIATE_CONTENT.md b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/INNOPROPRIATE_CONTENT.md new file mode 100644 index 00000000..f80fdaec --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/INNOPROPRIATE_CONTENT.md @@ -0,0 +1,9 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [GuardrailSampleTopics](../README.md) / INNOPROPRIATE\_CONTENT + +# Variable: INNOPROPRIATE\_CONTENT + +> `const` **INNOPROPRIATE\_CONTENT**: [`DeniedTopic`](../../../interfaces/DeniedTopic.md) diff --git a/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/LEGAL_ADVICE.md b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/LEGAL_ADVICE.md new file mode 100644 index 00000000..92ba30aa --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/LEGAL_ADVICE.md @@ -0,0 +1,9 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [GuardrailSampleTopics](../README.md) / LEGAL\_ADVICE + +# Variable: LEGAL\_ADVICE + +> `const` **LEGAL\_ADVICE**: [`DeniedTopic`](../../../interfaces/DeniedTopic.md) diff --git a/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/MEDICAL_ADVICE.md b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/MEDICAL_ADVICE.md new file mode 100644 index 00000000..784a7fe8 --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/MEDICAL_ADVICE.md @@ -0,0 +1,9 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [GuardrailSampleTopics](../README.md) / MEDICAL\_ADVICE + +# Variable: MEDICAL\_ADVICE + +> `const` **MEDICAL\_ADVICE**: [`DeniedTopic`](../../../interfaces/DeniedTopic.md) diff --git a/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/POLITICAL_ADVICE.md b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/POLITICAL_ADVICE.md new file mode 100644 index 00000000..903dd8ac --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/GuardrailSampleTopics/variables/POLITICAL_ADVICE.md @@ -0,0 +1,9 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [GuardrailSampleTopics](../README.md) / POLITICAL\_ADVICE + +# Variable: POLITICAL\_ADVICE + +> `const` **POLITICAL\_ADVICE**: [`DeniedTopic`](../../../interfaces/DeniedTopic.md) diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/README.md b/apidocs/namespaces/bedrock/namespaces/PIIType/README.md new file mode 100644 index 00000000..1cc23948 --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/README.md @@ -0,0 +1,22 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../README.md) / [bedrock](../../README.md) / PIIType + +# PIIType + +*************************************************************************** + SENSITIVE INFORMATION FILTERS - PII +*************************************************************************** + +## Index + +### Enumerations + +- [CanadaSpecific](enumerations/CanadaSpecific.md) +- [Finance](enumerations/Finance.md) +- [General](enumerations/General.md) +- [InformationTechnology](enumerations/InformationTechnology.md) +- [UKSpecific](enumerations/UKSpecific.md) +- [USASpecific](enumerations/USASpecific.md) diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/CanadaSpecific.md b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/CanadaSpecific.md new file mode 100644 index 00000000..1310088f --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/CanadaSpecific.md @@ -0,0 +1,27 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [PIIType](../README.md) / CanadaSpecific + +# Enumeration: CanadaSpecific + +Types of PII specific to Canada. + +## Enumeration Members + +### CA\_HEALTH\_NUMBER + +> **CA\_HEALTH\_NUMBER**: `"CA_HEALTH_NUMBER"` + +A Canadian Health Service Number is a 10-digit unique identifier, +required for individuals to access healthcare benefits. + +*** + +### CA\_SOCIAL\_INSURANCE\_NUMBER + +> **CA\_SOCIAL\_INSURANCE\_NUMBER**: `"CA_SOCIAL_INSURANCE_NUMBER"` + +A Canadian Social Insurance Number (SIN) is a nine-digit unique identifier, +required for individuals to access government programs and benefits. diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/Finance.md b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/Finance.md new file mode 100644 index 00000000..85e0ca7d --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/Finance.md @@ -0,0 +1,65 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [PIIType](../README.md) / Finance + +# Enumeration: Finance + +Types of PII in the domain of Finance. + +## Enumeration Members + +### CREDIT\_DEBIT\_CARD\_CVV + +> **CREDIT\_DEBIT\_CARD\_CVV**: `"CREDIT_DEBIT_CARD_CVV"` + +A three-digit card verification code (CVV) that is present on VISA, MasterCard, +and Discover credit and debit cards. For American Express credit or debit cards, +the CVV is a four-digit numeric code. + +*** + +### CREDIT\_DEBIT\_CARD\_EXPIRY + +> **CREDIT\_DEBIT\_CARD\_EXPIRY**: `"CREDIT_DEBIT_CARD_EXPIRY"` + +The expiration date for a credit or debit card. This number is usually four digits +long and is often formatted as month/year or MM/YY. Guardrails recognizes expiration +dates such as 01/21, 01/2021, and Jan 2021. + +*** + +### CREDIT\_DEBIT\_CARD\_NUMBER + +> **CREDIT\_DEBIT\_CARD\_NUMBER**: `"CREDIT_DEBIT_CARD_NUMBER"` + +The number for a credit or debit card. These numbers can vary from 13 to 16 digits +in length. + +*** + +### INTERNATIONAL\_BANK\_ACCOUNT\_NUMBER + +> **INTERNATIONAL\_BANK\_ACCOUNT\_NUMBER**: `"INTERNATIONAL_BANK_ACCOUNT_NUMBER"` + +An International Bank Account Number (IBAN). It has specific formats in each country. + +*** + +### PIN + +> **PIN**: `"PIN"` + +A four-digit personal identification number (PIN) with which you can access your +bank account. + +*** + +### SWIFT\_CODE + +> **SWIFT\_CODE**: `"SWIFT_CODE"` + +A SWIFT code is a standard format of Bank Identifier Code (BIC) used to specify a +particular bank or branch. Banks use these codes for money transfers such as +international wire transfers. SWIFT codes consist of eight or 11 characters. diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/General.md b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/General.md new file mode 100644 index 00000000..912886d4 --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/General.md @@ -0,0 +1,100 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [PIIType](../README.md) / General + +# Enumeration: General + +Types of PII that are general, and not domain-specific. + +## Enumeration Members + +### ADDRESS + +> **ADDRESS**: `"ADDRESS"` + +A physical address, such as "100 Main Street, Anytown, USA" or "Suite #12, +Building 123". An address can include information such as the street, building, +location, city, state, country, county, zip code, precinct, and neighborhood. + +*** + +### AGE + +> **AGE**: `"AGE"` + +An individual's age, including the quantity and unit of time. + +*** + +### DRIVER\_ID + +> **DRIVER\_ID**: `"DRIVER_ID"` + +The number assigned to a driver's license, which is an official document +permitting an individual to operate one or more motorized vehicles on a +public road. A driver's license number consists of alphanumeric characters. + +*** + +### EMAIL + +> **EMAIL**: `"EMAIL"` + +An email address, such as marymajor@email.com. + +*** + +### LICENSE\_PLATE + +> **LICENSE\_PLATE**: `"LICENSE_PLATE"` + +A license plate for a vehicle is issued by the state or country where the +vehicle is registered. The format for passenger vehicles is typically five +to eight digits, consisting of upper-case letters and numbers. The format +varies depending on the location of the issuing state or country. + +*** + +### NAME + +> **NAME**: `"NAME"` + +An individual's name. This entity type does not include titles, such as Dr., + Mr., Mrs., or Miss. + +*** + +### PASSWORD + +> **PASSWORD**: `"PASSWORD"` + +An alphanumeric string that is used as a password, such as "*very20special#pass*". + +*** + +### PHONE + +> **PHONE**: `"PHONE"` + +A phone number. This entity type also includes fax and pager numbers. + +*** + +### USERNAME + +> **USERNAME**: `"USERNAME"` + +A user name that identifies an account, such as a login name, screen name, +nick name, or handle. + +*** + +### VEHICLE\_IDENTIFICATION\_NUMBER + +> **VEHICLE\_IDENTIFICATION\_NUMBER**: `"VEHICLE_IDENTIFICATION_NUMBER"` + +A Vehicle Identification Number (VIN) uniquely identifies a vehicle. VIN +content and format are defined in the ISO 3779 specification. Each country +has specific codes and formats for VINs. diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/InformationTechnology.md b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/InformationTechnology.md new file mode 100644 index 00000000..d4f05d3d --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/InformationTechnology.md @@ -0,0 +1,53 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [PIIType](../README.md) / InformationTechnology + +# Enumeration: InformationTechnology + +Types of PII in the domain of IT (Information Technology). + +## Enumeration Members + +### AWS\_ACCESS\_KEY + +> **AWS\_ACCESS\_KEY**: `"AWS_ACCESS_KEY"` + +A unique identifier that's associated with a secret access key. You use +the access key ID and secret access key to sign programmatic AWS requests +cryptographically. + +*** + +### AWS\_SECRET\_KEY + +> **AWS\_SECRET\_KEY**: `"AWS_SECRET_KEY"` + +A unique identifier that's associated with a secret access key. You use +the access key ID and secret access key to sign programmatic AWS requests +cryptographically. + +*** + +### IP\_ADDRESS + +> **IP\_ADDRESS**: `"IP_ADDRESS"` + +An IPv4 address, such as 198.51.100.0. + +*** + +### MAC\_ADDRESS + +> **MAC\_ADDRESS**: `"MAC_ADDRESS"` + +A media access control (MAC) address assigned to a network interface. + +*** + +### URL + +> **URL**: `"URL"` + +A web address, such as www.example.com. diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/UKSpecific.md b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/UKSpecific.md new file mode 100644 index 00000000..36ab0f16 --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/UKSpecific.md @@ -0,0 +1,36 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [PIIType](../README.md) / UKSpecific + +# Enumeration: UKSpecific + +Types of PII specific to the United Kingdom (UK). + +## Enumeration Members + +### UK\_NATIONAL\_HEALTH\_SERVICE\_NUMBER + +> **UK\_NATIONAL\_HEALTH\_SERVICE\_NUMBER**: `"UK_NATIONAL_HEALTH_SERVICE_NUMBER"` + +A UK National Health Service Number is a 10-17 digit number, such as 485 777 3456. + +*** + +### UK\_NATIONAL\_INSURANCE\_NUMBER + +> **UK\_NATIONAL\_INSURANCE\_NUMBER**: `"UK_NATIONAL_INSURANCE_NUMBER"` + +A UK National Insurance Number (NINO) provides individuals with access to National +Insurance (social security) benefits. It is also used for some purposes in the UK +tax system. + +*** + +### UK\_UNIQUE\_TAXPAYER\_REFERENCE\_NUMBER + +> **UK\_UNIQUE\_TAXPAYER\_REFERENCE\_NUMBER**: `"UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER"` + +A UK Unique Taxpayer Reference (UTR) is a 10-digit number that identifies a +taxpayer or a business. diff --git a/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/USASpecific.md b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/USASpecific.md new file mode 100644 index 00000000..fc6eae58 --- /dev/null +++ b/apidocs/namespaces/bedrock/namespaces/PIIType/enumerations/USASpecific.md @@ -0,0 +1,51 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../../../README.md) / [bedrock](../../../README.md) / [PIIType](../README.md) / USASpecific + +# Enumeration: USASpecific + +Types of PII specific to the USA. + +## Enumeration Members + +### US\_BANK\_ACCOUNT\_NUMBER + +> **US\_BANK\_ACCOUNT\_NUMBER**: `"US_BANK_ACCOUNT_NUMBER"` + +A US bank account number, which is typically 10 to 12 digits long. + +*** + +### US\_BANK\_ROUTING\_NUMBER + +> **US\_BANK\_ROUTING\_NUMBER**: `"US_BANK_ROUTING_NUMBER"` + +A US bank account routing number. These are typically nine digits long. + +*** + +### US\_INDIVIDUAL\_TAX\_IDENTIFICATION\_NUMBER + +> **US\_INDIVIDUAL\_TAX\_IDENTIFICATION\_NUMBER**: `"US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER"` + +A US Individual Taxpayer Identification Number (ITIN) is a nine-digit number +that starts with a "9" and contain a "7" or "8" as the fourth digit. + +*** + +### US\_PASSPORT\_NUMBER + +> **US\_PASSPORT\_NUMBER**: `"US_PASSPORT_NUMBER"` + +A US passport number. Passport numbers range from six to nine alphanumeric characters. + +*** + +### US\_SOCIAL\_SECURITY\_NUMBER + +> **US\_SOCIAL\_SECURITY\_NUMBER**: `"US_SOCIAL_SECURITY_NUMBER"` + +A US Social Security Number (SSN) is a nine-digit number that is issued to US citizens, +permanent residents, and temporary working residents. diff --git a/apidocs/namespaces/bedrock/type-aliases/WordFilter.md b/apidocs/namespaces/bedrock/type-aliases/WordFilter.md new file mode 100644 index 00000000..6257f6a0 --- /dev/null +++ b/apidocs/namespaces/bedrock/type-aliases/WordFilter.md @@ -0,0 +1,9 @@ +[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md) • **Docs** + +*** + +[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / WordFilter + +# Type Alias: WordFilter + +> **WordFilter**: `string`[] \| [`ManagedWordFilterType`](../enumerations/ManagedWordFilterType.md)[] diff --git a/src/cdk-lib/bedrock/agent.ts b/src/cdk-lib/bedrock/agent.ts index a330701f..24268652 100644 --- a/src/cdk-lib/bedrock/agent.ts +++ b/src/cdk-lib/bedrock/agent.ts @@ -11,27 +11,27 @@ * and limitations under the License. */ -import * as cdk from "aws-cdk-lib"; -import { aws_bedrock as bedrock } from "aws-cdk-lib"; -import * as iam from "aws-cdk-lib/aws-iam"; -import * as kms from "aws-cdk-lib/aws-kms"; -import { Construct } from "constructs"; - -import { AgentActionGroup } from "./agent-action-group"; -import { AgentAlias } from "./agent-alias"; -import { Guardrail } from "./guardrails/guardrails"; -import { KnowledgeBase } from "./knowledge-base"; -import { BedrockFoundationModel } from "./models"; -import { generatePhysicalNameV2 } from "../../common/helpers/utils"; +import * as cdk from 'aws-cdk-lib'; +import { aws_bedrock as bedrock } from 'aws-cdk-lib'; +import * as iam from 'aws-cdk-lib/aws-iam'; +import * as kms from 'aws-cdk-lib/aws-kms'; +import { Construct } from 'constructs'; + +import { AgentActionGroup } from './agent-action-group'; +import { AgentAlias } from './agent-alias'; +import { Guardrail } from './guardrails/guardrails'; +import { KnowledgeBase } from './knowledge-base'; +import { BedrockFoundationModel } from './models'; +import { generatePhysicalNameV2 } from '../../common/helpers/utils'; /** * The step in the agent sequence that this prompt configuration applies to. */ export enum PromptType { - PRE_PROCESSING = "PRE_PROCESSING", - ORCHESTRATION = "ORCHESTRATION", - POST_PROCESSING = "POST_PROCESSING", - KNOWLEDGE_BASE_RESPONSE_GENERATION = "KNOWLEDGE_BASE_RESPONSE_GENERATION", + PRE_PROCESSING = 'PRE_PROCESSING', + ORCHESTRATION = 'ORCHESTRATION', + POST_PROCESSING = 'POST_PROCESSING', + KNOWLEDGE_BASE_RESPONSE_GENERATION = 'KNOWLEDGE_BASE_RESPONSE_GENERATION', } /** @@ -42,8 +42,8 @@ export enum PromptType { * with the ARN of a Lambda function. */ export enum ParserMode { - DEFAULT = "DEFAULT", - OVERRIDDEN = "OVERRIDDEN", + DEFAULT = 'DEFAULT', + OVERRIDDEN = 'OVERRIDDEN', } /** @@ -53,8 +53,8 @@ export enum ParserMode { * uses a default prompt template. */ export enum PromptCreationMode { - DEFAULT = "DEFAULT", - OVERRIDDEN = "OVERRIDDEN", + DEFAULT = 'DEFAULT', + OVERRIDDEN = 'OVERRIDDEN', } /** @@ -68,8 +68,8 @@ export enum PromptCreationMode { * POST_PROCESSING – DISABLED */ export enum PromptState { - ENABLED = "ENABLED", - DISABLED = "DISABLED", + ENABLED = 'ENABLED', + DISABLED = 'DISABLED', } /** Details about the guardrail associated with the agent. */ @@ -393,48 +393,48 @@ export class Agent extends Construct { validateModel(props.foundationModel); this.name = - props.name ?? generatePhysicalNameV2(this, "bedrock-agent", { maxLength: 32, lower: true, separator: "-" }); + props.name ?? generatePhysicalNameV2(this, 'bedrock-agent', { maxLength: 32, lower: true, separator: '-' }); if (props.existingRole) { this.role = props.existingRole; } else { - this.role = new iam.Role(this, "Role", { - assumedBy: new iam.ServicePrincipal("bedrock.amazonaws.com"), - roleName: generatePhysicalNameV2(this, "AmazonBedrockExecutionRoleForAgents_", { maxLength: 64, lower: false }), + this.role = new iam.Role(this, 'Role', { + assumedBy: new iam.ServicePrincipal('bedrock.amazonaws.com'), + roleName: generatePhysicalNameV2(this, 'AmazonBedrockExecutionRoleForAgents_', { maxLength: 64, lower: false }), }); this.role.assumeRolePolicy!.addStatements( new iam.PolicyStatement({ - actions: ["sts:AssumeRole"], - principals: [new iam.ServicePrincipal("bedrock.amazonaws.com")], + actions: ['sts:AssumeRole'], + principals: [new iam.ServicePrincipal('bedrock.amazonaws.com')], conditions: { StringEquals: { - "aws:SourceAccount": cdk.Stack.of(this).account, + 'aws:SourceAccount': cdk.Stack.of(this).account, }, ArnLike: { - "aws:SourceArn": cdk.Stack.of(this).formatArn({ - service: "bedrock", - resource: "agent", - resourceName: "*", + 'aws:SourceArn': cdk.Stack.of(this).formatArn({ + service: 'bedrock', + resource: 'agent', + resourceName: '*', arnFormat: cdk.ArnFormat.SLASH_RESOURCE_NAME, }), }, }, - }) + }), ); - new iam.Policy(this, "AgentFMPolicy", { + new iam.Policy(this, 'AgentFMPolicy', { roles: [this.role], statements: [ new iam.PolicyStatement({ - actions: ["bedrock:InvokeModel"], + actions: ['bedrock:InvokeModel'], resources: [props.foundationModel.asArn(this)], }), ], }); } - const agent = new bedrock.CfnAgent(this, "Agent", { + const agent = new bedrock.CfnAgent(this, 'Agent', { agentName: this.name, foundationModel: String(props.foundationModel), @@ -481,11 +481,11 @@ export class Agent extends Construct { // To allow your agent to request the user for additional information // when trying to complete a task, add this action group this.addActionGroup( - new AgentActionGroup(this, "userInputEnabledActionGroup", { - actionGroupName: "UserInputAction", - parentActionGroupSignature: "AMAZON.UserInput", - actionGroupState: props.enableUserInput ? "ENABLED" : "DISABLED", - }) + new AgentActionGroup(this, 'userInputEnabledActionGroup', { + actionGroupName: 'UserInputAction', + parentActionGroupSignature: 'AMAZON.UserInput', + actionGroupState: props.enableUserInput ? 'ENABLED' : 'DISABLED', + }), ); } @@ -517,13 +517,13 @@ export class Agent extends Construct { */ public addKnowledgeBase(knowledgeBase: KnowledgeBase) { if (!knowledgeBase.instruction) { - throw new Error("Agent Knowledge Bases require instructions."); + throw new Error('Agent Knowledge Bases require instructions.'); } new iam.Policy(this, `AgentKBPolicy-${knowledgeBase.name}`, { roles: [this.role], statements: [ new iam.PolicyStatement({ - actions: ["bedrock:UpdateKnowledgeBase", "bedrock:Retrieve"], + actions: ['bedrock:UpdateKnowledgeBase', 'bedrock:Retrieve'], resources: [knowledgeBase.knowledgeBaseArn], }), ], @@ -545,8 +545,8 @@ export class Agent extends Construct { * Add action group to the agent. */ public addActionGroup(actionGroup: AgentActionGroup) { - actionGroup.actionGroupExecutor?.lambda?.addPermission("AgentLambdaInvocationPolicy", { - principal: new iam.ServicePrincipal("bedrock.amazonaws.com"), + actionGroup.actionGroupExecutor?.lambda?.addPermission('AgentLambdaInvocationPolicy', { + principal: new iam.ServicePrincipal('bedrock.amazonaws.com'), sourceArn: this.agentArn, sourceAccount: cdk.Stack.of(this).account, }); @@ -575,7 +575,7 @@ export class Agent extends Construct { roles: [this.role], statements: [ new iam.PolicyStatement({ - actions: ["bedrock:ApplyGuardrail"], + actions: ['bedrock:ApplyGuardrail'], resources: [guardrail.guardrailArn], }), ], @@ -623,31 +623,31 @@ function validateModel(foundationModel: BedrockFoundationModel) { */ export function validateInferenceConfiguration(inferenceConfiguration: InferenceConfiguration) { if (inferenceConfiguration.topK < 0 || inferenceConfiguration.topK > 500) { - throw new Error("topK must be between 0 and 500"); + throw new Error('topK must be between 0 and 500'); } if (!Number.isInteger(inferenceConfiguration.topK)) { - throw new Error("topK must be an integer"); + throw new Error('topK must be an integer'); } if (inferenceConfiguration.stopSequences.length > 4) { - throw new Error("stopSequences cannot contain more than 4 elements"); + throw new Error('stopSequences cannot contain more than 4 elements'); } if (inferenceConfiguration.maximumLength < 0 || inferenceConfiguration.maximumLength > 4096) { - throw new Error("maximumLength must be between 0 and 4096"); + throw new Error('maximumLength must be between 0 and 4096'); } if (!Number.isInteger(inferenceConfiguration.maximumLength)) { - throw new Error("maximumLength must be an integer"); + throw new Error('maximumLength must be an integer'); } if (inferenceConfiguration.topP < 0 || inferenceConfiguration.topP > 1) { - throw new Error("topP must be between 0 and 1"); + throw new Error('topP must be between 0 and 1'); } if (inferenceConfiguration.temperature < 0 || inferenceConfiguration.temperature > 1) { - throw new Error("temperature must be between 0 and 1"); + throw new Error('temperature must be between 0 and 1'); } } @@ -657,7 +657,7 @@ export function validateInferenceConfiguration(inferenceConfiguration: Inference * @internal This is an internal core function and should not be called directly. */ export function validatePromptOverrideConfiguration( - promptOverrideConfiguration: PromptOverrideConfiguration | undefined + promptOverrideConfiguration: PromptOverrideConfiguration | undefined, ) { if (!promptOverrideConfiguration) { return; @@ -668,7 +668,7 @@ export function validatePromptOverrideConfiguration( promptOverrideConfiguration.promptConfigurations.some((pc) => pc.parserMode !== ParserMode.OVERRIDDEN) ) { throw new Error( - "overrideLambda can only be used if all promptConfigurations have a parserMode value of OVERRIDDEN" + 'overrideLambda can only be used if all promptConfigurations have a parserMode value of OVERRIDDEN', ); } @@ -677,7 +677,7 @@ export function validatePromptOverrideConfiguration( promptOverrideConfiguration.promptConfigurations.some((pc) => pc.parserMode === ParserMode.OVERRIDDEN) ) { throw new Error( - "At least one promptConfiguration has a parserMode value of OVERRIDDEN, but no overrideLambda is specified" + 'At least one promptConfiguration has a parserMode value of OVERRIDDEN, but no overrideLambda is specified', ); } diff --git a/src/cdk-lib/bedrock/guardrails/guardrail-filters.ts b/src/cdk-lib/bedrock/guardrails/guardrail-filters.ts index 55a4228c..aeaf9572 100644 --- a/src/cdk-lib/bedrock/guardrails/guardrail-filters.ts +++ b/src/cdk-lib/bedrock/guardrails/guardrail-filters.ts @@ -20,10 +20,10 @@ * of seeing harmful content in your application reduces. */ export enum ContentFilterStrength { - NONE = "NONE", - LOW = "LOW", - MEDIUM = "MEDIUM", - HIGH = "HIGH", + NONE = 'NONE', + LOW = 'LOW', + MEDIUM = 'MEDIUM', + HIGH = 'HIGH', } /** @@ -34,36 +34,36 @@ export enum ContentFilterType { * Describes input prompts and model responses that indicates sexual interest, activity, * or arousal using direct or indirect references to body parts, physical traits, or sex. */ - SEXUAL = "SEXUAL", + SEXUAL = 'SEXUAL', /** * Describes input prompts and model responses that includes glorification of or threats * to inflict physical pain, hurt, or injury toward a person, group or thing. */ - VIOLENCE = "VIOLENCE", + VIOLENCE = 'VIOLENCE', /** * Describes input prompts and model responses that discriminate, criticize, insult, * denounce, or dehumanize a person or group on the basis of an identity (such as race, * ethnicity, gender, religion, sexual orientation, ability, and national origin). */ - HATE = "HATE", + HATE = 'HATE', /** * Describes input prompts and model responses that includes demeaning, humiliating, * mocking, insulting, or belittling language. This type of language is also labeled * as bullying. */ - INSULTS = "INSULTS", + INSULTS = 'INSULTS', /** * Describes input prompts and model responses that seeks or provides information * about engaging in misconduct activity, or harming, defrauding, or taking advantage * of a person, group or institution. */ - MISCONDUCT = "MISCONDUCT", + MISCONDUCT = 'MISCONDUCT', /** * Enable to detect and block user inputs attempting to override system instructions. * To avoid misclassifying system prompts as a prompt attack and ensure that the filters * are selectively applied to user inputs, use input tagging. */ - PROMPT_ATTACK = "PROMPT_ATTACK", + PROMPT_ATTACK = 'PROMPT_ATTACK', } /** @@ -119,7 +119,7 @@ export interface DeniedTopic { * The managed word type filter available for guardrails. */ export enum ManagedWordFilterType { - PROFANITY = "PROFANITY", + PROFANITY = 'PROFANITY', } export type WordFilter = string[] | ManagedWordFilterType[]; @@ -137,52 +137,52 @@ export namespace PIIType { * Building 123". An address can include information such as the street, building, * location, city, state, country, county, zip code, precinct, and neighborhood. */ - ADDRESS = "ADDRESS", + ADDRESS = 'ADDRESS', /** * An individual's age, including the quantity and unit of time. */ - AGE = "AGE", + AGE = 'AGE', /** * The number assigned to a driver's license, which is an official document * permitting an individual to operate one or more motorized vehicles on a * public road. A driver's license number consists of alphanumeric characters. */ - DRIVER_ID = "DRIVER_ID", + DRIVER_ID = 'DRIVER_ID', /** * An email address, such as marymajor@email.com. */ - EMAIL = "EMAIL", + EMAIL = 'EMAIL', /** * A license plate for a vehicle is issued by the state or country where the * vehicle is registered. The format for passenger vehicles is typically five * to eight digits, consisting of upper-case letters and numbers. The format * varies depending on the location of the issuing state or country. */ - LICENSE_PLATE = "LICENSE_PLATE", + LICENSE_PLATE = 'LICENSE_PLATE', /** * An individual's name. This entity type does not include titles, such as Dr., * Mr., Mrs., or Miss. */ - NAME = "NAME", + NAME = 'NAME', /** * An alphanumeric string that is used as a password, such as "*very20special#pass*". */ - PASSWORD = "PASSWORD", + PASSWORD = 'PASSWORD', /** * A phone number. This entity type also includes fax and pager numbers. */ - PHONE = "PHONE", + PHONE = 'PHONE', /** * A user name that identifies an account, such as a login name, screen name, * nick name, or handle. */ - USERNAME = "USERNAME", + USERNAME = 'USERNAME', /** * A Vehicle Identification Number (VIN) uniquely identifies a vehicle. VIN * content and format are defined in the ISO 3779 specification. Each country * has specific codes and formats for VINs. */ - VEHICLE_IDENTIFICATION_NUMBER = "VEHICLE_IDENTIFICATION_NUMBER", + VEHICLE_IDENTIFICATION_NUMBER = 'VEHICLE_IDENTIFICATION_NUMBER', } /** @@ -194,33 +194,33 @@ export namespace PIIType { * and Discover credit and debit cards. For American Express credit or debit cards, * the CVV is a four-digit numeric code. */ - CREDIT_DEBIT_CARD_CVV = "CREDIT_DEBIT_CARD_CVV", + CREDIT_DEBIT_CARD_CVV = 'CREDIT_DEBIT_CARD_CVV', /** * The expiration date for a credit or debit card. This number is usually four digits * long and is often formatted as month/year or MM/YY. Guardrails recognizes expiration * dates such as 01/21, 01/2021, and Jan 2021. */ - CREDIT_DEBIT_CARD_EXPIRY = "CREDIT_DEBIT_CARD_EXPIRY", + CREDIT_DEBIT_CARD_EXPIRY = 'CREDIT_DEBIT_CARD_EXPIRY', /** * The number for a credit or debit card. These numbers can vary from 13 to 16 digits * in length. */ - CREDIT_DEBIT_CARD_NUMBER = "CREDIT_DEBIT_CARD_NUMBER", + CREDIT_DEBIT_CARD_NUMBER = 'CREDIT_DEBIT_CARD_NUMBER', /** * A four-digit personal identification number (PIN) with which you can access your * bank account. */ - PIN = "PIN", + PIN = 'PIN', /** * A SWIFT code is a standard format of Bank Identifier Code (BIC) used to specify a * particular bank or branch. Banks use these codes for money transfers such as * international wire transfers. SWIFT codes consist of eight or 11 characters. */ - SWIFT_CODE = "SWIFT_CODE", + SWIFT_CODE = 'SWIFT_CODE', /** * An International Bank Account Number (IBAN). It has specific formats in each country. */ - INTERNATIONAL_BANK_ACCOUNT_NUMBER = "INTERNATIONAL_BANK_ACCOUNT_NUMBER", + INTERNATIONAL_BANK_ACCOUNT_NUMBER = 'INTERNATIONAL_BANK_ACCOUNT_NUMBER', } /** @@ -230,27 +230,27 @@ export namespace PIIType { /** * A web address, such as www.example.com. */ - URL = "URL", + URL = 'URL', /** * An IPv4 address, such as 198.51.100.0. */ - IP_ADDRESS = "IP_ADDRESS", + IP_ADDRESS = 'IP_ADDRESS', /** * A media access control (MAC) address assigned to a network interface. */ - MAC_ADDRESS = "MAC_ADDRESS", + MAC_ADDRESS = 'MAC_ADDRESS', /** * A unique identifier that's associated with a secret access key. You use * the access key ID and secret access key to sign programmatic AWS requests * cryptographically. */ - AWS_ACCESS_KEY = "AWS_ACCESS_KEY", + AWS_ACCESS_KEY = 'AWS_ACCESS_KEY', /** * A unique identifier that's associated with a secret access key. You use * the access key ID and secret access key to sign programmatic AWS requests * cryptographically. */ - AWS_SECRET_KEY = "AWS_SECRET_KEY", + AWS_SECRET_KEY = 'AWS_SECRET_KEY', } /** @@ -260,25 +260,25 @@ export namespace PIIType { /** * A US bank account number, which is typically 10 to 12 digits long. */ - US_BANK_ACCOUNT_NUMBER = "US_BANK_ACCOUNT_NUMBER", + US_BANK_ACCOUNT_NUMBER = 'US_BANK_ACCOUNT_NUMBER', /** * A US bank account routing number. These are typically nine digits long. */ - US_BANK_ROUTING_NUMBER = "US_BANK_ROUTING_NUMBER", + US_BANK_ROUTING_NUMBER = 'US_BANK_ROUTING_NUMBER', /** * A US Individual Taxpayer Identification Number (ITIN) is a nine-digit number * that starts with a "9" and contain a "7" or "8" as the fourth digit. */ - US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER = "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER", + US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER = 'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER', /** * A US passport number. Passport numbers range from six to nine alphanumeric characters. */ - US_PASSPORT_NUMBER = "US_PASSPORT_NUMBER", + US_PASSPORT_NUMBER = 'US_PASSPORT_NUMBER', /** * A US Social Security Number (SSN) is a nine-digit number that is issued to US citizens, * permanent residents, and temporary working residents. */ - US_SOCIAL_SECURITY_NUMBER = "US_SOCIAL_SECURITY_NUMBER", + US_SOCIAL_SECURITY_NUMBER = 'US_SOCIAL_SECURITY_NUMBER', } /** @@ -289,12 +289,12 @@ export namespace PIIType { * A Canadian Health Service Number is a 10-digit unique identifier, * required for individuals to access healthcare benefits. */ - CA_HEALTH_NUMBER = "CA_HEALTH_NUMBER", + CA_HEALTH_NUMBER = 'CA_HEALTH_NUMBER', /** * A Canadian Social Insurance Number (SIN) is a nine-digit unique identifier, * required for individuals to access government programs and benefits. */ - CA_SOCIAL_INSURANCE_NUMBER = "CA_SOCIAL_INSURANCE_NUMBER", + CA_SOCIAL_INSURANCE_NUMBER = 'CA_SOCIAL_INSURANCE_NUMBER', } /** @@ -304,18 +304,18 @@ export namespace PIIType { /** * A UK National Health Service Number is a 10-17 digit number, such as 485 777 3456. */ - UK_NATIONAL_HEALTH_SERVICE_NUMBER = "UK_NATIONAL_HEALTH_SERVICE_NUMBER", + UK_NATIONAL_HEALTH_SERVICE_NUMBER = 'UK_NATIONAL_HEALTH_SERVICE_NUMBER', /** * A UK National Insurance Number (NINO) provides individuals with access to National * Insurance (social security) benefits. It is also used for some purposes in the UK * tax system. */ - UK_NATIONAL_INSURANCE_NUMBER = "UK_NATIONAL_INSURANCE_NUMBER", + UK_NATIONAL_INSURANCE_NUMBER = 'UK_NATIONAL_INSURANCE_NUMBER', /** * A UK Unique Taxpayer Reference (UTR) is a 10-digit number that identifies a * taxpayer or a business. */ - UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER = "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER", + UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER = 'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER', } } @@ -327,13 +327,13 @@ export enum GuardrailAction { * If sensitive information is detected in the prompt or response, the guardrail * blocks all the content and returns a message that you configure. */ - BLOCK = "BLOCK", + BLOCK = 'BLOCK', /** * If sensitive information is detected in the model response, the guardrail masks * it with an identifier, the sensitive information is masked and replaced with * identifier tags (for example: [NAME-1], [NAME-2], [EMAIL-1], etc.). */ - ANONYMIZE = "ANONYMIZE", + ANONYMIZE = 'ANONYMIZE', } /** @@ -344,12 +344,12 @@ export interface PIIFilter { * The type of PII to filter. */ readonly type: - | PIIType.General - | PIIType.Finance - | PIIType.InformationTechnology - | PIIType.USASpecific - | PIIType.CanadaSpecific - | PIIType.UKSpecific; + | PIIType.General + | PIIType.Finance + | PIIType.InformationTechnology + | PIIType.USASpecific + | PIIType.CanadaSpecific + | PIIType.UKSpecific; /** * The action to take when PII is detected. */ @@ -401,14 +401,14 @@ export enum ContextualGroundingFilterType { * the defined threshold, the response will be blocked and the configured blocked * message will be returned to the user. A higher threshold level blocks more responses. */ - GROUNDING = "GROUNDING", + GROUNDING = 'GROUNDING', /** * Relevance score represents the confidence that the model response is relevant * to the user's query. If the model response has a lower score than the defined * threshold, the response will be blocked and the configured blocked message will * be returned to the user. A higher threshold level blocks more responses. */ - RELEVANCE = "RELEVANCE", + RELEVANCE = 'RELEVANCE', } /** diff --git a/src/cdk-lib/bedrock/guardrails/guardrails.ts b/src/cdk-lib/bedrock/guardrails/guardrails.ts index 604871c9..c92dee05 100644 --- a/src/cdk-lib/bedrock/guardrails/guardrails.ts +++ b/src/cdk-lib/bedrock/guardrails/guardrails.ts @@ -11,13 +11,13 @@ * and limitations under the License. */ -import { Arn, ArnFormat, IResolvable, IResource, Lazy, Resource, Stack } from "aws-cdk-lib"; -import { IKey } from "aws-cdk-lib/aws-kms"; -import { Construct } from "constructs"; -import { md5hash } from "aws-cdk-lib/core/lib/helpers-internal"; -import * as bedrock from "aws-cdk-lib/aws-bedrock"; -import * as filters from "./guardrail-filters"; -import * as fs from "fs"; +import * as fs from 'fs'; +import { Arn, ArnFormat, IResolvable, IResource, Lazy, Resource, Stack } from 'aws-cdk-lib'; +import * as bedrock from 'aws-cdk-lib/aws-bedrock'; +import { IKey } from 'aws-cdk-lib/aws-kms'; +import { md5hash } from 'aws-cdk-lib/core/lib/helpers-internal'; +import { Construct } from 'constructs'; +import * as filters from './guardrail-filters'; /****************************************************************************** * COMMON @@ -141,8 +141,8 @@ export class Guardrail extends GuardrailBase { class Import extends GuardrailBase { public readonly guardrailId = guardrailId; public readonly guardrailArn = Stack.of(scope).formatArn({ - service: "bedrock", - resource: "guardrail", + service: 'bedrock', + resource: 'guardrail', resourceName: guardrailId, }); } @@ -229,8 +229,8 @@ export class Guardrail extends GuardrailBase { this.wordFilters = props.wordFilters ?? []; this.managedWordListFilters = props.managedWordListFilters ?? []; - const defaultBlockedInputMessaging = "Sorry, your query violates our usage policy."; - const defaultBlockedOutputsMessaging = "Sorry, I am unable to answer your question because of our usage policy."; + const defaultBlockedInputMessaging = 'Sorry, your query violates our usage policy.'; + const defaultBlockedOutputsMessaging = 'Sorry, I am unable to answer your question because of our usage policy.'; // ------------------------------------------------------ // CFN Props - With Lazy support @@ -255,7 +255,7 @@ export class Guardrail extends GuardrailBase { // ------------------------------------------------------ // L1 Instantiation // ------------------------------------------------------ - this.__resource = new bedrock.CfnGuardrail(this, "MyGuardrail", cfnProps); + this.__resource = new bedrock.CfnGuardrail(this, 'MyGuardrail', cfnProps); this.guardrailId = this.__resource.attrGuardrailId; this.guardrailArn = this.__resource.attrGuardrailArn; @@ -318,8 +318,8 @@ export class Guardrail extends GuardrailBase { * @param filePath The location of the word filter file. */ public addWordFilterFromFile(filePath: string): void { - const fileContents = fs.readFileSync(filePath, "utf8"); - const words = fileContents.trim().split(","); + const fileContents = fs.readFileSync(filePath, 'utf8'); + const words = fileContents.trim().split(','); for (const word of words) this.addWordFilter(word); } @@ -379,7 +379,7 @@ export class Guardrail extends GuardrailBase { definition: topic.definition, name: topic.name, examples: topic.examples, - type: "DENY", + type: 'DENY', } as bedrock.CfnGuardrail.TopicConfigProperty; }), }; @@ -447,7 +447,7 @@ export class Guardrail extends GuardrailBase { }); }, }, - { omitEmptyArray: true } + { omitEmptyArray: true }, ); } @@ -466,7 +466,7 @@ export class Guardrail extends GuardrailBase { }); }, }, - { omitEmptyArray: true } + { omitEmptyArray: true }, ); } @@ -488,7 +488,7 @@ export class Guardrail extends GuardrailBase { } }, }, - { omitEmptyArray: true } + { omitEmptyArray: true }, ); } @@ -510,7 +510,7 @@ export class Guardrail extends GuardrailBase { }); }, }, - { omitEmptyArray: true } + { omitEmptyArray: true }, ); } @@ -530,7 +530,7 @@ export class Guardrail extends GuardrailBase { }); }, }, - { omitEmptyArray: true } + { omitEmptyArray: true }, ); } } diff --git a/src/cdk-lib/bedrock/guardrails/sample-topics.ts b/src/cdk-lib/bedrock/guardrails/sample-topics.ts index 0e87db48..ce85a0f1 100644 --- a/src/cdk-lib/bedrock/guardrails/sample-topics.ts +++ b/src/cdk-lib/bedrock/guardrails/sample-topics.ts @@ -1,71 +1,83 @@ -import { DeniedTopic } from "./guardrail-filters"; +/** + * 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 { DeniedTopic } from './guardrail-filters'; /****************************************************************************** * SAMPLE TOPICS *****************************************************************************/ export namespace GuardrailSampleTopics { export const FINANCIAL_ADVICE: DeniedTopic = { - name: "Financial_Advice", + name: 'Financial_Advice', definition: "'Discussions that involve providing guidance, recommendations, or suggestions related to managing, investing, or handling finances, investments, or assets.", examples: [ - "Can you suggest some good stocks to invest in right now?", + 'Can you suggest some good stocks to invest in right now?', "What's the best way to save for retirement?", - "Should I put my money in a high-risk investment?", - "How can I maximize my returns on investments?", - "Is it a good time to buy real estate?", + 'Should I put my money in a high-risk investment?', + 'How can I maximize my returns on investments?', + 'Is it a good time to buy real estate?', ], }; export const POLITICAL_ADVICE: DeniedTopic = { - name: "Political_Advice", + name: 'Political_Advice', definition: - "Conversations that express views, opinions, or endorsements related to political parties, political ideologies, elections, or political figures.", + 'Conversations that express views, opinions, or endorsements related to political parties, political ideologies, elections, or political figures.', examples: [ "What's your stance on the current government policies?", - "Do you support party X or Y in the upcoming election?", - "Can you tell me which political party is better?", - "What do you think about the new policy introduced by the president?", - "Should I vote for this candidate?", + 'Do you support party X or Y in the upcoming election?', + 'Can you tell me which political party is better?', + 'What do you think about the new policy introduced by the president?', + 'Should I vote for this candidate?', ], }; export const MEDICAL_ADVICE: DeniedTopic = { - name: "Medical_Advice", + name: 'Medical_Advice', definition: - "Providing recommendations, diagnosis, treatment options, or guidance on medical conditions, symptoms, medications, or health-related issues.", + 'Providing recommendations, diagnosis, treatment options, or guidance on medical conditions, symptoms, medications, or health-related issues.', examples: [ - "What should I do to treat a persistent cough?", - "Can you recommend some medication for my headache?", - "What are the symptoms of a specific medical condition?", - "Is this drug effective for treating my illness?", + 'What should I do to treat a persistent cough?', + 'Can you recommend some medication for my headache?', + 'What are the symptoms of a specific medical condition?', + 'Is this drug effective for treating my illness?', "Do I need to see a doctor for this pain I'm experiencing?", ], }; export const INNOPROPRIATE_CONTENT: DeniedTopic = { - name: "Inappropriate_Content", + name: 'Inappropriate_Content', definition: - "Any discussions or references that include hate speech, discriminatory remarks, sexual content, or explicit language.", + 'Any discussions or references that include hate speech, discriminatory remarks, sexual content, or explicit language.', examples: [ - "Why are people from X country so [discriminatory remark]?", - "Can you tell me a dirty joke?", - "[Use of explicit language]", - "This service is as bad as [hate speech].", - "Do you have any adult content or products?", + 'Why are people from X country so [discriminatory remark]?', + 'Can you tell me a dirty joke?', + '[Use of explicit language]', + 'This service is as bad as [hate speech].', + 'Do you have any adult content or products?', ], }; export const LEGAL_ADVICE: DeniedTopic = { - 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?', ], }; } diff --git a/src/cdk-lib/bedrock/index.ts b/src/cdk-lib/bedrock/index.ts index 0b81c727..8a5473f6 100644 --- a/src/cdk-lib/bedrock/index.ts +++ b/src/cdk-lib/bedrock/index.ts @@ -11,24 +11,24 @@ * and limitations under the License. */ -export * from "./knowledge-base"; -export * from "./agent"; -export * from "./agent-alias"; -export * from "./agent-action-group"; -export * from "./api-schema"; -export * from "./guardrails/guardrail-filters"; -export * from "./guardrails/guardrails"; -export * from "./guardrails/sample-topics"; -export * from "./content-policy"; -export * from "./models"; -export * from "./prompt"; -export * from "./prompt-version"; -export * from "./data-sources/base-data-source"; -export * from "./data-sources/chunking"; -export * from "./data-sources/parsing"; -export * from "./data-sources/custom-transformation"; -export * from "./data-sources/web-crawler-data-source"; -export * from "./data-sources/sharepoint-data-source"; -export * from "./data-sources/confluence-data-source"; -export * from "./data-sources/salesforce-data-source"; -export * from "./data-sources/s3-data-source"; +export * from './knowledge-base'; +export * from './agent'; +export * from './agent-alias'; +export * from './agent-action-group'; +export * from './api-schema'; +export * from './guardrails/guardrail-filters'; +export * from './guardrails/guardrails'; +export * from './guardrails/sample-topics'; +export * from './content-policy'; +export * from './models'; +export * from './prompt'; +export * from './prompt-version'; +export * from './data-sources/base-data-source'; +export * from './data-sources/chunking'; +export * from './data-sources/parsing'; +export * from './data-sources/custom-transformation'; +export * from './data-sources/web-crawler-data-source'; +export * from './data-sources/sharepoint-data-source'; +export * from './data-sources/confluence-data-source'; +export * from './data-sources/salesforce-data-source'; +export * from './data-sources/s3-data-source'; diff --git a/test/cdk-lib/bedrock/guardrails.test.ts b/test/cdk-lib/bedrock/guardrails.test.ts index 99366ecc..be912646 100644 --- a/test/cdk-lib/bedrock/guardrails.test.ts +++ b/test/cdk-lib/bedrock/guardrails.test.ts @@ -1,28 +1,40 @@ -import * as cdk from "aws-cdk-lib"; -import { Match, Template } from "aws-cdk-lib/assertions"; -import * as bedrock from "../../../src/cdk-lib/bedrock"; -import { Key } from "aws-cdk-lib/aws-kms"; - -describe("CDK-Created-Guardrail", () => { +/** + * 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 cdk from 'aws-cdk-lib'; +import { Match, Template } from 'aws-cdk-lib/assertions'; +import { Key } from 'aws-cdk-lib/aws-kms'; +import * as bedrock from '../../../src/cdk-lib/bedrock'; + +describe('CDK-Created-Guardrail', () => { let stack: cdk.Stack; beforeEach(() => { const app = new cdk.App(); - stack = new cdk.Stack(app, "TestStack"); + stack = new cdk.Stack(app, 'TestStack'); }); - test("Basic Creation", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Basic Creation', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', // test defaults - BlockedInputMessaging: "Sorry, your query violates our usage policy.", - BlockedOutputsMessaging: "Sorry, I am unable to answer your question because of our usage policy.", + BlockedInputMessaging: 'Sorry, your query violates our usage policy.', + BlockedOutputsMessaging: 'Sorry, I am unable to answer your question because of our usage policy.', // ensure others are undefined TopicPolicyConfig: Match.absent(), ContextualGroundingPolicyConfig: Match.absent(), @@ -34,90 +46,90 @@ describe("CDK-Created-Guardrail", () => { guardrail.name; }); - test("Basic Creation + KMS Key", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Basic Creation + KMS Key', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', // test defaults" kmsKey: Key.fromKeyArn( stack, - "importedKey", - "arn:aws:kms:eu-central-1:123456789012:key/06484191-7d55-49fb-9be7-0baaf7fe8418" + 'importedKey', + 'arn:aws:kms:eu-central-1:123456789012:key/06484191-7d55-49fb-9be7-0baaf7fe8418', ), }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", - KmsKeyArn: "arn:aws:kms:eu-central-1:123456789012:key/06484191-7d55-49fb-9be7-0baaf7fe8418", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', + KmsKeyArn: 'arn:aws:kms:eu-central-1:123456789012:key/06484191-7d55-49fb-9be7-0baaf7fe8418', }); }); - test("Topic Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Topic Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', deniedTopics: [bedrock.GuardrailSampleTopics.FINANCIAL_ADVICE], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', TopicPolicyConfig: { TopicsConfig: [ { Definition: "'Discussions that involve providing guidance, recommendations, or suggestions related to managing, investing, or handling finances, investments, or assets.", Examples: [ - "Can you suggest some good stocks to invest in right now?", + 'Can you suggest some good stocks to invest in right now?', "What's the best way to save for retirement?", - "Should I put my money in a high-risk investment?", - "How can I maximize my returns on investments?", - "Is it a good time to buy real estate?", + 'Should I put my money in a high-risk investment?', + 'How can I maximize my returns on investments?', + 'Is it a good time to buy real estate?', ], - Name: "Financial_Advice", - Type: "DENY", + Name: 'Financial_Advice', + Type: 'DENY', }, ], }, }); }); - test("Topic Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Topic Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addDeniedTopicFilter(bedrock.GuardrailSampleTopics.FINANCIAL_ADVICE); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', TopicPolicyConfig: { TopicsConfig: [ { Definition: "'Discussions that involve providing guidance, recommendations, or suggestions related to managing, investing, or handling finances, investments, or assets.", Examples: [ - "Can you suggest some good stocks to invest in right now?", + 'Can you suggest some good stocks to invest in right now?', "What's the best way to save for retirement?", - "Should I put my money in a high-risk investment?", - "How can I maximize my returns on investments?", - "Is it a good time to buy real estate?", + 'Should I put my money in a high-risk investment?', + 'How can I maximize my returns on investments?', + 'Is it a good time to buy real estate?', ], - Name: "Financial_Advice", - Type: "DENY", + Name: 'Financial_Advice', + Type: 'DENY', }, ], }, }); }); - test("Content Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Content Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', contentFilters: [ { type: bedrock.ContentFilterType.MISCONDUCT, @@ -127,25 +139,25 @@ describe("CDK-Created-Guardrail", () => { ], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', ContentPolicyConfig: { FiltersConfig: [ { - InputStrength: "LOW", - OutputStrength: "LOW", - Type: "MISCONDUCT", + InputStrength: 'LOW', + OutputStrength: 'LOW', + Type: 'MISCONDUCT', }, ], }, }); }); - test("Content Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Content Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addContentFilter({ @@ -154,25 +166,25 @@ describe("CDK-Created-Guardrail", () => { outputStrength: bedrock.ContentFilterStrength.LOW, }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', ContentPolicyConfig: { FiltersConfig: [ { - InputStrength: "LOW", - OutputStrength: "LOW", - Type: "MISCONDUCT", + InputStrength: 'LOW', + OutputStrength: 'LOW', + Type: 'MISCONDUCT', }, ], }, }); }); - test("Contextual Grounding Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Contextual Grounding Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', contextualGroundingFilters: [ { type: bedrock.ContextualGroundingFilterType.GROUNDING, @@ -181,24 +193,24 @@ describe("CDK-Created-Guardrail", () => { ], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', ContextualGroundingPolicyConfig: { FiltersConfig: [ { Threshold: 0.99, - Type: "GROUNDING", + Type: 'GROUNDING', }, ], }, }); }); - test("Contextual Grounding Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Contextual Grounding Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addContextualGroundingFilter({ @@ -206,24 +218,24 @@ describe("CDK-Created-Guardrail", () => { threshold: 0.99, }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', ContextualGroundingPolicyConfig: { FiltersConfig: [ { Threshold: 0.99, - Type: "GROUNDING", + Type: 'GROUNDING', }, ], }, }); }); - test("PII Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('PII Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', piiFilters: [ { type: bedrock.PIIType.General.ADDRESS, @@ -232,24 +244,24 @@ describe("CDK-Created-Guardrail", () => { ], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', SensitiveInformationPolicyConfig: { PiiEntitiesConfig: [ { - Action: "ANONYMIZE", - Type: "ADDRESS", + Action: 'ANONYMIZE', + Type: 'ADDRESS', }, ], }, }); }); - test("PII Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('PII Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addPIIFilter({ @@ -257,172 +269,172 @@ describe("CDK-Created-Guardrail", () => { action: bedrock.GuardrailAction.ANONYMIZE, }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', SensitiveInformationPolicyConfig: { PiiEntitiesConfig: [ { - Action: "ANONYMIZE", - Type: "ADDRESS", + Action: 'ANONYMIZE', + Type: 'ADDRESS', }, ], }, }); }); - test("Regex Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Regex Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', regexFilters: [ { - 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, }, ], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', SensitiveInformationPolicyConfig: { RegexesConfig: [ { - Action: "ANONYMIZE", - Name: "TestRegexFilter", - Pattern: "/^[A-Z]{2}d{6}$/", - Description: "This is a test regex filter", + Action: 'ANONYMIZE', + Name: 'TestRegexFilter', + Pattern: '/^[A-Z]{2}d{6}$/', + Description: 'This is a test regex filter', }, ], }, }); }); - test("Regex Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Regex Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); 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, }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', SensitiveInformationPolicyConfig: { RegexesConfig: [ { - Action: "ANONYMIZE", - Name: "TestRegexFilter", - Pattern: "/^[A-Z]{2}d{6}$/", - Description: "This is a test regex filter", + Action: 'ANONYMIZE', + Name: 'TestRegexFilter', + Pattern: '/^[A-Z]{2}d{6}$/', + Description: 'This is a test regex filter', }, ], }, }); }); - test("Word Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", - wordFilters: ["reggaeton", "alcohol"], + test('Word Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', + wordFilters: ['reggaeton', 'alcohol'], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', WordPolicyConfig: { WordsConfig: [ { - Text: "reggaeton", + Text: 'reggaeton', }, { - Text: "alcohol", + Text: 'alcohol', }, ], }, }); }); - test("Word Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Word Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); - guardrail.addWordFilter("reggaeton"); - guardrail.addWordFilter("alcohol"); + guardrail.addWordFilter('reggaeton'); + guardrail.addWordFilter('alcohol'); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', WordPolicyConfig: { WordsConfig: [ { - Text: "reggaeton", + Text: 'reggaeton', }, { - Text: "alcohol", + Text: 'alcohol', }, ], }, }); }); - test("Managed Word Filter - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Managed Word Filter - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', managedWordListFilters: [bedrock.ManagedWordFilterType.PROFANITY], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', WordPolicyConfig: { ManagedWordListsConfig: [ { - Type: "PROFANITY", + Type: 'PROFANITY', }, ], }, }); }); - test("Managed Word Filter - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Managed Word Filter - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addManagedWordListFilter(bedrock.ManagedWordFilterType.PROFANITY); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', WordPolicyConfig: { ManagedWordListsConfig: [ { - Type: "PROFANITY", + Type: 'PROFANITY', }, ], }, }); }); - test("All filters - Props", () => { - new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('All filters - Props', () => { + new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', deniedTopics: [bedrock.GuardrailSampleTopics.FINANCIAL_ADVICE], contentFilters: [ { @@ -445,33 +457,33 @@ describe("CDK-Created-Guardrail", () => { ], regexFilters: [ { - 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, }, ], - wordFilters: ["reggaeton", "alcohol"], + wordFilters: ['reggaeton', 'alcohol'], managedWordListFilters: [bedrock.ManagedWordFilterType.PROFANITY], }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', TopicPolicyConfig: { TopicsConfig: [ { Definition: "'Discussions that involve providing guidance, recommendations, or suggestions related to managing, investing, or handling finances, investments, or assets.", Examples: [ - "Can you suggest some good stocks to invest in right now?", + 'Can you suggest some good stocks to invest in right now?', "What's the best way to save for retirement?", - "Should I put my money in a high-risk investment?", - "How can I maximize my returns on investments?", - "Is it a good time to buy real estate?", + 'Should I put my money in a high-risk investment?', + 'How can I maximize my returns on investments?', + 'Is it a good time to buy real estate?', ], - Name: "Financial_Advice", - Type: "DENY", + Name: 'Financial_Advice', + Type: 'DENY', }, ], }, @@ -479,57 +491,57 @@ describe("CDK-Created-Guardrail", () => { FiltersConfig: [ { Threshold: 0.99, - Type: "GROUNDING", + Type: 'GROUNDING', }, ], }, ContentPolicyConfig: { FiltersConfig: [ { - InputStrength: "LOW", - OutputStrength: "LOW", - Type: "MISCONDUCT", + InputStrength: 'LOW', + OutputStrength: 'LOW', + Type: 'MISCONDUCT', }, ], }, WordPolicyConfig: { WordsConfig: [ { - Text: "reggaeton", + Text: 'reggaeton', }, { - Text: "alcohol", + Text: 'alcohol', }, ], ManagedWordListsConfig: [ { - Type: "PROFANITY", + Type: 'PROFANITY', }, ], }, SensitiveInformationPolicyConfig: { RegexesConfig: [ { - Action: "ANONYMIZE", - Name: "TestRegexFilter", - Pattern: "/^[A-Z]{2}d{6}$/", - Description: "This is a test regex filter", + Action: 'ANONYMIZE', + Name: 'TestRegexFilter', + Pattern: '/^[A-Z]{2}d{6}$/', + Description: 'This is a test regex filter', }, ], PiiEntitiesConfig: [ { - Action: "ANONYMIZE", - Type: "ADDRESS", + Action: 'ANONYMIZE', + Type: 'ADDRESS', }, ], }, }); }); - test("All filters - Method", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('All filters - Method', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addDeniedTopicFilter(bedrock.GuardrailSampleTopics.FINANCIAL_ADVICE); @@ -545,8 +557,8 @@ describe("CDK-Created-Guardrail", () => { threshold: 0.99, }); - guardrail.addWordFilter("reggaeton"); - guardrail.addWordFilter("alcohol"); + guardrail.addWordFilter('reggaeton'); + guardrail.addWordFilter('alcohol'); guardrail.addManagedWordListFilter(bedrock.ManagedWordFilterType.PROFANITY); @@ -555,29 +567,29 @@ describe("CDK-Created-Guardrail", () => { action: bedrock.GuardrailAction.ANONYMIZE, }); 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, }); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::Guardrail", { - Name: "TestGuardrail", - Description: "This is a test guardrail", + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::Guardrail', { + Name: 'TestGuardrail', + Description: 'This is a test guardrail', TopicPolicyConfig: { TopicsConfig: [ { Definition: "'Discussions that involve providing guidance, recommendations, or suggestions related to managing, investing, or handling finances, investments, or assets.", Examples: [ - "Can you suggest some good stocks to invest in right now?", + 'Can you suggest some good stocks to invest in right now?', "What's the best way to save for retirement?", - "Should I put my money in a high-risk investment?", - "How can I maximize my returns on investments?", - "Is it a good time to buy real estate?", + 'Should I put my money in a high-risk investment?', + 'How can I maximize my returns on investments?', + 'Is it a good time to buy real estate?', ], - Name: "Financial_Advice", - Type: "DENY", + Name: 'Financial_Advice', + Type: 'DENY', }, ], }, @@ -585,98 +597,98 @@ describe("CDK-Created-Guardrail", () => { FiltersConfig: [ { Threshold: 0.99, - Type: "GROUNDING", + Type: 'GROUNDING', }, ], }, ContentPolicyConfig: { FiltersConfig: [ { - InputStrength: "LOW", - OutputStrength: "LOW", - Type: "MISCONDUCT", + InputStrength: 'LOW', + OutputStrength: 'LOW', + Type: 'MISCONDUCT', }, ], }, WordPolicyConfig: { WordsConfig: [ { - Text: "reggaeton", + Text: 'reggaeton', }, { - Text: "alcohol", + Text: 'alcohol', }, ], ManagedWordListsConfig: [ { - Type: "PROFANITY", + Type: 'PROFANITY', }, ], }, SensitiveInformationPolicyConfig: { RegexesConfig: [ { - Action: "ANONYMIZE", - Name: "TestRegexFilter", - Pattern: "/^[A-Z]{2}d{6}$/", - Description: "This is a test regex filter", + Action: 'ANONYMIZE', + Name: 'TestRegexFilter', + Pattern: '/^[A-Z]{2}d{6}$/', + Description: 'This is a test regex filter', }, ], PiiEntitiesConfig: [ { - Action: "ANONYMIZE", - Type: "ADDRESS", + Action: 'ANONYMIZE', + Type: 'ADDRESS', }, ], }, }); }); - test("Versioning", () => { - const guardrail = new bedrock.Guardrail(stack, "TestGuardrail", { - name: "TestGuardrail", - description: "This is a test guardrail", + test('Versioning', () => { + const guardrail = new bedrock.Guardrail(stack, 'TestGuardrail', { + name: 'TestGuardrail', + description: 'This is a test guardrail', }); guardrail.addDeniedTopicFilter(bedrock.GuardrailSampleTopics.FINANCIAL_ADVICE); guardrail.createVersion(); - Template.fromStack(stack).hasResourceProperties("AWS::Bedrock::GuardrailVersion", { + Template.fromStack(stack).hasResourceProperties('AWS::Bedrock::GuardrailVersion', { GuardrailIdentifier: { - "Fn::GetAtt": [Match.anyValue(), "GuardrailId"], + 'Fn::GetAtt': [Match.anyValue(), 'GuardrailId'], }, }); }); }); -describe("Imported-Guardrail", () => { +describe('Imported-Guardrail', () => { let stack: cdk.Stack; beforeEach(() => { const app = new cdk.App(); - stack = new cdk.Stack(app, "TestStack2", { + stack = new cdk.Stack(app, 'TestStack2', { env: { - account: "123456789012", - region: "us-east-1", + account: '123456789012', + region: 'us-east-1', }, }); }); - test("Basic Import - ARN", () => { + test('Basic Import - ARN', () => { const guardrail = bedrock.Guardrail.fromGuardrailArn( stack, - "TestGuardrail", - "arn:aws:bedrock:us-east-1:123456789012:guardrail/oygh3o8g7rtl" + 'TestGuardrail', + 'arn:aws:bedrock:us-east-1:123456789012:guardrail/oygh3o8g7rtl', ); - expect(guardrail.guardrailArn).toBe("arn:aws:bedrock:us-east-1:123456789012:guardrail/oygh3o8g7rtl"); - expect(guardrail.guardrailId).toBe("oygh3o8g7rtl"); + expect(guardrail.guardrailArn).toBe('arn:aws:bedrock:us-east-1:123456789012:guardrail/oygh3o8g7rtl'); + expect(guardrail.guardrailId).toBe('oygh3o8g7rtl'); }); - test("Basic Import - ID", () => { - const guardrail = bedrock.Guardrail.fromGuardrailId(stack, "TestGuardrail", "oygh3o8g7rtl"); + test('Basic Import - ID', () => { + const guardrail = bedrock.Guardrail.fromGuardrailId(stack, 'TestGuardrail', 'oygh3o8g7rtl'); - expect(guardrail.guardrailId).toBe("oygh3o8g7rtl"); + expect(guardrail.guardrailId).toBe('oygh3o8g7rtl'); }); });