From 2c5dc64e1f76fa6e71c519db66cd347b865fcdc2 Mon Sep 17 00:00:00 2001 From: tt-P607 <68868379+tt-P607@users.noreply.github.com> Date: Thu, 23 Oct 2025 02:25:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(chat):=20=E4=B8=BA=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E6=AE=B5=E8=90=BD=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=80=A7=E9=98=88=E5=80=BC=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据 `qa_paragraph_threshold` 配置,跳过相关性得分低于阈值的知识库段落。 这可以防止低相关性的知识污染上下文,从而提高生成回答的质量和准确性。 --- src/chat/utils/prompt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chat/utils/prompt.py b/src/chat/utils/prompt.py index 74bbd16cd..2931b1b08 100644 --- a/src/chat/utils/prompt.py +++ b/src/chat/utils/prompt.py @@ -748,6 +748,8 @@ class Prompt: if content: try: relevance_float = float(relevance) + if relevance_float < global_config.lpmm_knowledge.qa_paragraph_threshold: + continue # 跳过不符合阈值的知识 relevance_str = f"{relevance_float:.2f}" except (ValueError, TypeError): relevance_str = str(relevance)