SafetyThreshold enum
An enumeration representing various safety thresholds for content moderation. Each threshold defines a level of risk associated with potentially unsafe content, dictating whether content should be blocked or flagged based on its probability of being harmful.
Enum Values:
blockNone
: Content is always shown, regardless of the probability of unsafe content.blockOnlyHigh
: Content is blocked only if there is a high probability of unsafe content.blockMediumAndAbove
: Content is blocked if there is a medium or high probability of unsafe content.blockLowAndAbove
: Content is blocked if there is a low, medium, or high probability of unsafe content.harmBlockThresholdUnspecified
: The threshold is unspecified, and the system uses a default block threshold.
Usage:
The SafetyThreshold
enum is used to configure how strict the moderation system should be when evaluating content. Depending on the chosen threshold, content with varying levels of unsafe probability can be blocked or allowed.
Example:
var safetySetting = SafetySetting(
category: SafetyCategory.dangerous, // Flag dangerous content.
threshold: SafetyThreshold.blockMediumAndAbove, // Block if content has medium or high risk.
);
Values
- blockNone → const SafetyThreshold
-
blockNone Always show regardless of probability of unsafe content
const SafetyThreshold('BLOCK_NONE')
- blockOnlyHigh → const SafetyThreshold
-
blockOnlyHigh Block when high probability of unsafe content
const SafetyThreshold('BLOCK_ONLY_HIGH')
- blockMediumAndAbove → const SafetyThreshold
-
blockMediumAndAbove Block when medium or high probability of unsafe content
const SafetyThreshold('BLOCK_MEDIUM_AND_ABOVE')
- blockLowAndAbove → const SafetyThreshold
-
blockLowAndAbove Block when low, medium or high probability of unsafe content
const SafetyThreshold('BLOCK_LOW_AND_ABOVE')
- harmBlockThresholdUnspecified → const SafetyThreshold
-
harmBlockThresholdUnspecified Threshold is unspecified, block using default threshold
const SafetyThreshold('HARM_BLOCK_THRESHOLD_UNSPECIFIED')
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String
-
The string value that represents the safety threshold for backend processing or API use.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
SafetyThreshold> - A constant List of the values in this enum, in order of their declaration.