Class: AWSCDK::Bedrock::CfnGuardrail::ContentFilterConfigProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
bedrock/cfn_guardrail.rb

Overview

Contains filter strengths for harmful content.

Guardrails support the following content filters to detect and filter harmful user inputs and FM-generated outputs.

  • Hate – Describes language or a statement that discriminates, criticizes, insults, denounces, or dehumanizes a person or group on the basis of an identity (such as race, ethnicity, gender, religion, sexual orientation, ability, and national origin).
  • Insults – Describes language or a statement that includes demeaning, humiliating, mocking, insulting, or belittling language. This type of language is also labeled as bullying.
  • Sexual – Describes language or a statement that indicates sexual interest, activity, or arousal using direct or indirect references to body parts, physical traits, or sex.
  • Violence – Describes language or a statement that includes glorification of or threats to inflict physical pain, hurt, or injury toward a person, group or thing.

Content filtering depends on the confidence classification of user inputs and FM responses across each of the four harmful categories. All input and output statements are classified into one of four confidence levels (NONE, LOW, MEDIUM, HIGH) for each harmful category. For example, if a statement is classified as Hate with HIGH confidence, the likelihood of the statement representing hateful content is high. A single statement can be classified across multiple categories with varying confidence levels. For example, a single statement can be classified as Hate with HIGH confidence, Insults with LOW confidence, Sexual with NONE confidence, and Violence with MEDIUM confidence.

For more information, see Guardrails content filters .

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_strength:, output_strength:, type:, input_action: nil, input_enabled: nil, input_modalities: nil, output_action: nil, output_enabled: nil, output_modalities: nil) ⇒ ContentFilterConfigProperty

Returns a new instance of ContentFilterConfigProperty.

Parameters:

  • input_strength (String)

    The strength of the content filter to apply to prompts.

  • output_strength (String)

    The strength of the content filter to apply to model responses.

  • type (String)

    The harmful category that the content filter is applied to.

  • input_action (String, nil) (defaults to: nil)

    Specifies the action to take when harmful content is detected. Supported values include:.

  • input_enabled (Boolean, AWSCDK::IResolvable, nil) (defaults to: nil)

    Specifies whether to enable guardrail evaluation on the input.

  • input_modalities (Array<String>, nil) (defaults to: nil)

    The input modalities selected for the guardrail content filter configuration.

  • output_action (String, nil) (defaults to: nil)

    Specifies the action to take when harmful content is detected in the output. Supported values include:.

  • output_enabled (Boolean, AWSCDK::IResolvable, nil) (defaults to: nil)

    Specifies whether to enable guardrail evaluation on the output.

  • output_modalities (Array<String>, nil) (defaults to: nil)

    The output modalities selected for the guardrail content filter configuration.



816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
# File 'bedrock/cfn_guardrail.rb', line 816

