Class GuardrailContentFilter
- java.lang.Object
-
- software.amazon.awssdk.services.bedrock.model.GuardrailContentFilter
-
- All Implemented Interfaces:
Serializable,SdkPojo,ToCopyableBuilder<GuardrailContentFilter.Builder,GuardrailContentFilter>
@Generated("software.amazon.awssdk:codegen") public final class GuardrailContentFilter extends Object implements SdkPojo, Serializable, ToCopyableBuilder<GuardrailContentFilter.Builder,GuardrailContentFilter>
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.
This data type is used in the following API operations:
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGuardrailContentFilter.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GuardrailContentFilter.Builderbuilder()booleanequals(Object obj)booleanequalsBySdkFields(Object obj)<T> Optional<T>getValueForField(String fieldName, Class<T> clazz)inthashCode()booleanhasInputModalities()For responses, this returns true if the service returned a value for the InputModalities property.booleanhasOutputModalities()For responses, this returns true if the service returned a value for the OutputModalities property.GuardrailContentFilterActioninputAction()The action to take when harmful content is detected in the input.StringinputActionAsString()The action to take when harmful content is detected in the input.BooleaninputEnabled()Indicates whether guardrail evaluation is enabled on the input.List<GuardrailModality>inputModalities()The input modalities selected for the guardrail content filter.List<String>inputModalitiesAsStrings()The input modalities selected for the guardrail content filter.GuardrailFilterStrengthinputStrength()The strength of the content filter to apply to prompts.StringinputStrengthAsString()The strength of the content filter to apply to prompts.GuardrailContentFilterActionoutputAction()The action to take when harmful content is detected in the output.StringoutputActionAsString()The action to take when harmful content is detected in the output.BooleanoutputEnabled()Indicates whether guardrail evaluation is enabled on the output.List<GuardrailModality>outputModalities()The output modalities selected for the guardrail content filter.List<String>outputModalitiesAsStrings()The output modalities selected for the guardrail content filter.GuardrailFilterStrengthoutputStrength()The strength of the content filter to apply to model responses.StringoutputStrengthAsString()The strength of the content filter to apply to model responses.Map<String,SdkField<?>>sdkFieldNameToField()List<SdkField<?>>sdkFields()static Class<? extends GuardrailContentFilter.Builder>serializableBuilderClass()GuardrailContentFilter.BuildertoBuilder()StringtoString()Returns a string representation of this object.GuardrailContentFilterTypetype()The harmful category that the content filter is applied to.StringtypeAsString()The harmful category that the content filter is applied to.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.utils.builder.ToCopyableBuilder
copy
-
-
-
-
Method Detail
-
type
public final GuardrailContentFilterType type()
The harmful category that the content filter is applied to.
If the service returns an enum value that is not available in the current SDK version,
typewill returnGuardrailContentFilterType.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available fromtypeAsString().- Returns:
- The harmful category that the content filter is applied to.
- See Also:
GuardrailContentFilterType
-
typeAsString
public final String typeAsString()
The harmful category that the content filter is applied to.
If the service returns an enum value that is not available in the current SDK version,
typewill returnGuardrailContentFilterType.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available fromtypeAsString().- Returns:
- The harmful category that the content filter is applied to.
- See Also:
GuardrailContentFilterType
-
inputStrength
public final GuardrailFilterStrength inputStrength()
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.
If the service returns an enum value that is not available in the current SDK version,
inputStrengthwill returnGuardrailFilterStrength.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available frominputStrengthAsString().- Returns:
- 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.
- See Also:
GuardrailFilterStrength
-
inputStrengthAsString
public final String inputStrengthAsString()
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.
If the service returns an enum value that is not available in the current SDK version,
inputStrengthwill returnGuardrailFilterStrength.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available frominputStrengthAsString().- Returns:
- 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.
- See Also:
GuardrailFilterStrength
-
outputStrength
public final GuardrailFilterStrength outputStrength()
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.
If the service returns an enum value that is not available in the current SDK version,
outputStrengthwill returnGuardrailFilterStrength.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available fromoutputStrengthAsString().- Returns:
- 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.
- See Also:
GuardrailFilterStrength
-
outputStrengthAsString
public final String outputStrengthAsString()
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.
If the service returns an enum value that is not available in the current SDK version,
outputStrengthwill returnGuardrailFilterStrength.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available fromoutputStrengthAsString().- Returns:
- 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.
- See Also:
GuardrailFilterStrength
-
inputModalities
public final List<GuardrailModality> inputModalities()
The input modalities selected for the guardrail content filter.
Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the
hasInputModalities()method.- Returns:
- The input modalities selected for the guardrail content filter.
-
hasInputModalities
public final boolean hasInputModalities()
For responses, this returns true if the service returned a value for the InputModalities property. This DOES NOT check that the value is non-empty (for which, you should check theisEmpty()method on the property). This is useful because the SDK will never return a null collection or map, but you may need to differentiate between the service returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true if a value for the property was specified in the request builder, and false if a value was not specified.
-
inputModalitiesAsStrings
public final List<String> inputModalitiesAsStrings()
The input modalities selected for the guardrail content filter.
Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the
hasInputModalities()method.- Returns:
- The input modalities selected for the guardrail content filter.
-
outputModalities
public final List<GuardrailModality> outputModalities()
The output modalities selected for the guardrail content filter.
Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the
hasOutputModalities()method.- Returns:
- The output modalities selected for the guardrail content filter.
-
hasOutputModalities
public final boolean hasOutputModalities()
For responses, this returns true if the service returned a value for the OutputModalities property. This DOES NOT check that the value is non-empty (for which, you should check theisEmpty()method on the property). This is useful because the SDK will never return a null collection or map, but you may need to differentiate between the service returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true if a value for the property was specified in the request builder, and false if a value was not specified.
-
outputModalitiesAsStrings
public final List<String> outputModalitiesAsStrings()
The output modalities selected for the guardrail content filter.
Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the
hasOutputModalities()method.- Returns:
- The output modalities selected for the guardrail content filter.
-
inputAction
public final GuardrailContentFilterAction inputAction()
The action to take when harmful content is detected in the input. 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.
If the service returns an enum value that is not available in the current SDK version,
inputActionwill returnGuardrailContentFilterAction.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available frominputActionAsString().- Returns:
- The action to take when harmful content is detected in the input. 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.
-
- See Also:
GuardrailContentFilterAction
-
-
inputActionAsString
public final String inputActionAsString()
The action to take when harmful content is detected in the input. 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.
If the service returns an enum value that is not available in the current SDK version,
inputActionwill returnGuardrailContentFilterAction.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available frominputActionAsString().- Returns:
- The action to take when harmful content is detected in the input. 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.
-
- See Also:
GuardrailContentFilterAction
-
-
outputAction
public final GuardrailContentFilterAction outputAction()
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.
If the service returns an enum value that is not available in the current SDK version,
outputActionwill returnGuardrailContentFilterAction.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available fromoutputActionAsString().- Returns:
- 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.
-
- See Also:
GuardrailContentFilterAction
-
-
outputActionAsString
public final String outputActionAsString()
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.
If the service returns an enum value that is not available in the current SDK version,
outputActionwill returnGuardrailContentFilterAction.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available fromoutputActionAsString().- Returns:
- 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.
-
- See Also:
GuardrailContentFilterAction
-
-
inputEnabled
public final Boolean inputEnabled()
Indicates whether guardrail evaluation is enabled on the input. When disabled, you aren't charged for the evaluation. The evaluation doesn't appear in the response.
- Returns:
- Indicates whether guardrail evaluation is enabled on the input. When disabled, you aren't charged for the evaluation. The evaluation doesn't appear in the response.
-
outputEnabled
public final Boolean outputEnabled()
Indicates whether guardrail evaluation is enabled on the output. When disabled, you aren't charged for the evaluation. The evaluation doesn't appear in the response.
- Returns:
- Indicates whether guardrail evaluation is enabled on the output. When disabled, you aren't charged for the evaluation. The evaluation doesn't appear in the response.
-
toBuilder
public GuardrailContentFilter.Builder toBuilder()
- Specified by:
toBuilderin interfaceToCopyableBuilder<GuardrailContentFilter.Builder,GuardrailContentFilter>
-
builder
public static GuardrailContentFilter.Builder builder()
-
serializableBuilderClass
public static Class<? extends GuardrailContentFilter.Builder> serializableBuilderClass()
-
equalsBySdkFields
public final boolean equalsBySdkFields(Object obj)
- Specified by:
equalsBySdkFieldsin interfaceSdkPojo
-
toString
public final String toString()
Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be redacted from this string using a placeholder value.
-
sdkFieldNameToField
public final Map<String,SdkField<?>> sdkFieldNameToField()
- Specified by:
sdkFieldNameToFieldin interfaceSdkPojo
-
-