feat: 贯通 context_window 配置并按 token 预算裁剪对话历史

This commit is contained in:
2026-09-20 14:22:53 +08:00
parent 8251a57010
commit 4114b0b4fb
21 changed files with 307 additions and 42 deletions
+7
View File
@@ -38,6 +38,13 @@ class Settings(BaseSettings):
mcp_tools_enabled: bool = True
chat_history_limit: int = 40
# 从 Mongo 最多拉多少条再按 token 裁剪(应 ≥ 条数窗口时代的 limit)
chat_history_fetch_limit: int = 200
# 未配置 context_window 且模型名无法识别时的默认
llm_default_context_window: int = 128000
# 为模型输出与本轮 tool 预留的 token
context_reserve_output_tokens: int = 4096
context_reserve_tool_tokens: int = 8192
@property
def cors_origin_list(self) -> list[str]: