pub trait CompletionRanker: Send + Sync {
// Required methods
fn rank_completions(
&self,
items: Vec<CompletionItem>,
context: &CompletionContext,
) -> Vec<CompletionItem>;
fn score_relevance(
&self,
item: &CompletionItem,
context: &CompletionContext,
) -> f32;
fn score_frequency(&self, item: &CompletionItem) -> f32;
}Expand description
Completion ranker trait
Implementations rank completion suggestions by relevance, frequency, and recency. The ranker is responsible for sorting completions so the most relevant appear first.
§Scoring
Rankers typically combine multiple scoring factors:
- Relevance: How well the completion matches the context
- Frequency: How often the completion is used
- Recency: How recently the completion was used
§Implementations
BasicCompletionRanker: Prefix matching and fuzzy matchingAdvancedCompletionRanker: Advanced scoring with frequency and recency