pub struct SemanticRouter { /* private fields */ }Expand description
Routes prompts to specialised workers using keyword-based heuristics.
The router is stateless — all routing decisions are computed from the
prompt text alone, making it safe to share across threads via Arc.
§Example
use tokio_prompt_orchestrator::routing::semantic::{SemanticRouter, RoutingCategory};
let router = SemanticRouter::default();
assert_eq!(
router.classify("Write a recursive Fibonacci function in Rust"),
RoutingCategory::Code,
);Implementations§
Source§impl SemanticRouter
impl SemanticRouter
Sourcepub fn with_config(config: SemanticRouterConfig) -> Self
pub fn with_config(config: SemanticRouterConfig) -> Self
Sourcepub fn classify(&self, prompt: &str) -> RoutingCategory
pub fn classify(&self, prompt: &str) -> RoutingCategory
Classify a prompt into a RoutingCategory.
Returns RoutingCategory::General when no category reaches the
configured min_matches threshold, or when the prompt is empty.
§Panics
This function does not panic.
Sourcepub fn classify_detailed(&self, prompt: &str) -> ClassificationResult
pub fn classify_detailed(&self, prompt: &str) -> ClassificationResult
Classify a prompt and return a full ClassificationResult.
Useful for diagnostics, logging, and metrics.
§Panics
This function does not panic.
Sourcepub fn route(&self, prompt: &str) -> String
pub fn route(&self, prompt: &str) -> String
Classify a prompt and return the target worker label string.
This is the primary method callers use to decide where to send a request.
§Panics
This function does not panic.
Sourcepub fn worker_label_for(&self, category: RoutingCategory) -> String
pub fn worker_label_for(&self, category: RoutingCategory) -> String
Return the configured worker label for a given category, falling back to the default if no override is configured.
§Panics
This function does not panic.
Trait Implementations§
Source§impl Clone for SemanticRouter
impl Clone for SemanticRouter
Source§fn clone(&self) -> SemanticRouter
fn clone(&self) -> SemanticRouter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SemanticRouter
impl Debug for SemanticRouter
Source§impl Default for SemanticRouter
impl Default for SemanticRouter
Source§fn default() -> SemanticRouter
fn default() -> SemanticRouter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request