From 93659d279b48d4ca7a7fb8e5a3abf75e8c1411d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AA=E6=9D=A5?= Date: Fri, 1 May 2026 10:07:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=86=99=E4=BD=9C?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E5=9C=A8=E7=AB=A0=E8=8A=82=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=97=B6=E8=A2=AB=E9=87=8D=E5=A4=8D=E6=B3=A8=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 写作风格(style_content)同时被注入到 system_prompt 和 user prompt 中, 导致 AI 收到两份相同的风格指令。现在 apply_style_to_prompt() 仅追加 输出格式指令,风格注入统一由 system_prompt_with_style 负责。 --- backend/app/services/prompt_service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/app/services/prompt_service.py b/backend/app/services/prompt_service.py index fdf9f09..9b38579 100644 --- a/backend/app/services/prompt_service.py +++ b/backend/app/services/prompt_service.py @@ -11,15 +11,18 @@ class WritingStyleManager: """ 将写作风格应用到基础提示词中 + 注意:写作风格已通过 system_prompt 注入(system_prompt_with_style), + 此方法仅追加输出指令,不再重复注入 style_content,避免风格信息被注入两次。 + Args: base_prompt: 基础提示词 - style_content: 风格要求内容 + style_content: 风格要求内容(已通过 system_prompt 注入,此处不使用) Returns: - 组合后的提示词 + 追加输出指令后的提示词 """ - # 在基础提示词末尾添加风格要求 - return f"{base_prompt}\n\n{style_content}\n\n请直接输出章节正文内容,不要包含章节标题和其他说明文字。" + # 写作风格已在 system_prompt 中注入,此处只追加输出格式指令 + return f"{base_prompt}\n\n请直接输出章节正文内容,不要包含章节标题和其他说明文字。" class PromptService: