You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have looked for existing issues (including closed) about this
Feature Request
Refactor the VectorStoreIndex trait to add a generic type representing the type documents stored in the store. This would remove the generic type of the top_n method.
Motivation
This goal of this change is to improve the developer experience while working with vector stores. Specifically, it solves the problem where developers have to define the type associated with a vector store twice. For instance, with the InMemoryVectorStore, which is itself already parametrized by some generic type D, the type T of the top_n implementation cannot be inferred where it should in fact be the same as the type D of the store! A similar situation occurs with the MongoDbVectorStore, which takes as constructor argument a Collection<T>, which implies that the return type of the top_n method is also T (currently you have to define it twice).
Proposal
Refactor the VectorStoreIndex trait like so:
pubtraitVectorStoreIndex<T:for<'a>Deserialize<'a>>:Send + Sync{/// Get the top n documents based on the distance to the given query./// The result is a list of tuples of the form (score, id, document)fntop_n(&self,query:&str,n:usize,) -> impl std::future::Future<Output = Result<Vec<(f64,String,T)>,VectorStoreError>> + Send;/// Same as `top_n` but returns the document ids only.fntop_n_ids(&self,query:&str,n:usize,) -> impl std::future::Future<Output = Result<Vec<(f64,String)>,VectorStoreError>> + Send;}
The text was updated successfully, but these errors were encountered:
Feature Request
Refactor the
VectorStoreIndex
trait to add a generic type representing the type documents stored in the store. This would remove the generic type of thetop_n
method.Motivation
This goal of this change is to improve the developer experience while working with vector stores. Specifically, it solves the problem where developers have to define the type associated with a vector store twice. For instance, with the
InMemoryVectorStore
, which is itself already parametrized by some generic typeD
, the typeT
of thetop_n
implementation cannot be inferred where it should in fact be the same as the typeD
of the store! A similar situation occurs with theMongoDbVectorStore
, which takes as constructor argument aCollection<T>
, which implies that the return type of thetop_n
method is alsoT
(currently you have to define it twice).Proposal
Refactor the
VectorStoreIndex
trait like so:The text was updated successfully, but these errors were encountered: