Guard

A configured guardrail ready to be attached to a ChatBot.

Usage

Source

Guard()

Parameter Attributes

name: str
func: Callable[[str], GuardResult]
phase: GuardPhase = GuardPhase.BOTH
states: list[str] | None = None

Attributes

name: str

Human-readable guard name (used in telemetry and error messages).

func: Callable[[str], GuardResult]

The guard function: takes a string, returns a GuardResult.

phase: GuardPhase
When this guard runs (input, output, or both).