synaptic_vectorstores/
lib.rs1mod in_memory;
2mod multi_vector;
3
4pub use in_memory::{InMemoryVectorStore, VectorStoreRetriever};
5pub use multi_vector::MultiVectorRetriever;
6
7use async_trait::async_trait;
8use synaptic_core::SynapseError;
9use synaptic_embeddings::Embeddings;
10use synaptic_retrieval::Document;
11
12#[async_trait]
14pub trait VectorStore: Send + Sync {
15 async fn add_documents(
17 &self,
18 docs: Vec<Document>,
19 embeddings: &dyn Embeddings,
20 ) -> Result<Vec<String>, SynapseError>;
21
22 async fn similarity_search(
24 &self,
25 query: &str,
26 k: usize,
27 embeddings: &dyn Embeddings,
28 ) -> Result<Vec<Document>, SynapseError>;
29
30 async fn similarity_search_with_score(
32 &self,
33 query: &str,
34 k: usize,
35 embeddings: &dyn Embeddings,
36 ) -> Result<Vec<(Document, f32)>, SynapseError>;
37
38 async fn similarity_search_by_vector(
40 &self,
41 embedding: &[f32],
42 k: usize,
43 ) -> Result<Vec<Document>, SynapseError>;
44
45 async fn delete(&self, ids: &[&str]) -> Result<(), SynapseError>;
47}