mellea.stdlib.safety.guardian
class mellea.stdlib.safety.guardian.GuardianRisk()
class mellea.stdlib.safety.guardian.GuardianCheck(risk: str = GuardianRisk.HARM, model_version: str = 'ibm-granite/granite-guardian-3.2-3b-a800m', device: str | None = None)
risk
: The risk definition to check for, defaults to GuardianRisk.HARM.model_version
: The version of the model, defaults to “ibm-granite/granite-guardian-3.2-3b-a800m”.device
: The computational device to use (“cuda” for GPU, “mps” for Apple Silicon, or “cpu”), defaults to None. If not specified, the best available device will be automatically selected.mellea.stdlib.safety.guardian.GuardianCheck._parse_output(output, input_len, tokenizer)
output
: The model’s output containing sequences from which predictions are made.input_len
: The length of the original input sequence used for alignment with the model’s output.tokenizer
: The tokenizer associated with the model, used to decode the tokens back into text.mellea.stdlib.safety.guardian.GuardianCheck._guardian_validate(ctx: Context)
ctx
: Context
: The context object containing the last turn of the conversation.bool
: True if there is no identified risk, False otherwise.