Skip to main content

GuardrailResult

Defined in the guardrails module.
Rust AI Agent SDK Result of a guardrail validation.

Fields

NameTypeDescription
successboolWhether the guardrail check passed
resultOption<String>The result if modified, or original if unchanged
errorStringError message if validation failed
metadataHashMap<StringAdditional metadata

Methods

success

fn success(result: impl Into<String>) -> Self
Create a successful result Parameters:
NameType
resultimpl Into&lt;String&gt;

pass

fn pass() -> Self
Create a successful result without modification

failure

fn failure(error: impl Into<String>) -> Self
Create a failed result Parameters:
NameType
errorimpl Into&lt;String&gt;

from_tuple

fn from_tuple(success: bool, data: impl Into<String>) -> Self
Create from a tuple (success, result_or_error) Parameters:
NameType
successbool
dataimpl Into&lt;String&gt;

with_metadata

fn with_metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> Self
Add metadata Parameters:
NameType
keyimpl Into&lt;String&gt;
valueimpl Into&lt;String&gt;

is_success

fn is_success(&self) -> bool
Check if passed

is_failure

fn is_failure(&self) -> bool
Check if failed

get_result_or

fn get_result_or(&self, original: &str) -> String
Get the result or original content Parameters:
NameType
original&str

Source

View on GitHub

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