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§
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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 foragent_id- Optional agent ID to filter resultslimit- Maximum number of results to returnthreshold- Optional minimum similarity score threshold (0.0 to 1.0)
§Returns
A vector of search results ordered by similarity (highest first).
Sourcefn 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 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.