pub struct EmbeddingIndex { /* private fields */ }Expand description
Persistent embedding index.
Serialized to disk via bincode for fast startup. Rebuilds only when skill content changes (tracked via content_hash).
Implementations§
Source§impl EmbeddingIndex
impl EmbeddingIndex
Sourcepub async fn build(
registry: &SkillRegistry,
provider: &dyn EmbeddingProvider,
weights: ComponentWeights,
) -> Result<Self, EmbedError>
pub async fn build( registry: &SkillRegistry, provider: &dyn EmbeddingProvider, weights: ComponentWeights, ) -> Result<Self, EmbedError>
Build index from registry using the given embedding provider.
Embeds all skills in parallel where possible.
Sourcepub fn load_cached(
path: &Path,
registry: &SkillRegistry,
) -> Result<Option<Self>, EmbedError>
pub fn load_cached( path: &Path, registry: &SkillRegistry, ) -> Result<Option<Self>, EmbedError>
Load from disk cache. Returns None if cache is stale or doesn’t exist.
Sourcepub fn query(
&self,
query_embedding: &Embedding,
top_k: usize,
) -> Vec<ScoredSkill>
pub fn query( &self, query_embedding: &Embedding, top_k: usize, ) -> Vec<ScoredSkill>
Query: return top-k skills by similarity.
Sourcepub fn query_adaptive(
&self,
query_embedding: &Embedding,
min_score: f32,
max_k: usize,
gap_threshold: f32,
) -> Vec<ScoredSkill>
pub fn query_adaptive( &self, query_embedding: &Embedding, min_score: f32, max_k: usize, gap_threshold: f32, ) -> Vec<ScoredSkill>
Query with adaptive k: return skills above threshold, with automatic gap detection.
Sourcepub fn built_at(&self) -> SystemTime
pub fn built_at(&self) -> SystemTime
Get when this index was built.
Sourcepub fn skill_names(&self) -> Vec<&SkillName>
pub fn skill_names(&self) -> Vec<&SkillName>
Get all skill names in the index.
Sourcepub fn get(&self, name: &SkillName) -> Option<&SkillEmbeddings>
pub fn get(&self, name: &SkillName) -> Option<&SkillEmbeddings>
Get embeddings for a specific skill.
Trait Implementations§
Source§impl Clone for EmbeddingIndex
impl Clone for EmbeddingIndex
Source§fn clone(&self) -> EmbeddingIndex
fn clone(&self) -> EmbeddingIndex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 EmbeddingIndex
impl Debug for EmbeddingIndex
Source§impl<'de> Deserialize<'de> for EmbeddingIndex
impl<'de> Deserialize<'de> for EmbeddingIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for EmbeddingIndex
impl RefUnwindSafe for EmbeddingIndex
impl Send for EmbeddingIndex
impl Sync for EmbeddingIndex
impl Unpin for EmbeddingIndex
impl UnsafeUnpin for EmbeddingIndex
impl UnwindSafe for EmbeddingIndex
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more