mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-01 17:16:51 +00:00
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:
@@ -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"]
|
||||
|
Reference in New Issue
Block a user