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§
sourcefn top_n_from_query(
&self,
query: &str,
n: usize,
) -> impl Future<Output = Result<Vec<(f64, DocumentEmbeddings)>, VectorStoreError>> + Send
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.
sourcefn top_n_from_embedding(
&self,
prompt_embedding: &Embedding,
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
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§
sourcefn 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_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.
sourcefn top_n_ids_from_query(
&self,
query: &str,
n: usize,
) -> impl Future<Output = Result<Vec<(f64, String)>, VectorStoreError>> + Send
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.
sourcefn 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_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.