ContentFilter
- class aws_cdk.aws_bedrock_alpha.ContentFilter(*, input_strength, output_strength, type, input_action=None, input_enabled=None, input_modalities=None, output_action=None, output_enabled=None, output_modalities=None)
Bases:
object(experimental) Interface to declare a content filter.
- Parameters:
input_strength (
ContentFilterStrength) – (experimental) The strength of the content filter to apply to prompts / user input.output_strength (
ContentFilterStrength) – (experimental) The strength of the content filter to apply to model responses.type (
ContentFilterType) – (experimental) The type of harmful category that the content filter is applied to.input_action (
Optional[GuardrailAction]) – (experimental) The action to take when content is detected in the input. Default: GuardrailAction.BLOCKinput_enabled (
Optional[bool]) – (experimental) Whether the content filter is enabled for input. Default: trueinput_modalities (
Optional[Sequence[ModalityType]]) – (experimental) The input modalities to apply the content filter to. Default: undefined - Applies to text modalityoutput_action (
Optional[GuardrailAction]) – (experimental) The action to take when content is detected in the output. Default: GuardrailAction.BLOCKoutput_enabled (
Optional[bool]) – (experimental) Whether the content filter is enabled for output. Default: trueoutput_modalities (
Optional[Sequence[ModalityType]]) – (experimental) The output modalities to apply the content filter to. Default: undefined - Applies to text modality
- Stability:
experimental
- ExampleMetadata:
fixture=default infused
Example:
# Create a guardrail to filter inappropriate content guardrail = bedrock.Guardrail(self, "bedrockGuardrails", guardrail_name="my-BedrockGuardrails", description="Legal ethical guardrails." ) guardrail.add_content_filter( type=bedrock.ContentFilterType.SEXUAL, input_strength=bedrock.ContentFilterStrength.HIGH, output_strength=bedrock.ContentFilterStrength.MEDIUM ) # Create an agent with the guardrail agent_with_guardrail = bedrock.Agent(self, "AgentWithGuardrail", foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0, instruction="You are a helpful and friendly agent that answers questions about literature.", guardrail=guardrail )
Attributes
- input_action
(experimental) The action to take when content is detected in the input.
- Default:
GuardrailAction.BLOCK
- Stability:
experimental
- input_enabled
(experimental) Whether the content filter is enabled for input.
- Default:
true
- Stability:
experimental
- input_modalities
(experimental) The input modalities to apply the content filter to.
- Default:
undefined - Applies to text modality
- Stability:
experimental
- input_strength
(experimental) The strength of the content filter to apply to prompts / user input.
- Stability:
experimental
- output_action
(experimental) The action to take when content is detected in the output.
- Default:
GuardrailAction.BLOCK
- Stability:
experimental
- output_enabled
(experimental) Whether the content filter is enabled for output.
- Default:
true
- Stability:
experimental
- output_modalities
(experimental) The output modalities to apply the content filter to.
- Default:
undefined - Applies to text modality
- Stability:
experimental
- output_strength
(experimental) The strength of the content filter to apply to model responses.
- Stability:
experimental
- type
(experimental) The type of harmful category that the content filter is applied to.
- Stability:
experimental