community[patch]: apply embedding functions during query if defined (#16646)

**Description:** This update ensures that the user-defined embedding
function specified during vector store creation is applied during
queries. Previously, even if a custom embedding function was defined at
the time of store creation, Bagel DB would default to using the standard
embedding function during query execution. This pull request addresses
this issue by consistently using the user-defined embedding function for
queries if one has been specified earlier.
This commit is contained in:
Rashedul Hasan Rijul 2024-01-27 16:46:33 -08:00 committed by GitHub
parent f01fb47597
commit 481493dbce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,6 +109,12 @@ class Bagel(VectorStore):
import bagel # noqa: F401 import bagel # noqa: F401
except ImportError: except ImportError:
raise ImportError("Please install bagel `pip install betabageldb`.") raise ImportError("Please install bagel `pip install betabageldb`.")
if self._embedding_function and query_embeddings is None and query_texts:
texts = list(query_texts)
query_embeddings = self._embedding_function.embed_documents(texts)
query_texts = None
return self._cluster.find( return self._cluster.find(
query_texts=query_texts, query_texts=query_texts,
query_embeddings=query_embeddings, query_embeddings=query_embeddings,