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:
吉鑫升andClaude Opus 4.8 committed 2026-06-16 21:07:17 +08:00
1 parent b380575f16
commit 342fa8265a
12 files changed
+170 -22

No files matched your search

+12 -1
View File
@@ -176,10 +176,21 @@ function BatchImportDialog({
skip_existing: skipExisting,
status: "approved",
include_sources: true,
// Run in the background so the request returns immediately — a large
// batch otherwise blocks past the gateway timeout and shows "request
// failed". Threads stream into the list as they finish.
background: true,
model_name: model,
template_id: template,
folder,
});
if (result.queued) {
toast.success(
`已转入后台导入 ${result.processed} 个线程,完成后会陆续出现在左侧列表(可稍后刷新查看)`,
);
onOpenChange(false);
return;
}
const base = `批量导入完成:新增 ${result.created},跳过 ${result.skipped},失败 ${result.failed}`;
if (result.llm_fallback && result.llm_fallback > 0) {
// The model failed on some threads — they were saved via rule-based
@@ -549,7 +560,7 @@ export default function KnowledgeBasePage() {
keyword: debouncedKeyword || undefined,
source_type: sourceType === "all" ? undefined : sourceType,
status: status === "all" ? undefined : status,
limit: 500,
limit: 1000,
}),
[debouncedKeyword, sourceType, status],
);