Expand description
Input guardrails: local heuristic screening of chat input for prompt-injection / jailbreak patterns and obvious secrets/PII, run before the LLM call.
This is a first-line, dependency-free signal — substring matching for injection phrases and shaped scans for secrets/PII. It is intentionally conservative (accepts false negatives) and never echoes the matched value; findings carry only a category and a short label.
The InputScreen trait allows replacing or supplementing the built-in
heuristic with a classifier-based screen (e.g. an LLM judge). Callers use
screen_input for the built-in heuristic or compose screens via
ChainedScreen.
Structs§
- Chained
Screen - Chains multiple screens, returning the first finding from any screen.
Screens are evaluated in order; the first non-
Noneresult wins. - Guardrail
Finding - A guardrail finding: the category and a short, content-free reason label.
- Heuristic
Screen - The built-in heuristic screen (substring + shaped scans). This is the default screen used when no custom screen is configured.
Enums§
- Guardrail
Category - Category of a guardrail finding.
Traits§
- Input
Screen - Pluggable input screen interface. Implement this to replace or supplement the built-in heuristic with a classifier-based screen (e.g. an LLM judge).
Functions§
- screen_
input - Screen chat input. Returns the first finding (injection takes precedence over
PII), or
Nonewhen screening is disabled or the input is clean.