|
|
|
@ -3,7 +3,7 @@ Ensemble retriever that ensemble the results of
|
|
|
|
|
multiple retrievers by using weighted Reciprocal Rank Fusion
|
|
|
|
|
"""
|
|
|
|
|
import asyncio
|
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
from typing import Any, Dict, List, Optional, cast
|
|
|
|
|
|
|
|
|
|
from langchain_core.callbacks import (
|
|
|
|
|
AsyncCallbackManagerForRetrieverRun,
|
|
|
|
@ -195,7 +195,7 @@ class EnsembleRetriever(BaseRetriever):
|
|
|
|
|
# Enforce that retrieved docs are Documents for each list in retriever_docs
|
|
|
|
|
for i in range(len(retriever_docs)):
|
|
|
|
|
retriever_docs[i] = [
|
|
|
|
|
Document(page_content=doc) if not isinstance(doc, Document) else doc
|
|
|
|
|
Document(page_content=cast(str, doc)) if isinstance(doc, str) else doc
|
|
|
|
|
for doc in retriever_docs[i]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|