updateGuardrail method

Future<UpdateGuardrailResponse> updateGuardrail({
  1. required String blockedInputMessaging,
  2. required String blockedOutputsMessaging,
  3. required String guardrailIdentifier,
  4. required String name,
  5. GuardrailAutomatedReasoningPolicyConfig? automatedReasoningPolicyConfig,
  6. GuardrailContentPolicyConfig? contentPolicyConfig,
  7. GuardrailContextualGroundingPolicyConfig? contextualGroundingPolicyConfig,
  8. GuardrailCrossRegionConfig? crossRegionConfig,
  9. String? description,
  10. String? kmsKeyId,
  11. GuardrailSensitiveInformationPolicyConfig? sensitiveInformationPolicyConfig,
  12. GuardrailTopicPolicyConfig? topicPolicyConfig,
  13. GuardrailWordPolicyConfig? wordPolicyConfig,
})

Updates a guardrail with the values you specify.

  • Specify a name and optional description.
  • Specify messages for when the guardrail successfully blocks a prompt or a model response in the blockedInputMessaging and blockedOutputsMessaging fields.
  • Specify topics for the guardrail to deny in the topicPolicyConfig object. Each GuardrailTopicConfig object in the topicsConfig list pertains to one topic.
    • Give a name and description so that the guardrail can properly identify the topic.
    • Specify DENY in the type field.
    • (Optional) Provide up to five prompts that you would categorize as belonging to the topic in the examples list.
  • Specify filter strengths for the harmful categories defined in Amazon Bedrock in the contentPolicyConfig object. Each GuardrailContentFilterConfig object in the filtersConfig list 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 type field.
    • Specify the strength of the filter for prompts in the inputStrength field and for model responses in the strength field of the GuardrailContentFilterConfig.
  • (Optional) For security, include the ARN of a KMS key in the kmsKeyId field.

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);
}