Skip to content

Commit f8cc6bd

Browse files
author
awstools
committed
feat(client-bedrock): Add support for contextual grounding check for Guardrails for Amazon Bedrock.
1 parent 8863b77 commit f8cc6bd

File tree

6 files changed

+716
-113
lines changed

6 files changed

+716
-113
lines changed

clients/client-bedrock/src/commands/CreateGuardrailCommand.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,46 +32,38 @@ export interface CreateGuardrailCommandInput extends CreateGuardrailRequest {}
3232
export interface CreateGuardrailCommandOutput extends CreateGuardrailResponse, __MetadataBearer {}
3333

3434
/**
35-
* <p>Creates a guardrail to block topics and to filter out harmful content.</p>
35+
* <p>Creates a guardrail to block topics and to implement safeguards for your generative AI applications.</p>
36+
* <p>You can configure the following policies in a guardrail to avoid undesirable and harmful content, filter
37+
* out denied topics and words, and remove sensitive information for privacy protection.</p>
3638
* <ul>
3739
* <li>
38-
* <p>Specify a <code>name</code> and optional <code>description</code>.</p>
40+
* <p>
41+
* <b>Content filters</b> - Adjust filter strengths
42+
* to block input prompts or model responses containing harmful content.</p>
3943
* </li>
4044
* <li>
41-
* <p>Specify messages for when the guardrail successfully blocks a prompt or a model response in the <code>blockedInputMessaging</code> and <code>blockedOutputsMessaging</code> fields.</p>
45+
* <p>
46+
* <b>Denied topics</b> - Define a set of topics that
47+
* are undesirable in the context of your application. These topics will be blocked if
48+
* detected in user queries or model responses.</p>
4249
* </li>
4350
* <li>
44-
* <p>Specify topics for the guardrail to deny in the <code>topicPolicyConfig</code> object. Each <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailTopicConfig.html">GuardrailTopicConfig</a> object in the <code>topicsConfig</code> list pertains to one topic.</p>
45-
* <ul>
46-
* <li>
47-
* <p>Give a <code>name</code> and <code>description</code> so that the guardrail can properly identify the topic.</p>
48-
* </li>
49-
* <li>
50-
* <p>Specify <code>DENY</code> in the <code>type</code> field.</p>
51-
* </li>
52-
* <li>
53-
* <p>(Optional) Provide up to five prompts that you would categorize as belonging to the topic in the <code>examples</code> list.</p>
54-
* </li>
55-
* </ul>
51+
* <p>
52+
* <b>Word filters</b> - Configure filters to block
53+
* undesirable words, phrases, and profanity. Such words can include offensive terms,
54+
* competitor names etc.</p>
5655
* </li>
5756
* <li>
58-
* <p>Specify filter strengths for the harmful categories defined in Amazon Bedrock in the <code>contentPolicyConfig</code> object. Each <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a> object in the <code>filtersConfig</code> list pertains to a harmful category. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-filters">Content filters</a>. For more information about the fields in a content filter, see <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a>.</p>
59-
* <ul>
60-
* <li>
61-
* <p>Specify the category in the <code>type</code> field.</p>
62-
* </li>
63-
* <li>
64-
* <p>Specify the strength of the filter for prompts in the <code>inputStrength</code> field and for model responses in the <code>strength</code> field of the <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a>.</p>
65-
* </li>
66-
* </ul>
67-
* </li>
68-
* <li>
69-
* <p>(Optional) For security, include the ARN of a KMS key in the <code>kmsKeyId</code> field.</p>
70-
* </li>
71-
* <li>
72-
* <p>(Optional) Attach any tags to the guardrail in the <code>tags</code> object. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/tagging">Tag resources</a>.</p>
57+
* <p>
58+
* <b>Sensitive information filters</b> - Block or
59+
* mask sensitive information such as personally identifiable information (PII) or custom
60+
* regex in user inputs and model responses.</p>
7361
* </li>
7462
* </ul>
63+
* <p>In addition to the above policies, you can also configure the messages to be returned to
64+
* the user if a user input or model response is in violation of the policies defined in the guardrail.</p>
65+
* <p>For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html">Guardrails for Amazon Bedrock</a> in
66+
* the <i>Amazon Bedrock User Guide</i>.</p>
7567
* @example
7668
* Use a bare-bones client and the command you need to make an API call.
7769
* ```javascript
@@ -130,6 +122,14 @@ export interface CreateGuardrailCommandOutput extends CreateGuardrailResponse, _
130122
* },
131123
* ],
132124
* },
125+
* contextualGroundingPolicyConfig: { // GuardrailContextualGroundingPolicyConfig
126+
* filtersConfig: [ // GuardrailContextualGroundingFiltersConfig // required
127+
* { // GuardrailContextualGroundingFilterConfig
128+
* type: "GROUNDING" || "RELEVANCE", // required
129+
* threshold: Number("double"), // required
130+
* },
131+
* ],
132+
* },
133133
* blockedInputMessaging: "STRING_VALUE", // required
134134
* blockedOutputsMessaging: "STRING_VALUE", // required
135135
* kmsKeyId: "STRING_VALUE",

clients/client-bedrock/src/commands/GetGuardrailCommand.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ export interface GetGuardrailCommandOutput extends GetGuardrailResponse, __Metad
9797
* // },
9898
* // ],
9999
* // },
100+
* // contextualGroundingPolicy: { // GuardrailContextualGroundingPolicy
101+
* // filters: [ // GuardrailContextualGroundingFilters // required
102+
* // { // GuardrailContextualGroundingFilter
103+
* // type: "GROUNDING" || "RELEVANCE", // required
104+
* // threshold: Number("double"), // required
105+
* // },
106+
* // ],
107+
* // },
100108
* // createdAt: new Date("TIMESTAMP"), // required
101109
* // updatedAt: new Date("TIMESTAMP"), // required
102110
* // statusReasons: [ // GuardrailStatusReasons

clients/client-bedrock/src/commands/UpdateGuardrailCommand.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface UpdateGuardrailCommandOutput extends UpdateGuardrailResponse, _
5555
* </ul>
5656
* </li>
5757
* <li>
58-
* <p>Specify filter strengths for the harmful categories defined in Amazon Bedrock in the <code>contentPolicyConfig</code> object. Each <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a> object in the <code>filtersConfig</code> list pertains to a harmful category. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-filters">Content filters</a>. For more information about the fields in a content filter, see <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a>.</p>
58+
* <p>Specify filter strengths for the harmful categories defined in Amazon Bedrock in the <code>contentPolicyConfig</code> object. Each <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a> object in the <code>filtersConfig</code> list pertains to a harmful category. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-content-filters">Content filters</a>. For more information about the fields in a content filter, see <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a>.</p>
5959
* <ul>
6060
* <li>
6161
* <p>Specify the category in the <code>type</code> field.</p>
@@ -68,9 +68,6 @@ export interface UpdateGuardrailCommandOutput extends UpdateGuardrailResponse, _
6868
* <li>
6969
* <p>(Optional) For security, include the ARN of a KMS key in the <code>kmsKeyId</code> field.</p>
7070
* </li>
71-
* <li>
72-
* <p>(Optional) Attach any tags to the guardrail in the <code>tags</code> object. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/tagging">Tag resources</a>.</p>
73-
* </li>
7471
* </ul>
7572
* @example
7673
* Use a bare-bones client and the command you need to make an API call.
@@ -131,6 +128,14 @@ export interface UpdateGuardrailCommandOutput extends UpdateGuardrailResponse, _
131128
* },
132129
* ],
133130
* },
131+
* contextualGroundingPolicyConfig: { // GuardrailContextualGroundingPolicyConfig
132+
* filtersConfig: [ // GuardrailContextualGroundingFiltersConfig // required
133+
* { // GuardrailContextualGroundingFilterConfig
134+
* type: "GROUNDING" || "RELEVANCE", // required
135+
* threshold: Number("double"), // required
136+
* },
137+
* ],
138+
* },
134139
* blockedInputMessaging: "STRING_VALUE", // required
135140
* blockedOutputsMessaging: "STRING_VALUE", // required
136141
* kmsKeyId: "STRING_VALUE",

0 commit comments

Comments
 (0)