Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn add_documents<'life0, 'async_trait>(
        &'life0 self,
        docs: Vec<Document>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'async_trait>(
        &'life0 self,
        query_vector: Vector,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A persistent or in-memory store of embedded documents.

Implement this trait to add support for a new vector database backend (pgvector, Qdrant, Pinecone, etc.).

Required Methods§

Source

fn add_documents<'life0, 'async_trait>( &'life0 self, docs: Vec<Document>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persist a batch of documents (with their embeddings) to the store.

Source

fn search<'life0, 'async_trait>( &'life0 self, query_vector: Vector, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the limit documents whose embeddings are most similar to query_vector (cosine similarity, descending).

Implementors§