Skip to content

create_automated_reasoning_policy

create_automated_reasoning_policy(
    name: AutomatedReasoningPolicyName,
    *,
    config_overrides: Optional[BedrockClientConfig] = None,
    description: Optional[AutomatedReasoningPolicyDescription] = None,
    client_request_token: Optional[IdempotencyToken] = None,
    policy_definition: Optional[AutomatedReasoningPolicyDefinition] = None,
    kms_key_id: Optional[KmsKeyId] = None,
    tags: Optional[TagList] = None,
) -> CreateAutomatedReasoningPolicyResponse

Creates an Automated Reasoning policy for Amazon Bedrock Guardrails. Automated Reasoning policies use mathematical techniques to detect hallucinations, suggest corrections, and highlight unstated assumptions in the responses of your GenAI application.

To create a policy, you upload a source document that describes the rules that you're encoding. Automated Reasoning extracts important concepts from the source document that will become variables in the policy and infers policy rules.

Parameters:

  • name (AutomatedReasoningPolicyName) –

    A unique name for the Automated Reasoning policy. The name must be between 1 and 63 characters and can contain letters, numbers, hyphens, and underscores.

  • description (Optional[AutomatedReasoningPolicyDescription], default: None ) –

    A description of the Automated Reasoning policy. Use this to provide context about the policy's purpose and the types of validations it performs.

  • client_request_token (Optional[IdempotencyToken], default: None ) –

    A unique, case-sensitive identifier to ensure that the operation completes no more than once. If this token matches a previous request, Amazon Bedrock ignores the request but doesn't return an error.

  • policy_definition (Optional[AutomatedReasoningPolicyDefinition], default: None ) –

    The policy definition that contains the formal logic rules, variables, and custom variable types used to validate foundation model responses in your application.

  • kms_key_id (Optional[KmsKeyId], default: None ) –

    The identifier of the KMS key to use for encrypting the automated reasoning policy and its associated artifacts. If you don't specify a KMS key, Amazon Bedrock uses an KMS managed key for encryption. For enhanced security and control, you can specify a customer managed KMS key.

  • tags (Optional[TagList], default: None ) –

    A list of tags to associate with the Automated Reasoning policy. Tags help you organize and manage your policies.

Raises:

  • AccessDeniedException –

    The request is denied because of missing access permissions.

  • ConflictException –

    Error occurred because of a conflict while performing an operation.

  • InternalServerException –

    An internal server error occurred. Retry your request.

  • ResourceNotFoundException –

    The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.

  • ServiceQuotaExceededException –

    The number of requests exceeds the service quota. Resubmit your request later.

  • ThrottlingException –

    The number of requests exceeds the limit. Resubmit your request later.

  • TooManyTagsException –

    The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request.

  • ValidationException –

    Input validation failed. Check your request parameters and retry the request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_bedrock/_services/bedrock.py
def create_automated_reasoning_policy(
    self,
    name: "capo_bedrock.types.automated_reasoning_policy_name.AutomatedReasoningPolicyName",
    *,
    config_overrides: Optional[BedrockClientConfig] = None,
    description: Optional[
        "capo_bedrock.types.automated_reasoning_policy_description.AutomatedReasoningPolicyDescription"
    ] = None,
    client_request_token: Optional[
        "capo_bedrock.types.idempotency_token.IdempotencyToken"
    ] = None,
    policy_definition: Optional[
        "capo_bedrock.types.automated_reasoning_policy_definition.AutomatedReasoningPolicyDefinition"
    ] = None,
    kms_key_id: Optional["capo_bedrock.types.kms_key_id.KmsKeyId"] = None,
    tags: Optional["capo_bedrock.types.tag_list.TagList"] = None,
) -> "capo_bedrock.types.create_automated_reasoning_policy_response.CreateAutomatedReasoningPolicyResponse":
    """<p>Creates an Automated Reasoning policy for Amazon Bedrock Guardrails. Automated Reasoning policies use mathematical techniques to detect hallucinations, suggest corrections, and highlight unstated assumptions in the responses of your GenAI application.</p> <p>To create a policy, you upload a source document that describes the rules that you're encoding. Automated Reasoning extracts important concepts from the source document that will become variables in the policy and infers policy rules.</p>

    Args:
        name: <p>A unique name for the Automated Reasoning policy. The name must be between 1 and 63 characters and can contain letters, numbers, hyphens, and underscores.</p>
        description: <p>A description of the Automated Reasoning policy. Use this to provide context about the policy's purpose and the types of validations it performs.</p>
        client_request_token: <p>A unique, case-sensitive identifier to ensure that the operation completes no more than once. If this token matches a previous request, Amazon Bedrock ignores the request but doesn't return an error.</p>
        policy_definition: <p>The policy definition that contains the formal logic rules, variables, and custom variable types used to validate foundation model responses in your application.</p>
        kms_key_id: <p>The identifier of the KMS key to use for encrypting the automated reasoning policy and its associated artifacts. If you don't specify a KMS key, Amazon Bedrock uses an KMS managed key for encryption. For enhanced security and control, you can specify a customer managed KMS key.</p>
        tags: <p>A list of tags to associate with the Automated Reasoning policy. Tags help you organize and manage your policies.</p>

    Raises:
        capo_bedrock.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock.errors.conflict_exception.ConflictException: <p>Error occurred because of a conflict while performing an operation.</p>
        capo_bedrock.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_bedrock.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
        capo_bedrock.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The number of requests exceeds the service quota. Resubmit your request later.</p>
        capo_bedrock.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_bedrock.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request. </p>
        capo_bedrock.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
        capo_bedrock.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock.types.create_automated_reasoning_policy_request.CreateAutomatedReasoningPolicyRequest]",
    ) -> OperationResponse[
        "capo_bedrock.types.create_automated_reasoning_policy_response.CreateAutomatedReasoningPolicyResponse"
    ]:
        import capo_bedrock._operations.amazon_bedrock_control_plane_service.create_automated_reasoning_policy

        output, http_response = (
            capo_bedrock._operations.amazon_bedrock_control_plane_service.create_automated_reasoning_policy.create_automated_reasoning_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock.types.create_automated_reasoning_policy_request.CreateAutomatedReasoningPolicyRequest",
    ) -> dict[str, Any]:
        import capo_bedrock.types.create_automated_reasoning_policy_request

        return capo_bedrock.types.create_automated_reasoning_policy_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock.types.create_automated_reasoning_policy_response.CreateAutomatedReasoningPolicyResponse",
    ) -> dict[str, Any]:
        import capo_bedrock.types.create_automated_reasoning_policy_response

        return capo_bedrock.types.create_automated_reasoning_policy_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateAutomatedReasoningPolicy",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock.types.create_automated_reasoning_policy_request.CreateAutomatedReasoningPolicyRequest = {
        "name": name
    }
    if description is not None:
        input_["description"] = description
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if policy_definition is not None:
        input_["policy_definition"] = policy_definition
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output