mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-10 15:06:18 +00:00
In MergerRetriever async call all retrievers in parallel (#10938)
This commit is contained in:
parent
66d5a7e7cf
commit
aac2d4dcef
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from typing import List
|
||||
|
||||
from langchain.callbacks.manager import (
|
||||
@ -100,12 +101,14 @@ class MergerRetriever(BaseRetriever):
|
||||
"""
|
||||
|
||||
# Get the results of all retrievers.
|
||||
retriever_docs = [
|
||||
await retriever.aget_relevant_documents(
|
||||
retriever_docs = await asyncio.gather(
|
||||
*(
|
||||
retriever.aget_relevant_documents(
|
||||
query, callbacks=run_manager.get_child("retriever_{}".format(i + 1))
|
||||
)
|
||||
for i, retriever in enumerate(self.retrievers)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
# Merge the results of the retrievers.
|
||||
merged_documents = []
|
||||
|
Loading…
Reference in New Issue
Block a user