From b53f7280863f25b987172ff0eefcf5d578fcdc38 Mon Sep 17 00:00:00 2001 From: Windpicker-owo <3431391539@qq.com> Date: Mon, 18 Aug 2025 02:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E9=80=89=E6=98=AF=E5=90=A6=E5=90=91?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D=E6=8F=92=E5=85=A5=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/utils/prompt_builder.py | 5 +++++ src/config/official_configs.py | 3 +++ template/bot_config_template.toml | 1 + 3 files changed, 9 insertions(+) diff --git a/src/chat/utils/prompt_builder.py b/src/chat/utils/prompt_builder.py index ab8ab3d9..ca94d542 100644 --- a/src/chat/utils/prompt_builder.py +++ b/src/chat/utils/prompt_builder.py @@ -25,6 +25,11 @@ def get_tool_history_prompt(message_id: Optional[str] = None) -> str: Returns: 格式化的工具历史提示词 """ + from src.config.config import global_config + + if not global_config.tool.history.enable_prompt_history: + return "" + return tool_history_manager.get_recent_history_prompt( chat_id=message_id ) diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 37adc2e4..4239efcb 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -289,6 +289,9 @@ class ToolHistoryConfig(ConfigBase): enable_history: bool = True """是否启用工具历史记录""" + + enable_prompt_history: bool = True + """是否在提示词中加入工具历史记录""" max_history: int = 100 """历史记录最大保存数量""" diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index d43ece1c..db713ec5 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -116,6 +116,7 @@ enable_tool = false # 是否在普通聊天中启用工具 [tool.history] enable_history = true # 是否启用工具调用历史记录 +enable_prompt_history = true # 是否在提示词中加入工具历史记录 max_history = 5 # 每个会话最多保留的历史记录数 [mood]