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
| Name | Type | Description |
|---|---|---|
guardrails | Vec<Box<dyn Guardrail>> | – |
config | GuardrailConfig | – |
Methods
new
fn new() -> SelfCreate a new guardrail chain
add
fn add(mut self, guardrail: impl Guardrail + 'static) -> SelfAdd a guardrail to the chain
Parameters:
| Name | Type |
|---|---|
guardrail | impl Guardrail + 'static |
config
fn config(mut self, config: GuardrailConfig) -> SelfSet config
Parameters:
| Name | Type |
|---|---|
config | GuardrailConfig |
validate
fn validate(&self, output: &str) -> GuardrailResultValidate output through all guardrails
Parameters:
| Name | Type |
|---|---|
output | &str |
len
fn len(&self) -> usizeGet guardrail count
is_empty
fn is_empty(&self) -> boolCheck if empty
Source
View on GitHubpraisonai/src/guardrails/mod.rs at line 479