Skip to main content

VectorDb

Trait VectorDb 

Source
pub trait VectorDb: Send + Sync {
Show 14 methods // Required methods fn initialize<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_knowledge_item<'life0, 'life1, 'async_trait>( &'life0 self, item: &'life1 KnowledgeItem, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<VectorId, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn store_memory_item<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: AgentId, memory: &'life1 MemoryItem, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<VectorId, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn batch_store<'life0, 'async_trait>( &'life0 self, batch: VectorBatchOperation, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorId>, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn search_knowledge_base<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, query_embedding: Vec<f32>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<KnowledgeItem>, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn semantic_search<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, query_embedding: Vec<f32>, limit: usize, threshold: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextItem>, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn advanced_search<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, query_embedding: Vec<f32>, filters: HashMap<String, String>, limit: usize, threshold: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn delete_knowledge_item<'life0, 'async_trait>( &'life0 self, vector_id: VectorId, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn batch_delete<'life0, 'async_trait>( &'life0 self, vector_ids: Vec<VectorId>, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_metadata<'life0, 'async_trait>( &'life0 self, vector_id: VectorId, metadata: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<VectorDatabaseStats, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_index<'life0, 'life1, 'async_trait>( &'life0 self, field_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn optimize_collection<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, ContextError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Backend-agnostic vector database trait.

All vector operations go through this trait. Implementations:

  • LanceDbBackend — embedded, zero-config (default)
  • QdrantClientWrapper — remote, feature-gated behind vector-qdrant
  • NoOpVectorDatabase — fallback when no backend is configured

Required Methods§

Source

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

Initialize the backend (create collection/table if needed).

Source

fn store_knowledge_item<'life0, 'life1, 'async_trait>( &'life0 self, item: &'life1 KnowledgeItem, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<VectorId, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a knowledge item with its embedding vector.

Source

fn store_memory_item<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: AgentId, memory: &'life1 MemoryItem, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<VectorId, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a memory item with its embedding vector.

Source

fn batch_store<'life0, 'async_trait>( &'life0 self, batch: VectorBatchOperation, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorId>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store multiple items in batch.

Source

fn search_knowledge_base<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, query_embedding: Vec<f32>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<KnowledgeItem>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Search the knowledge base by semantic similarity.

Semantic similarity search returning context items.

Advanced search with metadata filters.

Source

fn delete_knowledge_item<'life0, 'async_trait>( &'life0 self, vector_id: VectorId, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete a knowledge item by vector ID.

Source

fn batch_delete<'life0, 'async_trait>( &'life0 self, vector_ids: Vec<VectorId>, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete multiple vectors by ID.

Source

fn update_metadata<'life0, 'async_trait>( &'life0 self, vector_id: VectorId, metadata: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update metadata on an existing vector.

Source

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

Get statistics about the vector database.

Source

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

Create an index on a field.

Source

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

Optimize the collection (compact, reindex, etc.).

Source

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

Health check — can the backend be reached?

Implementors§