pub struct SemanticRouter { /* private fields */ }Expand description
Semantic router that maintains a centroid cache per namespace.
Implementations§
Source§impl SemanticRouter
impl SemanticRouter
pub fn new(config: SemanticRouterConfig) -> Self
Sourcepub fn route(
&self,
query: &[f32],
top_k: usize,
min_similarity: f32,
) -> Vec<RouteMatch>
pub fn route( &self, query: &[f32], top_k: usize, min_similarity: f32, ) -> Vec<RouteMatch>
Route a query embedding to the most relevant namespaces.
Returns namespaces sorted by similarity (descending), filtered
by min_similarity.
Sourcepub async fn refresh_centroids(&self, storage: &Arc<dyn VectorStorage>)
pub async fn refresh_centroids(&self, storage: &Arc<dyn VectorStorage>)
Refresh the centroid cache by sampling memories from each agent namespace.
For each _dakera_agent_* namespace, sample up to sample_size vectors,
average their embeddings into a single centroid.
Sourcepub fn spawn_refresh(
router: Arc<SemanticRouter>,
storage: Arc<dyn VectorStorage>,
) -> JoinHandle<()>
pub fn spawn_refresh( router: Arc<SemanticRouter>, storage: Arc<dyn VectorStorage>, ) -> JoinHandle<()>
Spawn the centroid refresh as a background tokio task.
Auto Trait Implementations§
impl !Freeze for SemanticRouter
impl !RefUnwindSafe for SemanticRouter
impl Send for SemanticRouter
impl Sync for SemanticRouter
impl Unpin for SemanticRouter
impl UnsafeUnpin for SemanticRouter
impl UnwindSafe for SemanticRouter
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