safety
default_safety_rules
module-attribute
default_safety_rules = SafetyRules(
should_censor_nsfw=True,
should_censor_hate_speech=True,
should_censor_violent=True,
should_censor_self_harm=True,
)
default_image_safety_rules
module-attribute
default_image_safety_rules = SafetyRules(
should_censor_nsfw=True,
should_censor_hate_speech=True,
should_censor_violent=True,
should_censor_self_harm=True,
)
default_text_safety_rules
module-attribute
default_text_safety_rules = SafetyRules(
should_censor_nsfw=True,
should_censor_hate_speech=True,
should_censor_violent=True,
should_censor_self_harm=True,
)
SafetyResult
Bases: BaseModel
A model representing the result of a safety check.
Source code in horde_sdk/safety.py
nsfw_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is NSFW, typically between 0.0 and 1.0.
is_csam
class-attribute
instance-attribute
Indicates if the content is CSAM.
csam_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is CSAM, typically between 0.0 and 1.0.
is_hate_speech
class-attribute
instance-attribute
Indicates if the content is hate speech.
hate_speech_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is hate speech, typically between 0.0 and 1.0.
is_violent
class-attribute
instance-attribute
Indicates if the content is violent.
violent_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is violent, typically between 0.0 and 1.0.
is_self_harm
class-attribute
instance-attribute
Indicates if the content promotes self-harm.
TextSafetyResult
Bases: SafetyResult
A model representing the result of a text safety check.
Source code in horde_sdk/safety.py
nsfw_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is NSFW, typically between 0.0 and 1.0.
is_csam
class-attribute
instance-attribute
Indicates if the content is CSAM.
csam_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is CSAM, typically between 0.0 and 1.0.
is_hate_speech
class-attribute
instance-attribute
Indicates if the content is hate speech.
hate_speech_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is hate speech, typically between 0.0 and 1.0.
is_violent
class-attribute
instance-attribute
Indicates if the content is violent.
violent_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is violent, typically between 0.0 and 1.0.
is_self_harm
class-attribute
instance-attribute
Indicates if the content promotes self-harm.
ImageSafetyResult
Bases: SafetyResult
A model representing the result of an image safety check.
Source code in horde_sdk/safety.py
nsfw_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is NSFW, typically between 0.0 and 1.0.
csam_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is CSAM, typically between 0.0 and 1.0.
is_hate_speech
class-attribute
instance-attribute
Indicates if the content is hate speech.
hate_speech_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is hate speech, typically between 0.0 and 1.0.
is_violent
class-attribute
instance-attribute
Indicates if the content is violent.
violent_likelihood
class-attribute
instance-attribute
A float representing the likelihood that the content is violent, typically between 0.0 and 1.0.
is_self_harm
class-attribute
instance-attribute
Indicates if the content promotes self-harm.
SafetyRules
A class representing the rules for content safety checks.
Source code in horde_sdk/safety.py
should_censor_nsfw
class-attribute
instance-attribute
Indicates whether NSFW content should be censored.
should_censor_hate_speech
class-attribute
instance-attribute
Indicates whether hate speech content should be censored.
should_censor_violent
class-attribute
instance-attribute
Indicates whether violent content should be censored.
should_censor_self_harm
class-attribute
instance-attribute
Indicates whether self-harm content should be censored.
should_censor
Determine if the content should be censored based on the safety result.
Parameters:
-
safety_result(SafetyResult) –The result of the safety check.
Returns:
-
bool(bool) –True if the content should be censored, False otherwise.
Source code in horde_sdk/safety.py
__init__
__init__(
should_censor_nsfw: bool = True,
should_censor_hate_speech: bool = True,
should_censor_violent: bool = True,
should_censor_self_harm: bool = True,
) -> None
Initialize the SafetyRules with optional parameters to set censorship preferences.
Args: should_censor_nsfw (bool): Whether to censor NSFW content. Defaults to True. should_censor_hate_speech (bool): Whether to censor hate speech content. Defaults to True. should_censor_violent (bool): Whether to censor violent content. Defaults to True. should_censor_self_harm (bool): Whether to censor self-harm content. Defaults to True.