pub struct EmbeddingAnomalyGuard { /* private fields */ }Expand description
EmbeddingAnomaly embedding detector guard.
Implementations§
Source§impl EmbeddingAnomalyGuard
impl EmbeddingAnomalyGuard
Sourcepub fn new(
db: EmbeddingAnomalyPatternDb,
config: EmbeddingAnomalyConfig,
) -> Result<Self, EmbeddingAnomalyError>
pub fn new( db: EmbeddingAnomalyPatternDb, config: EmbeddingAnomalyConfig, ) -> Result<Self, EmbeddingAnomalyError>
Build a guard from a pattern database and configuration.
Sourcepub fn from_json(json: &str) -> Result<Self, EmbeddingAnomalyError>
pub fn from_json(json: &str) -> Result<Self, EmbeddingAnomalyError>
Convenience: build from a JSON pattern database string and defaults.
Sourcepub fn from_json_file(path: &str) -> Result<Self, EmbeddingAnomalyError>
pub fn from_json_file(path: &str) -> Result<Self, EmbeddingAnomalyError>
Read a pattern database from a JSON file on disk.
Sourcepub fn score(&self, embedding: &[f32]) -> f64
pub fn score(&self, embedding: &[f32]) -> f64
Score an embedding against the pattern database. Returns the cosine similarity of the best-matching pattern (0.0 if the embedding is invalid).
Sourcepub fn pattern_count(&self) -> usize
pub fn pattern_count(&self) -> usize
Number of patterns in the database.
Trait Implementations§
Source§impl Guard for EmbeddingAnomalyGuard
impl Guard for EmbeddingAnomalyGuard
Source§fn evaluate(&self, ctx: &GuardContext<'_>) -> Result<GuardDecision, KernelError>
fn evaluate(&self, ctx: &GuardContext<'_>) -> Result<GuardDecision, KernelError>
Evaluate the guard against a tool call request. Read more
Auto Trait Implementations§
impl Freeze for EmbeddingAnomalyGuard
impl RefUnwindSafe for EmbeddingAnomalyGuard
impl Send for EmbeddingAnomalyGuard
impl Sync for EmbeddingAnomalyGuard
impl Unpin for EmbeddingAnomalyGuard
impl UnsafeUnpin for EmbeddingAnomalyGuard
impl UnwindSafe for EmbeddingAnomalyGuard
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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