Base: codex-main originale (prima del fork aKode)
This commit is contained in:
58
codex-rs/ext/skills/src/dynamic_skill_selector.rs
Normal file
58
codex-rs/ext/skills/src/dynamic_skill_selector.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
mod character_ngram;
|
||||
mod character_routing_card;
|
||||
mod fielded_bm25;
|
||||
mod lru;
|
||||
mod lru_plus_character_routing;
|
||||
mod lru_plus_lexical;
|
||||
mod multi_query_lexical;
|
||||
mod routing_card_lexical;
|
||||
mod rrf_lexical_char;
|
||||
mod weighted_lexical;
|
||||
pub(crate) use character_ngram::CharacterNgramSkillSelector;
|
||||
pub(crate) use character_routing_card::CharacterRoutingCardSkillSelector;
|
||||
use codex_skills::SkillDependencies;
|
||||
pub(crate) use fielded_bm25::FieldedBm25SkillSelector;
|
||||
pub(crate) use lru::LruSkillSelector;
|
||||
pub(crate) use lru_plus_character_routing::LruPlusCharacterRoutingSkillSelector;
|
||||
pub(crate) use lru_plus_character_routing::LruPlusLexicalCharacterRoutingSkillSelector;
|
||||
pub(crate) use lru_plus_lexical::LruPlusLexicalSkillSelector;
|
||||
pub(crate) use multi_query_lexical::MultiQueryLexicalSkillSelector;
|
||||
pub(crate) use routing_card_lexical::RoutingCardLexicalSkillSelector;
|
||||
pub(crate) use rrf_lexical_char::RrfLexicalCharSkillSelector;
|
||||
pub(crate) use weighted_lexical::WeightedLexicalSkillSelector;
|
||||
|
||||
/// Metadata searched by a cheap skill selector.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct SkillSelectionDocument<'a> {
|
||||
/// Caller-owned identifier returned in [`CheapSkillSelection::candidate_ids`].
|
||||
pub id: usize,
|
||||
pub name: &'a str,
|
||||
pub short_description: Option<&'a str>,
|
||||
pub description: &'a str,
|
||||
pub dependencies: Option<&'a SkillDependencies>,
|
||||
}
|
||||
|
||||
/// Bounded output from one cheap skill-selection method.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub(crate) struct CheapSkillSelection {
|
||||
pub candidate_ids: Vec<usize>,
|
||||
pub query_term_count: usize,
|
||||
pub query_truncated: bool,
|
||||
pub candidate_set_truncated: bool,
|
||||
}
|
||||
|
||||
/// Selects likely-relevant skills without changing the model-visible catalog.
|
||||
///
|
||||
/// Implementations must be deterministic, side-effect free, and cheap enough to run in shadow
|
||||
/// mode on every turn. Callers must validate returned IDs against the supplied documents.
|
||||
pub(crate) trait CheapSkillSelector: Send + Sync {
|
||||
/// Low-cardinality identifier suitable for experiment metrics.
|
||||
fn method(&self) -> &'static str;
|
||||
|
||||
fn select(
|
||||
&self,
|
||||
query: &str,
|
||||
documents: &[SkillSelectionDocument<'_>],
|
||||
limit: usize,
|
||||
) -> CheapSkillSelection;
|
||||
}
|
||||
Reference in New Issue
Block a user