def initialize(input_strength:, output_strength:, type:, input_action: nil, input_enabled: nil, input_modalities: nil, output_action: nil, output_enabled: nil, output_modalities: nil)
  @input_strength = input_strength
  Jsii::Type.check_type(@input_strength, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "inputStrength")
  @output_strength = output_strength
  Jsii::Type.check_type(@output_strength, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "outputStrength")
  @type = type
  Jsii::Type.check_type(@type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "type")
  @input_action = input_action
  Jsii::Type.check_type(@input_action, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "inputAction") unless @input_action.nil?
  @input_enabled = input_enabled
  Jsii::Type.check_type(@input_enabled, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoiYm9vbGVhbiJ9LHsiZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifV19fQ==")), "inputEnabled") unless @input_enabled.nil?
  @input_modalities = input_modalities
  Jsii::Type.check_type(@input_modalities, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "inputModalities") unless @input_modalities.nil?
  @output_action = output_action
  Jsii::Type.check_type(@output_action, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "outputAction") unless @output_action.nil?
  @output_enabled = output_enabled
  Jsii::Type.check_type(@output_enabled, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoiYm9vbGVhbiJ9LHsiZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifV19fQ==")), "outputEnabled") unless @output_enabled.nil?
  @output_modalities = output_modalities
  Jsii::Type.check_type(@output_modalities, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "outputModalities") unless @output_modalities.nil?
end

Instance Attribute Details

#input_actionString? (readonly)

Specifies the action to take when harmful content is detected. Supported values include:.

  • BLOCK – Block the content and replace it with blocked messaging.
  • NONE – Take no action but return detection information in the trace response.


863
864
865
# File 'bedrock/cfn_guardrail.rb', line 863

def input_action
  @input_action
end

#input_enabledBoolean, ... (readonly)

Specifies whether to enable guardrail evaluation on the input.

When disabled, you aren't charged for the evaluation. The evaluation doesn't appear in the response.



870
871
872
# File 'bedrock/cfn_guardrail.rb', line 870

def input_enabled
  @input_enabled
end

#input_modalitiesArray<String>? (readonly)

The input modalities selected for the guardrail content filter configuration.



875
876
877
# File 'bedrock/cfn_guardrail.rb', line 875

def input_modalities
  @input_modalities
end

#input_strengthString (readonly)

The strength of the content filter to apply to prompts.

As you increase the filter strength, the likelihood of filtering harmful content increases and the probability of seeing harmful content in your application reduces.



843
844
845
# File 'bedrock/cfn_guardrail.rb', line 843

def input_strength
  @input_strength
end

#output_actionString? (readonly)

Specifies the action to take when harmful content is detected in the output. Supported values include:.

  • BLOCK – Block the content and replace it with blocked messaging.
  • NONE – Take no action but return detection information in the trace response.


883
884
885
# File 'bedrock/cfn_guardrail.rb', line 883

def output_action
  @output_action
end

#output_enabledBoolean, ... (readonly)

Specifies whether to enable guardrail evaluation on the output.

When disabled, you aren't charged for the evaluation. The evaluation doesn't appear in the response.



890
891
892
# File 'bedrock/cfn_guardrail.rb', line 890

def output_enabled
  @output_enabled
end

#output_modalitiesArray<String>? (readonly)

The output modalities selected for the guardrail content filter configuration.



895
896
897
# File 'bedrock/cfn_guardrail.rb', line 895

def output_modalities
  @output_modalities
end

#output_strengthString (readonly)

The strength of the content filter to apply to model responses.

As you increase the filter strength, the likelihood of filtering harmful content increases and the probability of seeing harmful content in your application reduces.



850
851
852
# File 'bedrock/cfn_guardrail.rb', line 850

def output_strength
  @output_strength
end

#typeString (readonly)

The harmful category that the content filter is applied to.



855
856
857
# File 'bedrock/cfn_guardrail.rb', line 855

def type
  @type
end

Class Method Details

.jsii_propertiesObject



897
898
899
900
901
902
903
904
905
906
907
908
909
# File 'bedrock/cfn_guardrail.rb', line 897

def self.jsii_properties
  {
    :input_strength => "inputStrength",
    :output_strength => "outputStrength",
    :type => "type",
    :input_action => "inputAction",
    :input_enabled => "inputEnabled",
    :input_modalities => "inputModalities",
    :output_action => "outputAction",
    :output_enabled => "outputEnabled",
    :output_modalities => "outputModalities",
  }
end

Instance Method Details

#to_jsiiObject



911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
# File 'bedrock/cfn_guardrail.rb', line 911

def to_jsii
  result = {}
  result.merge!({
    "inputStrength" => @input_strength,
    "outputStrength" => @output_strength,
    "type" => @type,
    "inputAction" => @input_action,
    "inputEnabled" => @input_enabled,
    "inputModalities" => @input_modalities,
    "outputAction" => @output_action,
    "outputEnabled" => @output_enabled,
    "outputModalities" => @output_modalities,
  })
  result.compact
end