From d835439feac3a565d7b4e9accacbc679eeca137a Mon Sep 17 00:00:00 2001 From: ouyangyouzhang Date: Wed, 2 Jul 2025 13:34:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96get=5Fretrieve=5Finfo?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E8=B0=83=E6=95=B4outputs=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=B1=BB=E5=9E=8B=E4=B8=BAlist[dict]=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0segmentid=5Fto=5Ftitle=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E5=8D=87=E5=86=85=E5=AE=B9=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=E7=9A=84=E5=87=86=E7=A1=AE?= =?UTF-8?q?=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rag2_0/dify/dify_tool.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rag2_0/dify/dify_tool.py b/rag2_0/dify/dify_tool.py index 2d1cbaa..50d2e01 100755 --- a/rag2_0/dify/dify_tool.py +++ b/rag2_0/dify/dify_tool.py @@ -341,7 +341,7 @@ content: "{content}" except Exception as e: return -1 - def get_retrieve_info(self, query: str, outputs: dict, reranker_sorce_info:list) -> tuple: + def get_retrieve_info(self, query: str, outputs: list[dict], reranker_sorce_info:list) -> tuple: """ 获取检索信息并计算分数 @@ -357,6 +357,7 @@ content: "{content}" total_score = 0 valid_scores = 0 retrieve_title = [] + segmentid_to_title = { result["segment_id"]:result["title"].split("/")[-1] for result in outputs} # 使用线程池并发计算分数 with ThreadPoolExecutor() as executor: @@ -372,7 +373,7 @@ content: "{content}" for future in as_completed(future_to_content): content, segment_id = future_to_content[future] score = future.result() - content_title = content.split("\n")[0] + content_title = segmentid_to_title[segment_id] if score != -1: max_score = max(max_score, score)