VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn store<'life0, 'async_trait>(
        &'life0 self,
        entry: VectorEntry,
    ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<VectorEntry>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        query_vector: &'life1 [f32],
        agent_id: Option<&'life2 str>,
        limit: usize,
        threshold: Option<f32>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn clear_agent_vectors<'life0, 'life1, 'async_trait>(
        &'life0 self,
        agent_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn dimension(&self) -> usize;

    // Provided method
    fn store_batch<'life0, 'async_trait>(
        &'life0 self,
        entries: Vec<VectorEntry>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for storing and retrieving vector embeddings.

Vector stores handle the low-level storage and similarity search of vector embeddings. Different implementations can use different backends like in-memory storage, vector databases, etc.

Required Methods§

Source

fn store<'life0, 'async_trait>( &'life0 self, entry: VectorEntry, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores a vector entry.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<VectorEntry>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a vector entry by ID.

Source

fn search<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query_vector: &'life1 [f32], agent_id: Option<&'life2 str>, limit: usize, threshold: Option<f32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Searches for similar vectors using cosine similarity.

§Arguments
  • query_vector - The query vector to search for
  • agent_id - Optional agent ID to filter results
  • limit - Maximum number of results to return
  • threshold - Optional minimum similarity score threshold (0.0 to 1.0)
§Returns

A vector of search results ordered by similarity (highest first).

Source

fn clear_agent_vectors<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes all vectors for an agent.

Source

fn count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the number of vectors stored.

Source

fn dimension(&self) -> usize

Returns the dimension of vectors in this store.

Provided Methods§

Source

fn store_batch<'life0, 'async_trait>( &'life0 self, entries: Vec<VectorEntry>, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores multiple vector entries in batch.

Implementors§