feat: (0.6)New UI (#1855)

Co-authored-by: 夏姜 <wenfengjiang.jwf@digital-engine.com>
Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: wb-lh513319 <wb-lh513319@alibaba-inc.com>
Co-authored-by: csunny <cfqsunny@163.com>
This commit is contained in:
明天
2024-08-21 17:37:45 +08:00
committed by GitHub
parent 3fc82693ba
commit b124ecc10b
824 changed files with 93371 additions and 2515 deletions

View File

@@ -314,3 +314,30 @@ class RerankEmbeddingsRanker(Ranker):
candidates_with_scores, rank_scores
)
return new_candidates_with_scores[: self.topk]
class RetrieverNameRanker(Ranker):
"""RetrieverName Ranker."""
def __init__(self, topk: int, rank_fn: Optional[callable] = None): # type: ignore # noqa
super().__init__(topk, rank_fn)
def rank(self, candidates: List[Chunk], query: Optional[str] = None) -> List[Chunk]:
"""Use Retriever NameRanker return candidates with retriever name in filter_retrievers.
Args:
candidates: List[Tuple]
query: Optional[str]
Return:
List[Chunk]
""" # noqa
candidates_with_scores = [
candidate
for candidate in candidates
if candidate.retriever in self.filter_retrievers
]
return candidates_with_scores
@property
def filter_retrievers(self):
"""Filter retrievers."""
return ["qa_retriever", "title_retriever"]