toxicity#

enkrypt.toxicity(*, on_violation="block", on_error="block")

Flags hateful, harassing, violent or otherwise toxic text.

Allowed actions

raise, block, retry, audit

Default action

block

Enkrypt detector

toxicity

Enkrypt reports which kinds of toxicity it found; they appear in the guard’s message and in the full response on a raised exception.

Where to use it#

  • On the answer, so the agent never says something toxic. retry asks the model to answer again rather than failing the run:

    OutputGuardrail(guard=[enkrypt.toxicity(on_violation="retry")])
    
  • On the prompt, to refuse abusive input before spending a model call on it:

    InputGuardrail(guard=[enkrypt.toxicity()])
    

On the answer, block raises OutputBlocked; see Actions.

Reference#

pydantic_ai_enkrypt.Enkrypt.toxicity()