From c21a1127f82a05700a6a082c47743f3c25b82630 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 16 Jun 2026 19:50:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=90=E7=82=BC=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=8A=A0=E5=AE=BD,=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87=E5=8E=8B=E7=BC=A9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/components/wiki/KnowledgeManage.tsx | 2 +- offline-backend-20260512/backend/config.yaml | 22 +++++++++++++++++++ offline-backend-20260512/config.yaml | 11 ++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/frontend-web/src/components/wiki/KnowledgeManage.tsx b/frontend-web/src/components/wiki/KnowledgeManage.tsx index bb6a5345..de42b5ea 100644 --- a/frontend-web/src/components/wiki/KnowledgeManage.tsx +++ b/frontend-web/src/components/wiki/KnowledgeManage.tsx @@ -304,7 +304,7 @@ export function ExtractTemplateManageDialog({ return ( - + 抽取提示词模板 diff --git a/offline-backend-20260512/backend/config.yaml b/offline-backend-20260512/backend/config.yaml index 4f1c6569..95094ee9 100644 --- a/offline-backend-20260512/backend/config.yaml +++ b/offline-backend-20260512/backend/config.yaml @@ -190,6 +190,28 @@ title: User: {user_msg} Assistant: {assistant_msg} +# 上下文压缩(对话摘要):长对话接近上下文上限时,把较早的消息总结成一段摘要, +# 只保留最近若干条原始消息,避免撑爆模型上下文窗口。 +# - trigger:触发条件,可配多个,任意一个先满足就压缩(OR 关系)。真正决定何时 +# 压缩的是 trigger(不是 keep)。type=tokens 按 token 总数;type=messages 按条数。 +# - keep:压缩后保留多少最近的上下文(tokens / messages)。 +# - trim_tokens_to_summarize:喂给摘要模型的消息最多裁到多少 token。 +# 当前为「测试值(易触发)」:发到服务器后稍微聊几句就会触发,可在 Gateway 日志里 +# grep「上下文压缩」/「context compaction」确认生效;确认后再调回生产值 +# (trigger tokens 60000 / messages 80,keep tokens 16000)。 +summarization: + enabled: true + # model_name: deepseek-chat # 留空则用主对话模型 + trigger: + - type: tokens + value: 8000 + - type: messages + value: 12 + keep: + type: messages + value: 6 + trim_tokens_to_summarize: 4000 + tool_groups: - name: web - name: file:read diff --git a/offline-backend-20260512/config.yaml b/offline-backend-20260512/config.yaml index 3a057ca7..6070507e 100644 --- a/offline-backend-20260512/config.yaml +++ b/offline-backend-20260512/config.yaml @@ -307,9 +307,9 @@ summarization: # model_name: deepseek-chat trigger: - type: tokens - value: 60000 + value: 8000 - type: messages - value: 80 + value: 12 # Keep a small *token* budget of recent context (same unit as the token # trigger, well below it). This is what the model receives after compaction: # [summary, ~16000 tokens of recent turns]. Small keep = small model context @@ -318,6 +318,9 @@ summarization: # which spans many turns. The full conversation still stays in state for the # page; only what is sent to the model is compressed. keep: - type: tokens - value: 16000 + type: messages # 测试值:压缩后只保留最近 6 条原始消息 + value: 6 + # 生产值改用 token 预算: + # type: tokens + # value: 16000 trim_tokens_to_summarize: 4000