mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-11 23:40:24 +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 typing import List
|
||||||
|
|
||||||
from langchain.callbacks.manager import (
|
from langchain.callbacks.manager import (
|
||||||
@ -100,12 +101,14 @@ class MergerRetriever(BaseRetriever):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Get the results of all retrievers.
|
# Get the results of all retrievers.
|
||||||
retriever_docs = [
|
retriever_docs = await asyncio.gather(
|
||||||
await retriever.aget_relevant_documents(
|
*(
|
||||||
query, callbacks=run_manager.get_child("retriever_{}".format(i + 1))
|
retriever.aget_relevant_documents(
|
||||||
|
query, callbacks=run_manager.get_child("retriever_{}".format(i + 1))
|
||||||
|
)
|
||||||
|
for i, retriever in enumerate(self.retrievers)
|
||||||
)
|
)
|
||||||
for i, retriever in enumerate(self.retrievers)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
# Merge the results of the retrievers.
|
# Merge the results of the retrievers.
|
||||||
merged_documents = []
|
merged_documents = []
|
||||||
|
Loading…
Reference in New Issue
Block a user