updateGuardrail method
- required String blockedInputMessaging,
- required String blockedOutputsMessaging,
- required String guardrailIdentifier,
- required String name,
- GuardrailAutomatedReasoningPolicyConfig? automatedReasoningPolicyConfig,
- GuardrailContentPolicyConfig? contentPolicyConfig,
- GuardrailContextualGroundingPolicyConfig? contextualGroundingPolicyConfig,
- GuardrailCrossRegionConfig? crossRegionConfig,
- String? description,
- String? kmsKeyId,
- GuardrailSensitiveInformationPolicyConfig? sensitiveInformationPolicyConfig,
- GuardrailTopicPolicyConfig? topicPolicyConfig,
- GuardrailWordPolicyConfig? wordPolicyConfig,
Updates a guardrail with the values you specify.
-
Specify a
nameand optionaldescription. -
Specify messages for when the guardrail successfully blocks a prompt or a
model response in the
blockedInputMessagingandblockedOutputsMessagingfields. -
Specify topics for the guardrail to deny in the
topicPolicyConfigobject. Each GuardrailTopicConfig object in thetopicsConfiglist pertains to one topic.-
Give a
nameanddescriptionso that the guardrail can properly identify the topic. -
Specify
DENYin thetypefield. -
(Optional) Provide up to five prompts that you would categorize as
belonging to the topic in the
exampleslist.
-
Give a
-
Specify filter strengths for the harmful categories defined in Amazon
Bedrock in the
contentPolicyConfigobject. Each GuardrailContentFilterConfig object in thefiltersConfiglist pertains to a harmful category. For more information, see Content filters. For more information about the fields in a content filter, see GuardrailContentFilterConfig.-
Specify the category in the
typefield. -
Specify the strength of the filter for prompts in the
inputStrengthfield and for model responses in thestrengthfield of the GuardrailContentFilterConfig.
-
Specify the category in the
-
(Optional) For security, include the ARN of a KMS key in the
kmsKeyIdfield.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter blockedInputMessaging :
The message to return when the guardrail blocks a prompt.
Parameter blockedOutputsMessaging :
The message to return when the guardrail blocks a model response.
Parameter guardrailIdentifier :
The unique identifier of the guardrail. This can be an ID or the ARN.
Parameter name :
A name for the guardrail.
Parameter automatedReasoningPolicyConfig :
Updated configuration for Automated Reasoning policies associated with the
guardrail.
Parameter contentPolicyConfig :
The content policy to configure for the guardrail.
Parameter contextualGroundingPolicyConfig :
The contextual grounding policy configuration used to update a guardrail.
Parameter crossRegionConfig :
The system-defined guardrail profile that you're using with your
guardrail. Guardrail profiles define the destination Amazon Web Services
Regions where guardrail inference requests can be automatically routed.
For more information, see the Amazon Bedrock User Guide.
Parameter description :
A description of the guardrail.
Parameter kmsKeyId :
The ARN of the KMS key with which to encrypt the guardrail.
Parameter sensitiveInformationPolicyConfig :
The sensitive information policy to configure for the guardrail.
Parameter topicPolicyConfig :
The topic policy to configure for the guardrail.
Parameter wordPolicyConfig :
The word policy to configure for the guardrail.
Implementation
Future<UpdateGuardrailResponse> updateGuardrail({
required String blockedInputMessaging,
required String blockedOutputsMessaging,
required String guardrailIdentifier,
required String name,
GuardrailAutomatedReasoningPolicyConfig? automatedReasoningPolicyConfig,
GuardrailContentPolicyConfig? contentPolicyConfig,
GuardrailContextualGroundingPolicyConfig? contextualGroundingPolicyConfig,
GuardrailCrossRegionConfig? crossRegionConfig,
String? description,
String? kmsKeyId,
GuardrailSensitiveInformationPolicyConfig? sensitiveInformationPolicyConfig,
GuardrailTopicPolicyConfig? topicPolicyConfig,
GuardrailWordPolicyConfig? wordPolicyConfig,
}) async {
final $payload = <String, dynamic>{
'blockedInputMessaging': blockedInputMessaging,
'blockedOutputsMessaging': blockedOutputsMessaging,
'name': name,
if (automatedReasoningPolicyConfig != null)
'automatedReasoningPolicyConfig': automatedReasoningPolicyConfig,
if (contentPolicyConfig != null)
'contentPolicyConfig': contentPolicyConfig,
if (contextualGroundingPolicyConfig != null)
'contextualGroundingPolicyConfig': contextualGroundingPolicyConfig,
if (crossRegionConfig != null) 'crossRegionConfig': crossRegionConfig,
if (description != null) 'description': description,
if (kmsKeyId != null) 'kmsKeyId': kmsKeyId,
if (sensitiveInformationPolicyConfig != null)
'sensitiveInformationPolicyConfig': sensitiveInformationPolicyConfig,
if (topicPolicyConfig != null) 'topicPolicyConfig': topicPolicyConfig,
if (wordPolicyConfig != null) 'wordPolicyConfig': wordPolicyConfig,
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri: '/guardrails/${Uri.encodeComponent(guardrailIdentifier)}',
exceptionFnMap: _exceptionFns,
);
return UpdateGuardrailResponse.fromJson(response);
}