CustomTopicProps

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

Bases: object

(experimental) Interface for creating a custom Topic.

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

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

Attributes

definition

(experimental) Provide a clear definition to detect and block user inputs and FM responses that fall into this topic.

Avoid starting with “don’t”.

Stability:

experimental

Example:

"""Investment advice refers to inquiries, guidance, or recommendations
regarding the management or allocation of funds or assets with the goal of
generating returns or achieving specific financial objectives."""
examples

(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.

Stability:

experimental

Example:

"Where should I invest my money?"
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