pub struct GuardrailSet { /* private fields */ }Expand description
A set of guardrails to run on input/output
Implementations§
Source§impl GuardrailSet
impl GuardrailSet
pub fn new() -> Self
pub fn with_config(self, config: GuardrailConfig) -> Self
pub fn add_input<G: Guardrail + 'static>(self, guardrail: G) -> Self
pub fn add_output<G: Guardrail + 'static>(self, guardrail: G) -> Self
pub fn add_input_boxed(self, guardrail: BoxedGuardrail) -> Self
pub fn add_output_boxed(self, guardrail: BoxedGuardrail) -> Self
Sourcepub async fn check_input(
&self,
content: &str,
) -> Result<GuardrailResult, GuardrailError>
pub async fn check_input( &self, content: &str, ) -> Result<GuardrailResult, GuardrailError>
Check input before processing
Sourcepub async fn check_input_with_context(
&self,
context: &GuardrailContext,
) -> Result<GuardrailResult, GuardrailError>
pub async fn check_input_with_context( &self, context: &GuardrailContext, ) -> Result<GuardrailResult, GuardrailError>
Check input with full context
Sourcepub async fn check_output(
&self,
content: &str,
) -> Result<GuardrailResult, GuardrailError>
pub async fn check_output( &self, content: &str, ) -> Result<GuardrailResult, GuardrailError>
Check output before returning
Sourcepub async fn check_output_with_context(
&self,
context: &GuardrailContext,
) -> Result<GuardrailResult, GuardrailError>
pub async fn check_output_with_context( &self, context: &GuardrailContext, ) -> Result<GuardrailResult, GuardrailError>
Check output with full context
pub fn stats(&self) -> GuardrailStats
pub fn input_guardrail_names(&self) -> Vec<&str>
pub fn output_guardrail_names(&self) -> Vec<&str>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GuardrailSet
impl !RefUnwindSafe for GuardrailSet
impl Send for GuardrailSet
impl Sync for GuardrailSet
impl Unpin for GuardrailSet
impl UnsafeUnpin for GuardrailSet
impl !UnwindSafe for GuardrailSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more