Rely less on positional arg order in subclasses of vector store when calling async methods (#8534)

pull/8539/head
Nuno Campos 1 year ago committed by GitHub
parent 5e3b968078
commit 4780156955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -280,7 +280,9 @@ class VectorStore(ABC):
# This is a temporary workaround to make the similarity search
# asynchronous. The proper solution is to make the similarity search
# asynchronous in the vector store implementations.
func = partial(self.similarity_search_with_relevance_scores, query, k, **kwargs)
func = partial(
self.similarity_search_with_relevance_scores, query, k=k, **kwargs
)
return await asyncio.get_event_loop().run_in_executor(None, func)
async def asimilarity_search(
@ -291,7 +293,7 @@ class VectorStore(ABC):
# This is a temporary workaround to make the similarity search
# asynchronous. The proper solution is to make the similarity search
# asynchronous in the vector store implementations.
func = partial(self.similarity_search, query, k, **kwargs)
func = partial(self.similarity_search, query, k=k, **kwargs)
return await asyncio.get_event_loop().run_in_executor(None, func)
def similarity_search_by_vector(
@ -316,7 +318,7 @@ class VectorStore(ABC):
# This is a temporary workaround to make the similarity search
# asynchronous. The proper solution is to make the similarity search
# asynchronous in the vector store implementations.
func = partial(self.similarity_search_by_vector, embedding, k, **kwargs)
func = partial(self.similarity_search_by_vector, embedding, k=k, **kwargs)
return await asyncio.get_event_loop().run_in_executor(None, func)
def max_marginal_relevance_search(
@ -359,7 +361,12 @@ class VectorStore(ABC):
# asynchronous. The proper solution is to make the similarity search
# asynchronous in the vector store implementations.
func = partial(
self.max_marginal_relevance_search, query, k, fetch_k, lambda_mult, **kwargs
self.max_marginal_relevance_search,
query,
k=k,
fetch_k=fetch_k,
lambda_mult=lambda_mult,
**kwargs,
)
return await asyncio.get_event_loop().run_in_executor(None, func)

Loading…
Cancel
Save