feat: 知识批量沉淀改为后台任务,避免 nginx 504
- /ingest/threads/batch 新增 background 参数(默认 true),立即返回 {queued:true}
- 抽取循环抽出 _run_batch_ingest,后台路径显式传入 created_by
- 前端知识库页与输入框、线程 hooks/types 配套调整
- config.yaml 上下文压缩测试值
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b380575f16
commit
342fa8265a
12 files changed
+170
-22
No files matched your search
+17
-5
@@ -54,12 +54,19 @@ def _resolve_model_name(requested_model_name: str | None = None, *, app_config:
|
||||
return default_model_name
|
||||
|
||||
|
||||
def _create_summarization_middleware(*, app_config: AppConfig | None = None) -> DeerFlowSummarizationMiddleware | None:
|
||||
"""Create and configure the summarization middleware from config."""
|
||||
def _create_summarization_middleware(*, app_config: AppConfig | None = None, force_enabled: bool = False) -> DeerFlowSummarizationMiddleware | None:
|
||||
"""Create and configure the summarization middleware from config.
|
||||
|
||||
Args:
|
||||
force_enabled: When True, build the middleware regardless of the config
|
||||
``summarization.enabled`` flag. The per-request 上下文压缩 toggle
|
||||
(chat input box, default off) drives this — the config file no longer
|
||||
owns the on/off switch, only the tuning (trigger/keep/...).
|
||||
"""
|
||||
resolved_app_config = app_config or get_app_config()
|
||||
config = resolved_app_config.summarization
|
||||
|
||||
if not config.enabled:
|
||||
if not (config.enabled or force_enabled):
|
||||
return None
|
||||
|
||||
# Prepare trigger parameter
|
||||
@@ -268,8 +275,13 @@ def _build_middlewares(
|
||||
if cfg.get("rag_mode_enabled", False):
|
||||
middlewares.append(RagCitationMiddleware())
|
||||
|
||||
# Add summarization middleware if enabled
|
||||
summarization_middleware = _create_summarization_middleware(app_config=resolved_app_config)
|
||||
# Add summarization middleware. The on/off switch now lives in the chat UI
|
||||
# (上下文压缩 toggle, default off) and arrives as ``summarization_enabled`` in
|
||||
# the runtime config; the config file only supplies tuning. force_enabled
|
||||
# lets the per-request toggle turn it on even when config.enabled is false,
|
||||
# while non-UI paths (channels/scheduled) still fall back to config.enabled.
|
||||
summarization_requested = cfg.get("summarization_enabled", False)
|
||||
summarization_middleware = _create_summarization_middleware(app_config=resolved_app_config, force_enabled=summarization_requested)
|
||||
if summarization_middleware is not None:
|
||||
middlewares.append(summarization_middleware)
|
||||
|
||||
|
||||
Reference in new issue
Block a user