Skip to main content

EmbeddingStore

Trait EmbeddingStore 

Source
pub trait EmbeddingStore: Send + Sync {
    // Required methods
    fn upsert<'life0, 'async_trait>(
        &'life0 self,
        record: EmbeddingRecord,
    ) -> Pin<Box<dyn Future<Output = StoreResult<EmbeddingRecord>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 [f32],
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<ScoredEmbedding>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_by_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Persists embedding vectors and supports nearest-neighbor search.

Implementations use cosine similarity for ranking results (higher score = closer match). Backends include in-memory HashMap and PostgreSQL with pgvector.

Required Methods§

Source

fn upsert<'life0, 'async_trait>( &'life0 self, record: EmbeddingRecord, ) -> Pin<Box<dyn Future<Output = StoreResult<EmbeddingRecord>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Inserts or updates an embedding record.

If a record with the same ID already exists, it is replaced. Returns the stored record on success.

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 [f32], limit: usize, ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<ScoredEmbedding>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the limit nearest neighbors to the query vector.

Each result includes the record and its similarity score (higher is closer).

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes an embedding by identifier.

Returns Ok(()) even when the ID does not exist (idempotent).

Source

fn delete_by_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes all embeddings associated with a session.

Returns the number of records deleted.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§