From 4d67cc8d8335a63eaff575441c5bde455baac58f Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sat, 15 Nov 2025 21:09:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(prompt):=20=E4=BF=AE=E5=A4=8D=E6=8A=97?= =?UTF-8?q?=E5=AE=A1=E6=9F=A5=E6=8C=87=E4=BB=A4=E8=A2=AB=E6=97=A0=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E6=B7=BB=E5=8A=A0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在之前的提交中,抗审查指令被错误地设置为无条件添加。本次提交修正了此逻辑,将其与 `enable_prompt_perturbation` 开关关联,确保只有在启用提示词扰动时才会添加该指令,恢复了预期的行为。 此外,还简化了反截断指令的条件判断,直接访问 `model_info.anti_truncation` 属性以提高代码的可读性。 --- src/llm_models/utils_model.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/llm_models/utils_model.py b/src/llm_models/utils_model.py index c3f4dc567..a46824a72 100644 --- a/src/llm_models/utils_model.py +++ b/src/llm_models/utils_model.py @@ -500,8 +500,9 @@ class _PromptProcessor: final_prompt_parts = [] user_prompt = prompt - # 步骤 A: (可选) 添加抗审查指令 - final_prompt_parts.append(self.noise_instruction) + # 步骤 A: 添加抗审查指令 + if model_info.enable_prompt_perturbation: + final_prompt_parts.append(self.noise_instruction) # 步骤 B: (可选) 应用统一的提示词扰动 if getattr(model_info, "enable_prompt_perturbation", False): @@ -515,7 +516,7 @@ class _PromptProcessor: final_prompt_parts.append(user_prompt) # 步骤 C: (可选) 添加反截断指令 - if getattr(model_info, "use_anti_truncation", False): + if model_info.anti_truncation: final_prompt_parts.append(self.anti_truncation_instruction) logger.info(f"模型 '{model_info.name}' (任务: '{task_name}') 已启用反截断功能。") @@ -881,7 +882,7 @@ class _RequestStrategy: # --- 响应内容处理和空回复/截断检查 --- content = response.content or "" - use_anti_truncation = getattr(model_info, "use_anti_truncation", False) + use_anti_truncation = model_info.anti_truncation processed_content, reasoning, is_truncated = await self.prompt_processor.process_response( content, use_anti_truncation )