Trait rig::vector_store::VectorStoreIndex

source ·
pub trait VectorStoreIndex: Send + Sync {
    // Required methods
    fn top_n_from_query(
        &self,
        query: &str,
        n: usize,
    ) -> impl Future<Output = Result<Vec<(f64, DocumentEmbeddings)>, VectorStoreError>> + Send;
    fn top_n_from_embedding(
        &self,
        prompt_embedding: &Embedding,
        n: usize,
    ) -> impl Future<Output = Result<Vec<(f64, DocumentEmbeddings)>, VectorStoreError>> + Send;

    // Provided methods
    fn top_n_documents_from_query<T: for<'a> Deserialize<'a>>(
        &self,
        query: &str,
        n: usize,
    ) -> impl Future<Output = Result<Vec<(f64, T)>, VectorStoreError>> + Send { ... }
    fn top_n_ids_from_query(
        &self,
        query: &str,
        n: usize,
    ) -> impl Future<Output = Result<Vec<(f64, String)>, VectorStoreError>> + Send { ... }
    fn top_n_documents_from_embedding<T: for<'a> Deserialize<'a>>(
        &self,
        prompt_embedding: &Embedding,
        n: usize,
    ) -> impl Future<Output = Result<Vec<(f64, T)>, VectorStoreError>> + Send { ... }
    fn top_n_ids_from_embedding(
        &self,
        prompt_embedding: &Embedding,
        n: usize,
    ) -> impl Future<Output = Result<Vec<(f64, String)>, VectorStoreError>> + Send { ... }
}
Expand description

Trait for vector store indexes

Required Methods§

source

fn top_n_from_query( &self, query: &str, n: usize, ) -> impl Future<Output = Result<Vec<(f64, DocumentEmbeddings)>, VectorStoreError>> + Send

Get the top n documents based on the distance to the given embedding. The distance is calculated as the cosine distance between the prompt and the document embedding. The result is a list of tuples with the distance and the document.

source

fn top_n_from_embedding( &self, prompt_embedding: &Embedding, n: usize, ) -> impl Future<Output = Result<Vec<(f64, DocumentEmbeddings)>, VectorStoreError>> + Send

Get the top n documents based on the distance to the given embedding. The distance is calculated as the cosine distance between the prompt and the document embedding. The result is a list of tuples with the distance and the document.

Provided Methods§

source

fn top_n_documents_from_query<T: for<'a> Deserialize<'a>>( &self, query: &str, n: usize, ) -> impl Future<Output = Result<Vec<(f64, T)>, VectorStoreError>> + Send

Same as top_n_from_query but returns the documents without its embeddings. The documents are deserialized into the given type.

source

fn top_n_ids_from_query( &self, query: &str, n: usize, ) -> impl Future<Output = Result<Vec<(f64, String)>, VectorStoreError>> + Send

Same as top_n_from_query but returns the document ids only.

source

fn top_n_documents_from_embedding<T: for<'a> Deserialize<'a>>( &self, prompt_embedding: &Embedding, n: usize, ) -> impl Future<Output = Result<Vec<(f64, T)>, VectorStoreError>> + Send

Same as top_n_from_embedding but returns the documents without its embeddings. The documents are deserialized into the given type.

source

fn top_n_ids_from_embedding( &self, prompt_embedding: &Embedding, n: usize, ) -> impl Future<Output = Result<Vec<(f64, String)>, VectorStoreError>> + Send

Same as top_n_from_embedding but returns the document ids only.

Object Safety§

This trait is not object safe.

Implementors§