Trait VectorStore

Source
pub trait VectorStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn add_documents<'life0, 'async_trait>(
        &'life0 self,
        documents: Vec<Document>,
        embeddings: Option<Vec<Embedding>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn similarity_search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        k: usize,
        filter: Option<HashMap<String, Value>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn similarity_search_by_embedding<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query_embedding: &'life1 Embedding,
        k: usize,
        filter: Option<HashMap<String, Value>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        ids: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn len<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn add_texts<'life0, 'async_trait>(
        &'life0 self,
        texts: Vec<String>,
        metadatas: Option<Vec<HashMap<String, Value>>>,
        embeddings: Option<Vec<Embedding>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn is_empty<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn embedding_model(&self) -> Option<&dyn Embeddings> { ... }
}
Expand description

Base trait for all vector stores

Required Methods§

Source

fn add_documents<'life0, 'async_trait>( &'life0 self, documents: Vec<Document>, embeddings: Option<Vec<Embedding>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add documents to the vector store

Search for similar documents

Source

fn similarity_search_by_embedding<'life0, 'life1, 'async_trait>( &'life0 self, query_embedding: &'life1 Embedding, k: usize, filter: Option<HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search for similar documents by embedding

Source

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

Delete documents by IDs

Source

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

Get the number of documents in the store

Source

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

Clear all documents from the store

Provided Methods§

Source

fn add_texts<'life0, 'async_trait>( &'life0 self, texts: Vec<String>, metadatas: Option<Vec<HashMap<String, Value>>>, embeddings: Option<Vec<Embedding>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add texts to the vector store

Source

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

Check if the store is empty

Source

fn embedding_model(&self) -> Option<&dyn Embeddings>

Get the embedding model used by this store

Implementors§