From 25ec655e4fd134ca15bfdb9f7640769c7e811d02 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:04:49 -0700 Subject: [PATCH] supabase embedding usage fix (#10335) Should be calling Embeddings.embed_query instead of embed_documents when searching --- libs/langchain/langchain/vectorstores/supabase.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/langchain/langchain/vectorstores/supabase.py b/libs/langchain/langchain/vectorstores/supabase.py index d911965346..4214e085f6 100644 --- a/libs/langchain/langchain/vectorstores/supabase.py +++ b/libs/langchain/langchain/vectorstores/supabase.py @@ -168,10 +168,8 @@ class SupabaseVectorStore(VectorStore): filter: Optional[Dict[str, Any]] = None, **kwargs: Any, ) -> List[Document]: - vectors = self._embedding.embed_documents([query]) - return self.similarity_search_by_vector( - vectors[0], k=k, filter=filter, **kwargs - ) + vector = self._embedding.embed_query(query) + return self.similarity_search_by_vector(vector, k=k, filter=filter, **kwargs) def similarity_search_by_vector( self, @@ -195,9 +193,9 @@ class SupabaseVectorStore(VectorStore): filter: Optional[Dict[str, Any]] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: - vectors = self._embedding.embed_documents([query]) + vector = self._embedding.embed_query(query) return self.similarity_search_by_vector_with_relevance_scores( - vectors[0], k=k, filter=filter + vector, k=k, filter=filter ) def match_args( @@ -407,9 +405,9 @@ class SupabaseVectorStore(VectorStore): $$; ``` """ - embedding = self._embedding.embed_documents([query]) + embedding = self._embedding.embed_query(query) docs = self.max_marginal_relevance_search_by_vector( - embedding[0], k, fetch_k, lambda_mult=lambda_mult + embedding, k, fetch_k, lambda_mult=lambda_mult ) return docs