supabase embedding usage fix (#10335)

Should be calling Embeddings.embed_query instead of embed_documents when
searching
This commit is contained in:
Bagatur 2023-09-07 10:04:49 -07:00 committed by GitHub
parent f0ccce76fe
commit 25ec655e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,10 +168,8 @@ class SupabaseVectorStore(VectorStore):
filter: Optional[Dict[str, Any]] = None, filter: Optional[Dict[str, Any]] = None,
**kwargs: Any, **kwargs: Any,
) -> List[Document]: ) -> List[Document]:
vectors = self._embedding.embed_documents([query]) vector = self._embedding.embed_query(query)
return self.similarity_search_by_vector( return self.similarity_search_by_vector(vector, k=k, filter=filter, **kwargs)
vectors[0], k=k, filter=filter, **kwargs
)
def similarity_search_by_vector( def similarity_search_by_vector(
self, self,
@ -195,9 +193,9 @@ class SupabaseVectorStore(VectorStore):
filter: Optional[Dict[str, Any]] = None, filter: Optional[Dict[str, Any]] = None,
**kwargs: Any, **kwargs: Any,
) -> List[Tuple[Document, float]]: ) -> 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( return self.similarity_search_by_vector_with_relevance_scores(
vectors[0], k=k, filter=filter vector, k=k, filter=filter
) )
def match_args( 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( 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 return docs