pub struct HeuristicIntentClassifier {
pub max_shallow_query_chars: usize,
pub max_shallow_question_marks: usize,
pub max_shallow_depth: u32,
pub comparative_markers: Vec<String>,
}Expand description
Deterministic, LLM-free intent classifier.
Classifies a request as ResearchTier::Shallow when all of
the following hold; otherwise it routes to ResearchTier::Deep:
req.query.chars().count()is strictly less thanHeuristicIntentClassifier::max_shallow_query_chars.- The query contains zero or one
?characters (multiple sub- questions imply deep). req.depthis<=HeuristicIntentClassifier::max_shallow_depth.- The query contains none of the configured comparative markers (case-insensitive substring match).
All thresholds are tunable via the with_* builder methods.
Fields§
§max_shallow_query_chars: usizeStrict upper bound on chars().count() of a shallow query.
max_shallow_question_marks: usizeMaximum allowed ? count in a shallow query.
max_shallow_depth: u32Maximum allowed req.depth for a shallow query.
comparative_markers: Vec<String>Case-insensitive substrings whose presence forces the request to the deep tier.
Implementations§
Source§impl HeuristicIntentClassifier
impl HeuristicIntentClassifier
Sourcepub fn with_max_shallow_query_chars(self, n: usize) -> Self
pub fn with_max_shallow_query_chars(self, n: usize) -> Self
Override the strict character-count upper bound.
Sourcepub fn with_max_shallow_question_marks(self, n: usize) -> Self
pub fn with_max_shallow_question_marks(self, n: usize) -> Self
Override the maximum allowed ? count for shallow queries.
Sourcepub fn with_max_shallow_depth(self, n: u32) -> Self
pub fn with_max_shallow_depth(self, n: u32) -> Self
Override the maximum allowed req.depth for shallow queries.
Sourcepub fn with_comparative_markers<I, S>(self, markers: I) -> Self
pub fn with_comparative_markers<I, S>(self, markers: I) -> Self
Replace the comparative-marker list outright.
Sourcepub fn classify_sync(&self, req: &ResearchRequest) -> ResearchTier
pub fn classify_sync(&self, req: &ResearchRequest) -> ResearchTier
Pure synchronous classifier used by the async trait method.
Public so callers and tests can exercise it without await.
Trait Implementations§
Source§impl Clone for HeuristicIntentClassifier
impl Clone for HeuristicIntentClassifier
Source§fn clone(&self) -> HeuristicIntentClassifier
fn clone(&self) -> HeuristicIntentClassifier
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 HeuristicIntentClassifier
impl Debug for HeuristicIntentClassifier
Source§impl Default for HeuristicIntentClassifier
impl Default for HeuristicIntentClassifier
Source§impl IntentClassifier for HeuristicIntentClassifier
impl IntentClassifier for HeuristicIntentClassifier
Source§fn classify<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ResearchRequest,
) -> Pin<Box<dyn Future<Output = Result<ResearchTier>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn classify<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ResearchRequest,
) -> Pin<Box<dyn Future<Output = Result<ResearchTier>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
req.