Topic

class aws_cdk.aws_bedrock_alpha.Topic(*, definition, examples, name, input_action=None, input_enabled=None, output_action=None, output_enabled=None)

Bases: object

(experimental) Represents predefined topics that can be used to filter content.

Stability:

experimental

ExampleMetadata:

fixture=default infused

Example:

guardrail = bedrock.Guardrail(self, "bedrockGuardrails",
    guardrail_name="my-BedrockGuardrails",
    # Configure tier for topic filters (optional)
    topics_tier_config=bedrock.TierConfig.STANDARD
)

# Use a predefined topic
guardrail.add_denied_topic_filter(bedrock.Topic.FINANCIAL_ADVICE)

# Create a custom topic with input/output actions
guardrail.add_denied_topic_filter(
    bedrock.Topic.custom(
        name="Legal_Advice",
        definition="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?"
        ],
        # props below are optional
        input_action=bedrock.GuardrailAction.BLOCK,
        input_enabled=True,
        output_action=bedrock.GuardrailAction.NONE,
        output_enabled=True
    ))
Parameters:
  • definition (str) – (experimental) Provide a clear definition to detect and block user inputs and FM responses that fall into this topic. Avoid starting with “don’t”.

  • examples (Sequence[str]) – (experimental) Representative phrases that refer to the topic. These phrases can represent a user input or a model response. Add between 1 and 100 phrases, up to 100 characters each.

  • name (str) – (experimental) The name of the topic to deny.

  • input_action (Optional[GuardrailAction]) – (experimental) The action to take when a topic is detected in the input. Default: GuardrailAction.BLOCK

  • input_enabled (Optional[bool]) – (experimental) Whether the topic filter is enabled for input. Default: true

  • output_action (Optional[GuardrailAction]) – (experimental) The action to take when a topic is detected in the output. Default: GuardrailAction.BLOCK

  • output_enabled (Optional[bool]) – (experimental) Whether the topic filter is enabled for output. Default: true

Stability:

experimental

Attributes

FINANCIAL_ADVICE = <aws_cdk.aws_bedrock_alpha.Topic object>
INAPPROPRIATE_CONTENT = <aws_cdk.aws_bedrock_alpha.Topic object>
LEGAL_ADVICE = <aws_cdk.aws_bedrock_alpha.Topic object>
MEDICAL_ADVICE = <aws_cdk.aws_bedrock_alpha.Topic object>
POLITICAL_ADVICE = <aws_cdk.aws_bedrock_alpha.Topic object>
definition

(experimental) Definition of the topic.

Stability:

experimental

examples

(experimental) Representative phrases that refer to the topic.

Stability:

experimental

input_action

(experimental) The action to take when a topic is detected in the input.

Default:

GuardrailAction.BLOCK

Stability:

experimental

input_enabled

(experimental) Whether the topic filter is enabled for input.

Default:

true

Stability:

experimental

name

(experimental) The name of the topic to deny.

Stability:

experimental

output_action

(experimental) The action to take when a topic is detected in the output.

Default:

GuardrailAction.BLOCK

Stability:

experimental

output_enabled

(experimental) Whether the topic filter is enabled for output.

Default:

true

Stability:

experimental

Static Methods

classmethod custom(*, definition, examples, name, input_action=None, input_enabled=None, output_action=None, output_enabled=None)

(experimental) Create a custom topic filter.

Parameters:
  • definition (str) – (experimental) Provide a clear definition to detect and block user inputs and FM responses that fall into this topic. Avoid starting with “don’t”.

  • examples (Sequence[str]) – (experimental) Representative phrases that refer to the topic. These phrases can represent a user input or a model response. Add between 1 and 100 phrases, up to 100 characters each.

  • name (str) – (experimental) The name of the topic to deny.

  • input_action (Optional[GuardrailAction]) – (experimental) The action to take when a topic is detected in the input. Default: GuardrailAction.BLOCK

  • input_enabled (Optional[bool]) – (experimental) Whether the topic filter is enabled for input. Default: true

  • output_action (Optional[GuardrailAction]) – (experimental) The action to take when a topic is detected in the output. Default: GuardrailAction.BLOCK

  • output_enabled (Optional[bool]) – (experimental) Whether the topic filter is enabled for output. Default: true

Stability:

experimental

Return type:

Topic