pub struct KnowledgeRouter { /* private fields */ }Expand description
Router for classifying incoming knowledge.
The router applies rules in order, using the first matching rule. If no rules match, the default type is used.
Implementations§
Source§impl KnowledgeRouter
impl KnowledgeRouter
Sourcepub fn with_default(default_type: KnowledgeTypeHint) -> Self
pub fn with_default(default_type: KnowledgeTypeHint) -> Self
Create a router with a custom default type.
Sourcepub fn with_scoring_weights(self, weights: ScoringWeights) -> Self
pub fn with_scoring_weights(self, weights: ScoringWeights) -> Self
Set custom scoring weights.
Sourcepub fn add_rule(&mut self, rule: RoutingRule)
pub fn add_rule(&mut self, rule: RoutingRule)
Add a routing rule.
Rules are evaluated in the order they are added.
Sourcepub fn add_rules(&mut self, rules: impl IntoIterator<Item = RoutingRule>)
pub fn add_rules(&mut self, rules: impl IntoIterator<Item = RoutingRule>)
Add multiple routing rules at once.
Sourcepub fn classify(
&self,
source_path: &Path,
content: &str,
metadata: &HashMap<String, String>,
) -> KnowledgeType
pub fn classify( &self, source_path: &Path, content: &str, metadata: &HashMap<String, String>, ) -> KnowledgeType
Classify knowledge based on source path, content, and metadata.
Evaluates rules in order and returns the first matching type. If no rules match, returns the default type.
Sourcepub fn classify_with_id(
&self,
entry_id: Uuid,
source_path: &Path,
content: &str,
metadata: &HashMap<String, String>,
) -> KnowledgeType
pub fn classify_with_id( &self, entry_id: Uuid, source_path: &Path, content: &str, metadata: &HashMap<String, String>, ) -> KnowledgeType
Classify with a specific entry ID.
Sourcepub fn compute_relevance_score(
&self,
knowledge: &KnowledgeType,
base_similarity: f32,
query_context: Option<&str>,
) -> f32
pub fn compute_relevance_score( &self, knowledge: &KnowledgeType, base_similarity: f32, query_context: Option<&str>, ) -> f32
Compute the relevance score for a knowledge entry.
Uses the unified ranking formula:
final_score = (
base_similarity * source_weight +
case_relevance * context_boost +
background_relevance * support_factor +
recency_score * decay_factor
)§Arguments
knowledge- The classified knowledge to scorebase_similarity- Base similarity score from vector search (0.0 to 1.0)query_context- Optional current case context for boosting
§Returns
The final relevance score.
Sourcepub fn rules(&self) -> &[RoutingRule]
pub fn rules(&self) -> &[RoutingRule]
Get all rules.
Sourcepub fn default_type(&self) -> &KnowledgeTypeHint
pub fn default_type(&self) -> &KnowledgeTypeHint
Get the default knowledge type hint.
Sourcepub fn scoring_weights(&self) -> &ScoringWeights
pub fn scoring_weights(&self) -> &ScoringWeights
Get the scoring weights.
Trait Implementations§
Source§impl Clone for KnowledgeRouter
impl Clone for KnowledgeRouter
Source§fn clone(&self) -> KnowledgeRouter
fn clone(&self) -> KnowledgeRouter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KnowledgeRouter
impl Debug for KnowledgeRouter
Auto Trait Implementations§
impl Freeze for KnowledgeRouter
impl RefUnwindSafe for KnowledgeRouter
impl Send for KnowledgeRouter
impl Sync for KnowledgeRouter
impl Unpin for KnowledgeRouter
impl UnsafeUnpin for KnowledgeRouter
impl UnwindSafe for KnowledgeRouter
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request