Guardrail Chain • Rust AI Agent SDK

GuardrailChain: Chain of guardrails to run in sequence.

GuardrailChain

Defined in the guardrails module.

Rust AI Agent SDK

Chain of guardrails to run in sequence.

Fields

NameTypeDescription
guardrailsVec<Box<dyn Guardrail>>–
configGuardrailConfig–

Methods

new

rust
fn new() -> Self

Create a new guardrail chain

add

rust
fn add(mut self, guardrail: impl Guardrail + 'static) -> Self

Add a guardrail to the chain

Parameters:

NameType
guardrailimpl Guardrail + 'static

config

rust
fn config(mut self, config: GuardrailConfig) -> Self

Set config

Parameters:

NameType
configGuardrailConfig

validate

rust
fn validate(&self, output: &str) -> GuardrailResult

Validate output through all guardrails

Parameters:

NameType
output&str

len

rust
fn len(&self) -> usize

Get guardrail count

is_empty

rust
fn is_empty(&self) -> bool

Check if empty

Source

View on GitHub

praisonai/src/guardrails/mod.rs at line 479


Related Documentation