sync update from LAN repo (source ji @ 85078a31)
This commit is contained in:
1 parent
5d6627af50
commit
e602d88695
864 files changed
+99150
-6346
No files matched your search
@@ -8,6 +8,15 @@
|
||||
|
||||
DeerFlow is a LangGraph-based AI super agent with sandbox execution, persistent memory, and extensible tool integration. The backend enables AI agents to execute code, browse the web, manage files, delegate tasks to subagents, and retain context across conversations - all in isolated, per-thread environments.
|
||||
|
||||
The dedicated wx chat entry (`#/page/workspace/wx/chats/new`) is fixed to the
|
||||
deep-blue presentation and has no global header or page sidebar. Its retained
|
||||
workspace panel keeps its original recommendation logic until wx selects an
|
||||
Agent Gallery category: `我的`, a configured publish square such as
|
||||
`默认广场`, or `舆情分析`. The shared optional selection is stored in
|
||||
`system_settings.json` → `wx_common_agents`; the `wx` account and
|
||||
administrators may update or clear it through
|
||||
`/api/system-settings/wx-common-agents`.
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
@@ -51,6 +60,22 @@ Health probes are always unauthenticated, even when API authentication is enable
|
||||
|
||||
## Core Components
|
||||
|
||||
### 项目空间
|
||||
|
||||
前端入口为 `/page/workspace/projects`。项目作为现有问答的分类容器,保留工作区左侧聊天记录。创建项目时选择问答、策略智能或方案生成,创建后不可修改模式;可设置默认智能体,并在新建每条项目对话时另选智能体。方案生成复用「工作流配置 · 报告结构」的结构库和现有写作研究管线;策略智能支持可配置 Lens、多视角独立分析、策略辩论与综合决策。
|
||||
|
||||
Gateway `/api/analysis-projects` 提供列表、创建、查询、更新及 `/{id}/threads` 新建和查询对话。项目与对话归属存储在 `analysis_projects` / `analysis_project_threads`,智能体、Lens、报告结构等扩展配置存储在 `analysis_project_configs`;这些表随数据库初始化自动创建,内存部署不跨重启保存。项目按登录用户隔离,模式和归属不接受客户端元数据覆盖。策略智能可在无知识库时基于用户条件推演,但必须标出假设与资料缺口。方案生成调用现有 `deep_research_report` 研究管线,使用项目选择的固定或弹性报告结构,复用方案画布和后续修改流程。
|
||||
|
||||
方案生成的首份交付对用户呈现为简单两步:先像普通问答一样讨论并自然理解需求,系统会先用自然语言复述识别到的真实目标、面向对象、成功结果与边界,并随用户补充持续修正;仅在影响方案的关键信息缺失时少量追问。信息足够时给出简短、非表单式的「意图理解」,并在不可见的 HTML 注释中写入包含目标、受众、成功结果、范围、约束、交付物、验收标准及待确认问题的结构化快照。只有服务器从最新助手回复解析出字段完整、`open_questions` 为空的唯一快照和就绪标记,且本轮用户点击「结束问答并生成方案」时,才进入正式方案生成;该权威快照会随运行上下文交给报告生成。客户端传入的 `solution_requirements_confirmed` 或 `solution_intent` 会被覆盖,不能跳过闸门。已有 `report.md` 的对话仍可直接进入后续修改。
|
||||
|
||||
关键问题通过统一澄清卡呈现:普通方案需求第一步至少给出 1 个最关键的决策问题,每个问题提供 2–4 个可点击选项并保留「其他/我补充」入口,总量控制在 1–3 个,不再只输出一段无法继续的普通文本或未经选择便直接就绪。用户也可随时点击「直接生成方案」;Gateway 仅接受当前最后一条用户消息中的专用令牌,忽略客户端伪造的上下文字段,并复用最近的合法意图快照(没有则从完整对话推断),把缺失项明确标成暂定假设后直接生成。确认或强制生成轮必须实际调用研究管线并产出 `/mnt/user-data/outputs/report.md`,否则中间件会拒绝“已生成/已展示”式的虚假完成回复;本轮真实生成失败时明确提示失败并结束,不在后台自动循环重试,用户可点击「重新生成方案」发起新一轮。
|
||||
|
||||
方案项目的最终 `report.md` 不使用 `[1]`、`【1】` 等数字引用标记。研究管线仍可使用检索资料,但会在 solution 专属写作要求和落盘后处理两层保证正文无数字标记;参考来源保留为无编号项目列表。该规则仅影响方案项目,普通写作与深度研究保持原有编号引用行为。
|
||||
|
||||
项目线程会由服务端同步只读展示元数据 `analysis_project_id`、`analysis_project_mode`、`analysis_project_name`,供最近对话显示项目类型与所属项目并在项目改名后刷新;真正的项目归属仍只以 `analysis_project_threads` 绑定表为准,客户端不能借此移动线程。
|
||||
|
||||
验证:`python -m pytest tests/test_analysis_projects.py tests/test_deep_research_report_tool.py tests/test_writing_mode_report_middleware.py -q`。
|
||||
|
||||
### Lead Agent
|
||||
|
||||
The single LangGraph agent (`lead_agent`) is the runtime entry point, created via `make_lead_agent(config)`. It combines:
|
||||
@@ -61,10 +86,22 @@ The single LangGraph agent (`lead_agent`) is the runtime entry point, created vi
|
||||
- **Subagent delegation** for parallel task execution
|
||||
- **System prompt** with skills injection, memory context, and working directory guidance
|
||||
|
||||
普通问答采用严格的输出载体门禁:只有本次请求明确要求 HTML、网页、页面、看板、大屏或 `.html` 文件时,才允许读取网页生成技能、调用页面模板工具或创建 HTML;“画流程图”“画图表”“画地图”“画思维导图”“做可视化”本身都不构成 HTML 意图。普通流程图直接在消息中输出 Mermaid,普通图表沿用既有消息内方式,普通地图输出 `map-json`。只有本次请求明确要求“思维导图 / 脑图 / 知识导图”或点名 `analysis-mindmap` 时,才会输出专用 `mindmap-json`;普通分析、总结、提纲和结构化 JSON 不会自动生成导图。未闭合的 `mindmap-json`(兼容历史 `mindmap` 围栏)会原样作为代码块流式显示,闭合且本地校验通过后才懒加载横向分析树预览。导图必须是一棵含唯一根节点的受限层级树:目标 12–24 个节点、硬上限 36 个,最多 4 层(含中心主题),中心主题至多 6 个一级维度、每个后续节点至多 3 个子节点;不得把报告的每个数据、段落或引用逐条转成节点。点击父节点本身,或其连线起点处的+/−,即可展开/收起子节点,且连接线明确可见;全量弹窗的右上角含关闭与视图工具、右下角含由实际布局绘制的全图预览,消息预览同样支持拖动、滚轮缩放和视图工具;消息卡片的单个下载图标会打开 PNG、SVG、JSON 选项。明确的 HTML 请求必须进入沙箱生成 `/mnt/user-data/outputs/*.html` 并通过 `present_files` 打开右侧制品预览,禁止用聊天中的完整 HTML 代码块代替文件。前端负责本地校验和渲染,并兼容模型误写成普通 `json` 围栏的合法地图契约;只有包含地图字段且通过完整 schema 校验的 JSON 才会按地图渲染,其他 JSON 保持原代码块。地图卡片占满消息内容区,与步骤条左右边界对齐;格式错误时显示可读错误与原始数据,不中断整条消息。
|
||||
|
||||
生成 `.html` 网页、看板或大屏时使用独立的离线绘图契约:流程图使用 `data-df-flow` + AntV G6(不使用 Mermaid),图表使用 `data-df-chart`,地图使用本地 GeoJSON + ECharts Canvas 的 `data-df-geo`。Gateway 从公开路径 `/api/public/html-runtime/` 提供浏览器版 `g6.min.js`、`echarts.min.js`、统一初始化脚本 `deerflow-runtime.js`,以及中国省级、美国州级、日本都道府县、台湾地区县市四份地图资源(`china-provinces` / `us-states` / `japan-prefectures` / `taiwan-counties`)。生成的 HTML 源码会直接引用这些后台文件,不依赖前端 React 构建产物、Leaflet、地图瓦片或公网 CDN;区域/标点的 `description` 在点击后由运行时显示详情浮层。这些文件作为 `packages/harness/deerflow/html_runtime/assets/` 的包资源随 harness wheel 一起发布,来源与许可见 `assets/maps/ATTRIBUTION.md`。`config.yaml -> html_runtime.base_url` 必须填写浏览器可访问的 Gateway Runtime 地址(本机默认 `http://localhost:8001/api/public/html-runtime`),运行时据此解析本地 GeoJSON 地址;内网部署只需把它替换为实际 Gateway 地址。该能力不改变普通问答消息列表,普通问答地图仍走原有 `map-json` 前端瓦片渲染与 `frontend-web/public/runtime-config.js` 的 `VITE_MAP_TILE_URL`。地图大屏使用“中间地图舞台”而非整页地图背景:中间地图保持可见和可点击,两侧为窄信息栏、底部为摘要面板;提到的城市和行政区必须分别写入 `markers` 与高亮 `regions`。
|
||||
|
||||
从已有 Markdown 报告生成 HTML 时,必须根据材料盘点 Mermaid/流程图、图表及地图,并在 `page_report_template validate` 的 `required_features` 和 `page_brief` 中如实声明。流程图必须包含 `g6.min.js`、`deerflow-runtime.js`、`.df-flow` 与 `data-df-flow`,并拒绝 Mermaid、手写 HTML/CSS 流程节点以及页面内自行初始化 `G6.Graph`;图表和地图分别检查 ECharts 资源与 `data-df-chart` / `data-df-geo` 声明式数据块。`data-df-chart` 必须是严格 JSON,校验会拒绝函数、箭头函数和其他 JavaScript 回调;颜色使用字面量或数据项 `itemStyle`,提示文本使用字符串模板。地图只能使用上述四个内置 GeoJSON,校验会拒绝 Leaflet、`data-df-map`、瓦片和页面内自行初始化 ECharts。默认页面从零开始直接写入最终 outputs HTML,不读取或预览模板;只有用户明确要求模板时,prepare 才会把要求持久化到同名 brief,validate 会自动恢复并与调用参数合并。校验失败时不得交付,必须修复后重新校验。
|
||||
|
||||
HTML 默认采用单页面:validate 在 `preferred_page_count` 省略时按 `1` 处理;只有用户直接提出“多页面 / 多页 / 多个页面 / 分页门户”或指定页数时,模型才可传入大于 `1` 的页数。用户明确要求模板时,prepare 会严格排除页数模式不符的模板,并把 `requested_page_count` 与 `page_mode` 写入 brief。单页模式检测到多个 `data-page`、tabpanel、`.report-page` 或 `.view` 页面视图时验证失败,内容长度和 Markdown 章节数不构成多页理由。
|
||||
|
||||
HTML 流程图节点采用浅色语义圆角卡片、同色系描边和深色高对比文字,节点文字居中并带类型前缀。运行时严格尊重页面声明的 `LR` / `TB` 方向和容器高度,不再自行改方向或把容器撑穿后续区块;单图超过 8 个节点时,页面生成规则要求拆图,或使用至少 600px 高的 `TB` 布局。画布保留拖动和缩放能力。
|
||||
|
||||
普通 HTML 默认不读取模板库、不选择模板,而是直接用 `write_file` 在 `/mnt/user-data/outputs/` 从空白文件生成;写入开始即可自动打开右侧沙箱。只有用户明确要求使用模板时才调用 catalog/prepare,此时可选 `light-document` / `dark-document` 响应式文档模板,且 `working_copy` 与 `final_output` 是同一路径。普通页面自然纵向滚动、主体限制最大宽度、移动端降为单列;只有 `page_brief` 明确包含大屏、驾驶舱、单屏或固定画布意图时才允许屏幕式布局。文档模式校验会拒绝 `html/body overflow:hidden`、1920×1080 整页缩放、过矮流程图和过长横向流程。
|
||||
|
||||
### Workflow Studio runtime
|
||||
|
||||
- Candidate workflow graphs remain editable after they are loaded into the Coze-compatible canvas; the compatibility response explicitly marks the current owner as editable so node dragging is not mistaken for a read-only preview.
|
||||
- Workflow-agent SSE forwards provider `reasoning_content` as an inline `<think>…</think>` trace for the UI while keeping the executable node output limited to the visible answer text. Every native LangGraph `[AIMessage|ToolMessage, metadata]` frame is additionally persisted and sent as `node.message.data.messages` without projection or length cropping, so the Studio can replay DeerFlow's tool-result, search-result and `ask_clarification` cards exactly after reconnecting.
|
||||
- OpenAI-compatible model responses accept both `reasoning_content` and `reasoning`; both are normalized into the existing reasoning display path. Models marked `supports_thinking: true` also receive `enable_thinking: true` when thinking mode is active unless an explicit `when_thinking_enabled` configuration overrides it. Workflow-agent SSE forwards provider reasoning as an inline `<think>…</think>` trace for the UI while keeping the executable node output limited to the visible answer text. Every native LangGraph `[AIMessage|ToolMessage, metadata]` frame is additionally persisted and sent as `node.message.data.messages` without projection or length cropping, so the Studio can replay DeerFlow's tool-result, search-result and `ask_clarification` cards exactly after reconnecting.
|
||||
|
||||
### AgentScope report collaboration (in progress)
|
||||
|
||||
@@ -79,7 +116,7 @@ Middlewares execute in strict order, each handling a specific concern:
|
||||
| 1 | **ThreadDataMiddleware** | Creates per-thread isolated directories (workspace, uploads, outputs) |
|
||||
| 2 | **UploadsMiddleware** | Injects newly uploaded files into conversation context |
|
||||
| 3 | **SandboxMiddleware** | Acquires sandbox environment for code execution |
|
||||
| 4 | **SummarizationMiddleware** | Reduces context when approaching token limits (optional) |
|
||||
| 4 | **SummarizationMiddleware** | Reduces context near token limits and folds the hidden summary into one leading system message for strict model adapters (optional) |
|
||||
| 5 | **TodoListMiddleware** | Tracks multi-step tasks in plan mode (optional) |
|
||||
| 6 | **TitleMiddleware** | Auto-generates conversation titles after first exchange |
|
||||
| 7 | **MemoryMiddleware** | Queues conversations for async memory extraction |
|
||||
@@ -93,9 +130,9 @@ Per-thread isolated execution with virtual path translation:
|
||||
- **Abstract interface**: `execute_command`, `read_file`, `write_file`, `list_dir`
|
||||
- **Providers**: `LocalSandboxProvider` (filesystem) and `AioSandboxProvider` (Docker, in community/)
|
||||
- **Virtual paths**: `/mnt/user-data/{workspace,uploads,outputs}` → thread-specific physical directories
|
||||
- **Skills path**: `/mnt/skills` → `deer-flow/skills/` directory
|
||||
- **Skills path**: `/mnt/skills` → an online-only view under `DEER_FLOW_HOME`; the canonical `deer-flow/skills/` tree remains administrative storage
|
||||
- **Portable configured mounts**: a relative `sandbox.mounts[*].host_path` is resolved against the directory containing the loaded `config.yaml`, not the process working directory. Providers still receive an absolute host path, so `knowledge/knowledge_base` can be committed and the deployment can be cloned or moved without editing a machine-specific path; already-absolute mount paths are preserved.
|
||||
- **Skills loading**: Recursively discovers nested `SKILL.md` files under `skills/{public,custom}` and preserves nested container paths
|
||||
- **Skills loading**: Recursively discovers nested `SKILL.md` files under `skills/{public,custom}` and preserves nested container paths. Administrators can take a skill offline without deleting it: the persisted `enabled: false` state keeps the files and existing agent references intact while removing the skill from model-facing discovery, prompt injection, new skill selection, and direct `/mnt/skills` file/command access. Bringing it online again restores those references automatically; launcher-managed runtime configuration lives in a writable persisted directory.
|
||||
- **Conditional WeKnora LLMWiki**: a non-empty `llmwiki.weknora.api_base_url` enables the DeerFlow-native WeKnora BFF and UI; an empty address preserves the existing LLMWiki page. WeKnora remains independently deployed and owns its database, Redis, storage, parsers and models. DeerFlow keeps only the API/admin addresses, user/publication mappings, agent knowledge-base bindings and per-conversation selections; it stores and sends no WeKnora credential, so the endpoint must be restricted to a trusted network and allow DeerFlow traffic. Owners publish directly to the public LLMWiki without an approval queue for ordinary bases; the system-owned conversation-deposit base is always published, shared by all users, excluded from My Knowledge, immutable through user/admin detail operations, and recognized by both its reserved name and `system` owner. An existing same-name remote mapping is adopted in place as the system deposit so its mapping id and document links stay valid. Its user-facing knowledge-base description and generated document metadata use the `cmzs` brand; list/detail reads synchronize stale remote descriptions, while conversation-deposit search results, source previews and embedded-detail JSON rewrite legacy brand text to `cmzs`. Deposit requests must reference a thread accessible to the current account. Personal knowledge-base lists are scoped to the current DeerFlow account even for admins, while frontend LLMWiki query caches also include the active account id so switching accounts cannot reuse another account's list/detail data. Admins remain the only role that sees the WeKnora connection-config tab. Knowledge cards open a dedicated WeKnora-style detail route: Wiki-enabled bases default to Wiki, then documents and graph; standard bases hide Wiki and default to documents. Writable ordinary knowledge-base details expose a native multi-file upload action that submits files sequentially and reports aggregate success/failure; read-only public bases and the system deposit base do not. It supports file/URL/manual-Markdown imports, Wiki page browsing, document preview, real parsed chunks and Wiki graph nodes/edges. New chats use a compact WeKnora-style searchable/grouped multi-select inside the composer, while agent create/edit pages bind spaces through an inline panel. A single proxy service identity means DeerFlow users are isolated logically while their WeKnora entities share that identity's workspace. The read-only `llmwiki_search` tool reauthorizes the current DeerFlow user on every call and renders credential-free source previews; source previews prefer cleaned Wiki/LLMWiki text when a retrieved chunk maps to a Wiki page, with raw chunks as the fallback. The detail page first creates a signed iframe session through the normal DeerFlow API auth path, then points the iframe directly at the proxied WeKnora `/platform/...` route using the signed `deerflow_weknora_embed` cookie; global auth/CSRF bypass is limited to those signed iframe proxy requests, and HTTPS cookie attributes honor `X-Forwarded-Proto` behind reverse proxies. The iframe proxy keeps WeKnora's root-relative `/platform`, `/assets`, `/locales`, and `/api/v1/*` paths, but is registered last through `llmwiki.proxy_router` so it cannot intercept first-party Gateway APIs such as `POST /api/v1/auth/login/username`. See [docs/LLMWIKI_WEKNORA_INTEGRATION_ZH.md](docs/LLMWIKI_WEKNORA_INTEGRATION_ZH.md).
|
||||
- **Enterprise Research workbench (temporarily disabled)**: the independent `/api/enterprise-research` router, its report executor, and its ORM table registration are intentionally inactive. The implementation remains in the repository, but startup does not create or alter `enterprise_research_tasks` or `enterprise_research_report_jobs`; this keeps the active Deep Research workflow independent of the paused workbench and avoids MySQL schema errors.
|
||||
- **Embedded WeKnora detail chrome**: the proxy hides WeKnora's application sidebar (`.main > .aside_box`) and expands the detail outlet to the full iframe width, while preserving the Wiki page's own index/navigation panel. The host does not sandbox this trusted, permission-filtered detail frame because browser PDF viewers are disabled inside sandboxed ancestor frames. Preview and knowledge-base file redirects are followed by the Gateway so PDF bytes and protected Wiki images remain inside the authorized proxy instead of leaking to an unreachable object-storage URL.
|
||||
@@ -154,23 +191,26 @@ FastAPI application providing REST endpoints for frontend integration:
|
||||
|-------|---------|
|
||||
| `GET /api/models` | List available LLM models |
|
||||
| `GET/PUT /api/mcp/config` | Manage MCP server configurations |
|
||||
| `GET/PUT /api/skills` | List and manage skills |
|
||||
| `GET /api/skills`, `PUT /api/skills/{name}` | List skills; administrators can toggle any skill and ordinary users can toggle their own custom skills without deleting them |
|
||||
| `POST /api/skills/install` | Install skill from `.skill` archive |
|
||||
| `POST /api/skills/validate`, `POST /api/skills/install-upload` | Validate and upload `.zip`/`.skill` packages with owner-aware conflicts: owners may explicitly overwrite their own copy; other users' copies report the uploader and cannot be overwritten |
|
||||
| `GET/POST /api/agents` | List visible agents or create a user-owned agent |
|
||||
| `GET/PUT/DELETE /api/agents/{id}` | Read, update, or delete an id-addressed agent |
|
||||
| `GET/POST/PUT/DELETE /api/roundtable-chains` | Manage user-owned roundtable business chains; each seat may optionally carry `position_id` for the separate position-collaboration workspace, plus `human_validation` to mark a Step 2 client-side pause checkpoint after that seat/stage completes (the original roundtable has no extra validation card) |
|
||||
| `GET/PUT /api/business-mapping` | Read global business mappings. Updates to 3Q/6BF/7BF require an administrator; the 8BF public business-chain mapping is maintained exclusively by the trusted `lqq` account (derived from the authenticated email prefix). |
|
||||
| `GET/PUT /api/business-mapping` | Read global business mappings (seeded 3Q/6BF/7BF/8BF/AFX plus independent slots 3q-1…3q-5, 6-1…6-4, 7-1…7-4). Updates to 3Q/6BF/7BF and the independent slots require an administrator; the 8BF public business-chain mapping is maintained exclusively by the trusted `lqq` account (derived from the authenticated email prefix). |
|
||||
| `GET/POST/PUT /api/position-roundtable/sessions` | Standalone position-collaboration sessions: freeze task/intent/chain snapshots, index one direct-agent node per seat, build upstream handoff context (including bounded UTF-8 excerpts of text artifacts), and make archived sessions read-only without invoking the original roundtable coordinator or jobs. Built-in summary/action-plan completion mirrors visible report text into a Markdown artifact when a model omits its final `write_file` call. `POST /sessions/{id}/nodes/{nodeKey}/reject` accepts an optional reason, marks the rejected delivery for rework, and invalidates affected downstream deliveries so they are regenerated in order. The same router is also mounted at `/api/multi-agent/position-roundtable/*` for intranet gateways that only forward the established multi-agent namespace; the compatibility mount is intentionally omitted from OpenAPI. |
|
||||
| `GET /api/memory` | Retrieve memory data |
|
||||
| `POST /api/memory/reload` | Force memory reload |
|
||||
| `GET /api/memory/config` | Memory configuration |
|
||||
| `GET /api/memory/status` | Combined config + data |
|
||||
| `POST /api/threads/{id}/uploads` | Upload files (auto-converts PDF/PPT/Excel/Word to Markdown, rejects directory paths) |
|
||||
| `GET/PUT /api/upload-policy`, `POST /api/upload-policy/reset` | Read the database-backed global upload policy; administrators atomically replace it or restore the persisted defaults. Defaults: 20 files, 100 MiB total, documents/images 10 MiB each, spreadsheets 5 MiB, large-file output 12,000 characters with a non-disableable 32,000-character hard ceiling. |
|
||||
| `POST /api/threads/{id}/uploads` | Upload a staged all-or-nothing batch under the current database policy. The Gateway enforces category extension/size limits, validates text/image/PDF/Office signatures, and optionally converts PDF/PPT/Excel/Word to a collision-free `<original-name>.<ext>.md` companion. |
|
||||
| `GET /api/threads/{id}/uploads/list` | List uploaded files |
|
||||
| `DELETE /api/threads/{id}` | Delete DeerFlow-managed local thread data after LangGraph thread deletion; unexpected failures are logged server-side and return a generic 500 detail |
|
||||
| `GET /api/artifact-library` | List the current user's generated conversation files across normal threads, with filename/conversation search, file-kind filtering, pagination, and an optional cache-bypassing refresh. The filesystem `outputs/` directories remain authoritative; uploads and image/audio/video files are excluded. |
|
||||
| `GET /api/threads/{id}/artifacts/{path}` | Serve generated artifacts |
|
||||
| `GET /api/artifact-library` | List the current user's generated documents across normal threads and completed strategy-selection project snapshots, with name/source search, file-kind/source filtering, pagination, and an optional cache-bypassing refresh. Thread `outputs/` directories remain authoritative for conversation files; strategy syntheses are projected from the owner-scoped `parallel_agent_tasks` snapshot. Strategy items carry `source_type=strategy`, `strategy_project_id`, `strategy_name`, `strategy_stale`, an explicit `strategy_source_kind` (`strategy_selection` or `analysis_project`), and `download_url` when they use the dedicated virtual-document route. Uploads and image/audio/video files are excluded. |
|
||||
| `GET /api/strategy-project-artifacts/{id}/download` | Download the current user's completed strategy-selection synthesis as Markdown. Ownership and the versioned strategy snapshot are revalidated on every request; stale-but-completed historical syntheses remain downloadable. |
|
||||
| `GET /api/threads/{id}/artifacts/{path}` | Stream generated artifacts without materialising the whole file in Gateway memory. |
|
||||
| `GET /api/threads/{id}/artifact-preview` | Return a bounded text preview; large files use streaming full-file statistics and deterministic head/middle/tail samples. |
|
||||
| `GET/POST /api/deep-research/*` | Durable Deep Research sessions and jobs. `quick`/`basic` run the compact report flow; `detailed` plans subtopics and writes independent sections; `deep` recursively investigates bounded follow-up branches. All modes reuse DeerFlow's configured material provider, LLM factory, hidden-thread artifacts, and SSE event log. Deep Research session/job/event/source/message writes serialise their rows in the writer transaction, rather than doing a post-commit ORM refresh or readback; this prevents MySQL read/write-splitting replica lag from failing “start writing”, dispatcher claim, report persistence, or follow-up history. Whole-document artifact/report rewrites likewise create their reversible version snapshots from writer-local ORM data and never refresh after commit, so replica lag cannot restore an otherwise successful rewrite. A report is written to the session and confirmed before its Job becomes `completed`; an unconfirmed write is retried and never exposed as a false completion. Retrying an already-created queued job re-nudges the dispatcher, recovering an interrupted HTTP response without creating a second report. If progress-event persistence, durable replay, or live fan-out is briefly unavailable, the worker/stream logs the degradation and continues or reconnects rather than failing the whole job. Whole-report rewrite accepts an optional `reportOutline` Markdown template; the durable job persists it and applies it as the chapter structure constraint. Optional report illustrations use a separately configured OpenAI-compatible image endpoint and are served only through the owning session's authenticated artifact route. |
|
||||
| `/api/enterprise-research/*` | Temporarily disabled. Its router and persistence initialization are not registered, so these endpoints return 404 and no enterprise-research tables are created or migrated during startup. |
|
||||
| `POST /api/ai-writing/sample/extract` | Extract text from Word/PDF/Markdown/TXT samples for AI-writing imitation mode |
|
||||
@@ -317,7 +357,10 @@ multi-agent review revision emits `report_reset` before the replacement draft.
|
||||
Every session may also provide a bounded `custom_outline`. Markdown headings or
|
||||
numbered entries become the deterministic section plan for `detailed` and
|
||||
`multi_agent`; `basic` and `deep` receive the same outline as a guarded
|
||||
report-writing constraint. The outline is frozen in the session snapshot and
|
||||
report-writing constraint. An empty outline (the workbench default) is planned after chat collection
|
||||
via `POST /sessions/{id}/intent-outline` and filled into the write-confirmation
|
||||
form; `basic`/`quick` still generate a topic-specific skeleton at write time
|
||||
if the form is still empty. The outline is frozen in the session snapshot and
|
||||
never treated as a system instruction.
|
||||
|
||||
All owner-scoped Deep Research routes resolve the platform's asynchronous
|
||||
@@ -474,7 +517,7 @@ The built-in `forced-research-responder` (「强制检索输出助手」) is see
|
||||
|
||||
The strategy-selection workbench starts with nine folder-backed functional agents: one intent agent, six independent angle agents (governance, diplomacy, economy/supply-chain, security risk, public opinion, and law/policy), one judge, and one final solution editor. Defaults ship in `app/gateway/routers/_strategy_selection_seed_assets/` and are copied only when an agent directory is absent, before `_sync_legacy_agents`; existing administrator edits are never overwritten. A global `strategy_agent_roles` registry owns classification, lifecycle state, and ordering independently of projects. Intent, judge, and solution are fixed singleton roles: administrators may update their model, SOUL, and skills but cannot add, disable, reorder, or delete them. Angles form one ordered catalog shared by every project; administrators may add, update, disable, restore, and reorder them. `GET /api/strategy-agents` is the public enabled catalog and omits model/SOUL/skills; `include_disabled=true` or `include_config=true` requires an administrator. Admin writes use `POST /api/strategy-agents/angles`, `PUT /api/strategy-agents/{id}`, and `DELETE /api/strategy-agents/{id}`; deletion is a soft disable so folder configuration and historical project references remain intact. Dynamic angles use the reserved `strategy-selection-angle-` namespace, receive `web` + `file:read`, and get a safe default SOUL if the submitted SOUL is blank. Model names and selected skills are validated, skills must be active and globally visible, generic agent CRUD cannot create or hard-delete reserved strategy agents, and parallel execution rejects disabled roles. The shipped angle agents use `policy-knowledge`, intent uses `intent-clarification-policy`, judging is input-only, and the solution editor has file-write access for `/mnt/user-data/outputs/综合策略方案.md`. Every default SOUL requires neutral evidence handling, de-escalation and civilian protection, and prohibits operational combat guidance or targeted political manipulation.
|
||||
|
||||
`POST /api/parallel-agents/run/stream` keeps reasoning and the deliverable in separate per-agent frames. Provider structured reasoning and inline `<think>...</think>` content are emitted only as `reasoning_delta`; visible answer text is emitted as `delta`, and `agent_done.content` contains only the visible answer. Consumers must not append `reasoning_delta` to strategy output or the final document. A final `is_llm_error_message` fallback, empty/thinking-only response, or punctuation-only provider degeneration is emitted as `agent_error`, never as a successful `agent_done`. Regression coverage: `tests/test_strategy_selection_seed.py`, `tests/test_strategy_agent_management.py`, and `tests/test_roundtable_model_fallback.py`.
|
||||
`POST /api/parallel-agents/run/stream` keeps reasoning and the deliverable in separate per-agent frames. Provider structured reasoning and inline `<think>...</think>` content are emitted only as `reasoning_delta`; visible answer text is emitted as `delta`, and `agent_done.content` contains only the visible answer. Consumers must not append `reasoning_delta` to strategy output or the final document. A final `is_llm_error_message` fallback, empty/thinking-only response, or punctuation-only provider degeneration is emitted as `agent_error`, never as a successful `agent_done`. While a seat is waiting inside a long-running skill or retrieval call, the stream emits `agent_progress` every five seconds with its current user-facing step and elapsed time; 180 seconds without any upstream frame ends only that seat with `agent_error` instead of leaving the whole workbench pending. The strategy frontend keeps the intent Q&A visible, translates tool calls into readable execution steps, and shows the heartbeat on each running card. Strategy-mode project conversations also open on the real message/tool stream by default, with the structured board still available as a secondary view. Regression coverage: `tests/test_strategy_selection_seed.py`, `tests/test_strategy_agent_management.py`, and `tests/test_roundtable_model_fallback.py`.
|
||||
|
||||
### AI Writing Intranet Retrieval
|
||||
|
||||
@@ -524,6 +567,8 @@ models:
|
||||
use: langchain_openai:ChatOpenAI
|
||||
model: gpt-4o
|
||||
api_key: $OPENAI_API_KEY
|
||||
# Complete input request ceiling; independent from the output max_tokens.
|
||||
max_input_tokens: 128000
|
||||
supports_thinking: false
|
||||
supports_vision: true
|
||||
|
||||
@@ -555,6 +600,13 @@ non-streaming calls. DeerFlow retries transient upstream responses instead of
|
||||
accepting an empty assistant turn, while genuine quota/balance failures are
|
||||
classified as non-retriable and surfaced immediately instead of being retried.
|
||||
|
||||
For models with a finite context window, set `max_input_tokens` to a safe value
|
||||
below the advertised window (for example `160000` for a 200k-token deployment).
|
||||
Immediately before every lead-agent or subagent model call, DeerFlow applies
|
||||
this ceiling to the complete payload and transiently removes/truncates the
|
||||
oldest context if needed. `max_tokens` remains the maximum generated output;
|
||||
it does not cap the input. See [Context Summarization](docs/summarization.md).
|
||||
|
||||
### Running
|
||||
|
||||
**Full Application** (from project root):
|
||||
@@ -790,9 +842,12 @@ Reference-mode entry points are controlled by `citation_display` in
|
||||
`.deer-flow/system_settings.json`. `reference_mode_enabled` defaults to `false`;
|
||||
when disabled, the frontend hides the "参考文献" composer button in both the
|
||||
normal workspace and iframe chat, and hides the per-user RAG citation toggle
|
||||
from appearance settings. Conversations with selected LLMWiki knowledge bases
|
||||
still show their source documents in the reference panel even when the manual
|
||||
entry is hidden. `GET /api/system-settings/citation-display` is
|
||||
from appearance settings. Conversations with selected LLMWiki/assistant
|
||||
knowledge spaces still show their sources even when the manual entry is hidden,
|
||||
but they use a separate Wiki reader rather than the generic reference-card
|
||||
panel: a flat Wiki table of contents selects an inline Markdown article, and
|
||||
sources without one of the currently selected server-authored knowledge-space
|
||||
ids are omitted. `GET /api/system-settings/citation-display` is
|
||||
readable by logged-in users so the UI can decide whether to expose the entry;
|
||||
`PUT /api/system-settings/citation-display` is admin-only and supports partial
|
||||
updates for both `reference_mode_enabled` and `cleanup_words`.
|
||||
@@ -924,22 +979,45 @@ the file through the existing thread-artifact endpoint.
|
||||
|
||||
## 普通知识库管理
|
||||
|
||||
在「普通知识库」的「我的知识库」或「公共 LLMWiki」中,知识库所有者和管理员可以点击卡片上的「编辑」,修改名称和描述(描述可清空)。保存后同步更新知识服务和本地记录,并刷新列表;系统「对话沉淀」库不提供编辑入口。
|
||||
在「普通知识库」的「我的知识库」或「公共 LLMWiki」中,知识库所有者和管理员可以点击卡片上的「编辑」,修改名称和描述(描述可清空)。保存后同步更新知识服务和本地记录,并刷新列表;系统「对话沉淀」库不提供编辑入口。系统生成的默认测试问题不会因为只修改名称而被保存为自定义内容,并始终按远端当前名称重新生成;旧版本误保存的精确四问默认模板也按自动问题处理,因此改名后不再继续显示旧名称。只有用户实际编辑问题文本时才固定为自定义问题。
|
||||
|
||||
远端已经删除的知识库会在下次列表刷新时自动隐藏,包括个人、公共列表和知识库选择器;页面每 15 秒自动刷新,也可以手动点击「刷新」。远端服务请求失败时展示错误,不把连接故障当成删除,不自动删除本地映射或已有引用。
|
||||
|
||||
新建知识库时会通过 `GET /api/llmwiki/embedding-models` 读取 WeKnora 中可用的
|
||||
Embedding 模型,并把所选 `embedding_model_id` 明确传给创建接口。该模型只负责
|
||||
WeKnora 中上传原文的分块向量化;它和下文 DeerFlow 自己的 Wiki 镜像编码器是两套
|
||||
独立配置,因此选择 OpenAI/OpenAI-compatible 原文编码器时不要求同时启用本地
|
||||
BGE-M3。模型列表响应只暴露名称、provider、状态等白名单字段,不返回密钥或连接
|
||||
参数。模型绑定只对新建库生效;需要跨知识库检索时,各库应使用相同或兼容的向量模型。
|
||||
|
||||
选择「Wiki 知识库」时,新建弹窗还可填写「Wiki 内容生成要求」和「Wiki 提取重点」;
|
||||
已有 Wiki 库可从知识库卡片的「编辑」入口修改。两项配置分别写入 WeKnora
|
||||
`wiki_config.content_instructions` 与 `wiki_config.extraction_instructions`:前者控制自动生成页面的
|
||||
语言、结构与表达侧重,后者控制候选主题、实体和概念的抽取重点。配置会用于之后上传或
|
||||
重新解析的文档;只修改配置不会自动重写已有 Wiki 页面。
|
||||
|
||||
## DeerFlow-local LLMWiki Wiki vector index
|
||||
|
||||
LLMWiki can mirror processed WeKnora Wiki pages into DeerFlow and search only
|
||||
processed Wiki content. A knowledge base uses exact NumPy cosine similarity
|
||||
only after its whole Wiki has completed one coherent vectorization pass; until
|
||||
then internal search calls WeKnora's Wiki-page search/list API and reads the
|
||||
matched Wiki pages. It never falls back to raw documents or chunks. Configure
|
||||
processed Wiki content. Retrieval now runs local vector and local lexical Wiki
|
||||
recall in parallel and merges independently ranked channels with RRF. A failed
|
||||
or cancelled incremental sync keeps serving the last coherent vector snapshot;
|
||||
only `rebuild_required`, a fingerprint mismatch, or an actually incomplete
|
||||
snapshot takes it offline. Before a first complete snapshot, internal search
|
||||
uses local Wiki keyword recall plus WeKnora's Wiki-page search/list API. It
|
||||
never falls back to raw documents or chunks. Configure
|
||||
`llmwiki.local_wiki_index.embedding`, then enable the local index in
|
||||
`config.yaml`. `auto_sync` defaults to true: the scheduler performs one
|
||||
immediate incremental scan at startup and then scans every configured interval
|
||||
(30 seconds by default). Wiki changes are content-hash checked, so unchanged
|
||||
pages reuse their vectors instead of being encoded again.
|
||||
immediate incremental scan at startup and then refreshes the WeKnora
|
||||
knowledge-base directory every configured interval (30 seconds by default).
|
||||
Only new, failed, remotely updated, or rebuild-required libraries are scanned;
|
||||
a 10-minute low-frequency full scan is the safety net for older providers that
|
||||
do not update directory timestamps. Wiki page summaries with a complete body
|
||||
are normalized directly. Older summary shapes use `version` / `updated_at` to
|
||||
skip unchanged detail requests and fall back to the page-detail API when those
|
||||
markers are absent. Unchanged pages reuse their vectors, while directory,
|
||||
parent, path, source/chunk-reference, version, and timestamp-only changes update
|
||||
the mirror without re-embedding the body.
|
||||
`database_batch_size` caps each vector insert statement (default `50`) while
|
||||
the page replacement remains atomic, preventing a large Wiki from flooding
|
||||
the SQL connection in one statement.
|
||||
@@ -952,24 +1030,36 @@ from the first successful response.
|
||||
Embedding failures log the upstream HTTP status and a bounded response body.
|
||||
The client never sends a `dimensions` request parameter.
|
||||
|
||||
The deployment default uses SiliconFlow's OpenAI-compatible endpoint with
|
||||
`BAAI/bge-m3` (1024 dimensions); set `SILICONFLOW_API_KEY` in `.env.local` or
|
||||
the process environment. Provider/model/base URL/dimensions are part of the
|
||||
fingerprint, so switching providers intentionally schedules a rebuild while
|
||||
keyword/Wiki fallback remains available.
|
||||
|
||||
The migration creates `llmwiki_wiki_pages`, `llmwiki_wiki_vectors`, and
|
||||
`llmwiki_wiki_sync_states`. Wiki Markdown and normalized float32 vectors are
|
||||
stored in DeerFlow's configured SQL database. Multi-worker sync is protected by
|
||||
database leases; searches use revision-checked per-knowledge-base LRU snapshots
|
||||
after the full-library readiness gate succeeds. Knowledge-base owners can click
|
||||
**手动向量化** in Wiki management (`POST
|
||||
/api/llmwiki/knowledge-bases/{id}/vectorize`) and follow its status at
|
||||
**同步更新** in Wiki management (`POST
|
||||
/api/llmwiki/knowledge-bases/{id}/sync`; the former `/vectorize` route remains a
|
||||
compatible alias) and follow its status at
|
||||
`GET /api/llmwiki/knowledge-bases/{id}/wiki-index-status`. The response includes
|
||||
aggregate `progress` plus a `pages` list with every Wiki page's index state,
|
||||
vector-section count, timestamps, and last error. The management page renders
|
||||
vector-section count, timestamps, and last error. Its `last_sync` object reports
|
||||
the last run's added, modified, skipped, deleted, and failed counts, timestamps,
|
||||
mode, and sync id. It also includes configured/indexed fingerprints,
|
||||
stale-serving state, and the effective retrieval mode. The management page renders
|
||||
the percentage and labels each article as 已向量化 / 待向量化 / 失败, so it is
|
||||
clear exactly what is searchable. Existing chunk citations remain readable
|
||||
while all new retrieval citations open Wiki pages.
|
||||
|
||||
The frontend labels these results simply as **Wiki** references; provider-brand
|
||||
wording is intentionally hidden from user-facing labels and status text. Clicking any
|
||||
part of a Wiki reference card opens one right-side drawer (rather than a second
|
||||
detail dialog), renders the complete page as Markdown, and reads the remote
|
||||
wording is intentionally hidden from user-facing labels and status text. In
|
||||
knowledge-space Q&A, the right side is a dedicated Wiki table-of-contents and
|
||||
inline Markdown reader rather than the generic reference-card layout. Its
|
||||
**完整 Wiki** action opens one right-side drawer (rather than a second detail
|
||||
dialog), renders the complete page as Markdown, and reads the remote
|
||||
WeKnora Wiki page directly when the local index is disabled. Even if a Wiki
|
||||
citation carries a legacy document id, the drawer does not mix in the uploaded
|
||||
original-file preview. A single page can be downloaded as Markdown or Word from
|
||||
@@ -1013,6 +1103,10 @@ duplicate `20260821_01` identifier is repaired by unique fixed-question
|
||||
revisions and the `20260825_01` merge revision, which also fills the
|
||||
report-structure column for databases stamped by either old variant.
|
||||
|
||||
「问题配置」中的固定回答流式速度完全在本地实现。固定回答命中后使用内置的
|
||||
文字分块器控制 `1–1000 token/s` 的近似速度,不加载模型分词器,也不会在首次命中时
|
||||
联网下载 `cl100k_base` 等词表;因此清空缓存的离线部署同样可以直接返回固定回答。
|
||||
|
||||
Published knowledge bases also have a login-free, chrome-free reader at
|
||||
`/#/embed/knowledge/{mapping_id}` for direct third-party iframe use. With no
|
||||
`wikiSlug`, it selects the Wiki **索引** page first (recognized by title, page
|
||||
@@ -1154,6 +1248,13 @@ Wiki 向量并通过落盘导出包自动沉淀到「知识梳理」。内置技
|
||||
包保留正文、别名/标签、目录分类、双向链接、实体关系及 float32 向量。
|
||||
回流时通过 WeKnora API 重建目录/页面,向量进入 DeerFlow 本地 Wiki 索引,
|
||||
**不直接写 WeKnora 的底层向量或图数据库**。普通与助手 Wiki 使用同一个阅读组件。
|
||||
助手知识库入口只读取库统计,不再因服务重启同步扫描全库;进入具体库时先加载不含
|
||||
正文/搜索文本的轻量 Wiki 目录,当前文章正文再按 slug 单页读取,因此目录条目很多时
|
||||
也能先打开页面,且不会在浏览器和 Gateway 中同时保留全库的多份长文本。首批目录
|
||||
返回后即可阅读默认索引,后续目录分页在后台补齐;直接链接的文章会与目录并行加载。
|
||||
新建且尚未导入文件的助手知识库仍可正常进入 Wiki 管理页:空目录是合法状态,页面
|
||||
明确提供上传文件或导入普通知识库数据包的入口,不以“已有来源/Wiki 页面”作为路由
|
||||
前置条件。普通知识库的空 Wiki 阅读页同样可直接进入 Wiki 管理并手工创建首篇文章。
|
||||
|
||||
小批量 CPU 编码可配置如下,无需额外部署 HTTP 编码服务:
|
||||
|
||||
@@ -1176,13 +1277,23 @@ llmwiki:
|
||||
|
||||
本地编码依赖随标准后端安装。将完整 BGE-M3 模型目录提前放到离线服务器,并通过
|
||||
`local_model_path` 或 `DEERFLOW_BGE_M3_MODEL_PATH` 指向它。管理员也可在
|
||||
「设置和更多 → 设置 → 本地编码器」中选择服务器目录,或从浏览器上传完整模型目录;
|
||||
「设置和更多 → 设置 → Wiki 镜像编码器」中选择服务器目录,或从浏览器上传完整模型目录;
|
||||
页面配置持久化到运行目录的 `system_settings.json`,上传文件落到
|
||||
`.deer-flow/models/bge-m3`,均不进入源码仓库。系统强制 `local_files_only`,
|
||||
`.deer-flow/models/bge-m3-revisions/<revision>` 的不可变版本目录,均不进入源码仓库。系统强制 `local_files_only`,
|
||||
**不会访问互联网或下载模型**。管理员可在同一设置页点击「一键启动编码器」异步加载;该操作不挂在应用启动流程,加载失败不会
|
||||
中断 DeerFlow 主服务。默认由独立低优先级子进程承载模型内存,正常停止 DeerFlow
|
||||
时会一并回收该子进程;编码进程异常退出只会将当前向量任务标记失败。模型目录应包含
|
||||
`onnx/model.onnx`(官方权重约 2.3 GB)及对应 tokenizer/config 文件。权重不进入业务源码仓库。
|
||||
|
||||
运行时编码器模式持久化为 `configured` 或 `local`。默认 `configured` 严格使用
|
||||
`config.yaml` 中的 OpenAI、OpenAI-compatible 或 local provider;保存服务器目录或
|
||||
上传模型会显式切到 `local` 并热重建 embedding/search/sync/retrieval 服务,不需要
|
||||
重启 Gateway。`POST /api/llmwiki/local-encoder/use-configured` 可立即恢复配置文件中的
|
||||
provider。`GET /api/llmwiki/local-encoder/status` 在远程 provider 下也正常返回当前
|
||||
provider/mode,不再把“不是 local”当成状态接口错误。每次激活本地模型都会生成新的
|
||||
模型修订指纹,避免同一路径替换权重后误复用旧向量。切换后的旧编码器会给在途任务
|
||||
保留短暂宽限期,随后等待当前编码调用结束并自动回收模型进程。
|
||||
|
||||
浏览器目录上传采用磁盘暂存和 4 MB 分块复制,页面显示上传进度;经 Nginx 等反向
|
||||
代理部署时仍需把请求体上限和读写超时配置到可承载完整模型目录。
|
||||
相同模型指纹、相同内容的页面复用现有向量;短正文/摘要至少保留一个非空分段。
|
||||
@@ -1190,10 +1301,28 @@ llmwiki:
|
||||
问答编码查询本身仍需可用的同一模型。WeKnora 的原始文档向量不能当作生成后
|
||||
Wiki 正文的向量使用,两种文本需要分别建立各自的首次索引。
|
||||
|
||||
Wiki 页面新增、编辑、删除及文档上传/重解析都会立即触发一次增量检查;WeKnora
|
||||
后台稍后才完成的 Wiki 抽取由 30 秒周期补扫接管。每次成功向量化后自动把该普通
|
||||
普通知识库检索会将“此知识库都讲了什么”“这个知识空间有哪些内容”等库级问法识别为概览请求:
|
||||
完整本地索引直接返回若干代表性 **正文**,不让宽泛提问被 `min_similarity` 过滤成零结果;尚未完成
|
||||
索引的库则通过 Wiki 页面目录取得同类正文。目录、索引和摘要页不作为概览或回退候选,也不会以页面摘要
|
||||
冒充正文命中。
|
||||
|
||||
知识空间列表的热路径也做了收敛:助手知识库的来源/Wiki/实体/关系数量由每库 4 次串行
|
||||
统计改为整批 1 条聚合查询,单纯改名不再扫描内容表;普通知识库复用 WeKnora 登录态,
|
||||
并用 15 秒短缓存合并多个页面/权限范围同时发起的目录请求,增删改库及文档变化后立即
|
||||
失效。前端关闭知识空间选择器时不再无条件拉取全量列表,也不再固定每 15 秒轮询空闲库。
|
||||
|
||||
助手向量检索先校验编码指纹和维度,再按 256 条矩阵化计算;全量扫描阶段只读取向量与
|
||||
最小页面标识,最终候选才回查正文。中文无空格问句的关键词降级会拆出有效短语,因此
|
||||
模型不兼容或暂时不可用时也不会把整句当成唯一关键词而轻易返回 0。
|
||||
|
||||
Wiki 页面新增、编辑、删除及文档上传/重解析(包括嵌入式 WeKnora 页面内完成的写操作)
|
||||
都会按知识库去抖,并按 1/8/30/90/300 秒的有上限退避执行增量重试;远端仍在处理时只读
|
||||
知识库状态,不枚举整库页面,也不会耗掉最终确认机会。处理结束后至少做一次短间隔静默确认,
|
||||
首轮早于 WeKnora 异步抽取完成时后续轮次仍会接住新页面。周期目录预检与 10 分钟补扫继续
|
||||
作为兜底,但任何补扫都不会在远端处理期退休缺页或覆盖完整图快照。每次成功
|
||||
向量化后自动把该普通
|
||||
知识库的最新完整快照同步到「知识梳理总库」,包括服务重启前已有库和新建库;来源
|
||||
页面被删除时也会在总库中退役,不保留失效 Wiki。
|
||||
页面被删除时也会在总库中退役,不保留失效 Wiki。同一 Gateway 内会按 mapping 合并同步触发;跨 Gateway worker 的导入事务统一先锁定目标助手库基表行,再进行图对齐和来源快照替换,避免不同 worker 以不同顺序持有从属表锁。数据库报告瞬态锁等待超时、死锁或序列化冲突时,会在完整回滚后按有界退避重放整个导入事务,而不会把已经完成的 Wiki 向量化误报为永久的知识梳理失败。
|
||||
|
||||
「知识梳理总库」不是按来源简单堆叠:导入时会规范化全/半角、空白、标点及常见实体
|
||||
类型,并利用实体别名对齐同一人物、组织、产品或概念;不同来源中同标题的实体 Wiki
|
||||
@@ -1203,6 +1332,53 @@ Wiki 页面新增、编辑、删除及文档上传/重解析都会立即触发
|
||||
同步时自动归并。助手知识检索排除目录、索引和摘要页;关键词只查标题与知识正文,
|
||||
向量检索返回实际命中的正文片段,问答上下文和检索卡片均不再用摘要代替知识。
|
||||
|
||||
聊天中一旦选择普通或助手知识空间,本轮进入严格知识空间模式:Gateway 与 Lead Agent
|
||||
双层关闭 Web、浏览器、检索型 MCP、外部检索技能、ACP 与子智能体,不允许模型用常识
|
||||
补齐库内没有的事实。`llmwiki_search` 兼容名现在同时支持普通与助手知识空间,并且只能
|
||||
读取线程上下文中的已选 ID。普通 Wiki 同时执行向量与标题/摘要/正文关键词召回并以 RRF
|
||||
融合;低于向量阈值时返回关键词结果以及 raw top score、阈值过滤数和 `fallback_reason`。
|
||||
新对话选择空间后,输入框会根据库名展示 4 个可直接提问的问题;知识空间建议存在时不再
|
||||
混排全局通用推荐问题。
|
||||
|
||||
知识空间新增「检索调试」页面(`/page/workspace/knowledge/retrieval-debug`):可同时选择普通
|
||||
Wiki 库和助手知识库,输入问题后调用 `POST /api/llmwiki/retrieval-debug`。该接口复用真实问答
|
||||
的回答前检索函数,不是单独的向量测试接口;响应会给出所选库、实际模式(向量/关键词/
|
||||
Wiki API/原文分块/混合)、候选数、阈值和降级原因,以及最终送给模型的限长正文。普通问答的首次 SSE
|
||||
`metadata` 事件同时带 `knowledge_retrieval_trace`;回答结束后也可在
|
||||
`GET /api/threads/{thread_id}/reference-batches` 的 `retrieval_traces` 中复查,包括零命中轮次。
|
||||
因此浏览器 F12 可以区分“没有选库”“索引未就绪”“向量低于阈值”“关键词未命中”和检索服务
|
||||
不可用,而不再把所有情况都表现为没有参考资料。旧版或嵌入式客户端若后续轮次省略选库字段,
|
||||
Gateway 会沿用线程已持久化的选择;显式传空列表仍表示本轮不检索知识空间。
|
||||
|
||||
普通知识库现在并行检索两层证据:生成后的 Wiki 正文页/分段,以及 WeKnora 原始上传文档
|
||||
chunk;两层都命中时用 RRF 做跨通道融合,最终仍最多向回答上下文提供 8 条、每条 1400 字。
|
||||
原文通道只使用通过 DeerFlow 权限校验后映射出的远端库 ID,并再次丢弃上游返回的未知库结果。
|
||||
完整本地 Wiki 索引使用向量与关键词并行的混合召回;索引未就绪时走本地关键词和 Wiki 页面
|
||||
API。助手知识库也会并行召回向量与关键词/原文 chunk,再以加权 RRF 融合;精确设备码、事件码
|
||||
等字面标识优先,因此即使已有 Wiki 向量,普通库导入的原文 chunk 也不会被隐藏。两类知识库都
|
||||
不能宣称每轮都是纯向量检索。
|
||||
|
||||
标题优先排序:普通 Wiki、原文切片和助手知识库的检索融合都会提取用户问题中的
|
||||
主题短语,并把标题/别名命中作为有界的高权重信号;因此查询「海湖庄园」时,标题为
|
||||
「海湖庄园」的文档通常会优先于只在正文提到该词的「特朗普」文档,同时不会让弱标题
|
||||
子串无条件压过高度相关正文。普通 Wiki 的本地
|
||||
向量索引可在 `llmwiki.local_wiki_index` 中通过 `title_boost_enabled` 和
|
||||
`title_boost_weight` 调整(默认 `true` / `0.25`)。实体扩展产生的关联词只用于
|
||||
召回,不会冒充原始问题的标题命中。
|
||||
|
||||
点击知识库引用的「查看详情」后,抽屉顶部先展示该次检索实际命中的切片,再展示摘要和
|
||||
完整文档/Wiki 正文。对话底部的后续问题只在消息列表处于最下方时展示;用户上滑查看
|
||||
历史消息时自动隐藏,回到最下方后恢复。
|
||||
同步器会把 Wiki 入链、出链、正文 `[[wikilink]]` 和 provider graph 归并成库内有向边;回答前以
|
||||
混合召回页面为种子做有界图扩展,默认 1 跳,问题明确要求多跳或首轮向量低置信时最多 2 跳。
|
||||
助手知识库也会沿已导入的实体关系扩展:关系两端通过 entity 的 `wiki_page_id` 回到原始 Wiki
|
||||
正文页,只读取所选助手库内仍为 active 的关系、实体和页面,不跨库追边。助手库图扩展使用同样
|
||||
的跳数、候选和去重边界;直接召回但未入 seed 的中间页仍可作为下一跳,却不会重复占用上下文。
|
||||
图通道最多检查 24 个候选,种子、每库接受数和最终上下文图槽都有硬上限,并以衰减传播分排序;
|
||||
扩展页必须有真实正文和可打开引用,未知库或越权节点会被再次过滤。调试 trace 会给出种子、候选、
|
||||
接受数、实际跳数、路径和独立耗时;存储接口可用时 `capabilities.wiki_graph_expansion=true`,图通道
|
||||
失败只标记 partial,不会丢弃 Wiki、原文 chunk 或助手库已经命中的证据。
|
||||
|
||||
大包采用流式 JSONL 落盘、同盘临时 SQLite 分阶段读取及异步导入,避免一次性将
|
||||
整个包加载进内存。部署需预留包、暂存索引和业务数据库空间,并配置代理上传大小
|
||||
与超时。当前不宣称断点续传或 GB 级压力验收已完成。
|
||||
@@ -1235,3 +1411,69 @@ checkpointer:
|
||||
normalized to the openGauss dialect. Do not configure the LangGraph
|
||||
PostgreSQL checkpointer against GaussDB: its migrations are PostgreSQL-specific.
|
||||
For a production image, build with `--build-arg UV_EXTRAS=gauss`.
|
||||
# 问答记忆开关
|
||||
|
||||
问答记忆默认关闭。关闭时,普通问答不会加载记忆中间件、不会注入历史记忆,也不会在回答结束后调用模型提取或写入记忆。管理员可在「设置 → 问答记忆」中显式开启;开关保存在运行目录的 `system_settings.json`,新部署或没有该字段时始终按关闭处理。
|
||||
|
||||
## 2026-09-14 我的项目与知识库验收修复
|
||||
|
||||
- 简洁模式的「我的项目」列表、策略工作台和普通问答项目恢复工作区功能导航;窄屏提供展开菜单按钮。
|
||||
- 普通问答先创建具名项目,再在项目内创建多个对话。列表读取 `/api/analysis-projects` 的 `qa` 项目,不再读取、标记或自动归入全局普通聊天。
|
||||
- 项目设置更新保留既有知识库绑定。原「项目空间」与官方入口继续可用;我的项目下问答路由为 `qa/projects/groups/*`。
|
||||
- 策略生成卡片统一先显示思考/执行过程,再显示正文;评判、方案及展开视图沿用相同顺序。
|
||||
- 完成评判但尚未勾选策略的项目可以从方案列表进入,在工作台选择后生成;已保存方案在任务修改后仍可打开。旧列表请求不再覆盖新请求状态。
|
||||
- 策略优选终稿不依赖临时系统 thread 写文件;`parallel_agent_tasks.messages` 内版本化 snapshot 的 `synthesisStatus=done` 且 `synthesis` 非空时,资料库将其投影为一份可搜索、可下载的 Markdown 文档。`workflowStale=true` 只标记为历史方案,不删除或禁止下载。普通分析项目 thread 的 `analysis_project_mode=strategy` 文件也以策略来源展示。
|
||||
- 知识库管理页读取上游最新目录,避免远端删除后命中旧缓存;检索调用仍共享短期目录缓存。
|
||||
- 普通用户访问尚未初始化的助手知识库时显示明确空态及刷新按钮。
|
||||
|
||||
验证:后端相关回归 273 项、前端策略/项目回归 31 项通过;真实 BAAI/bge-m3 编码、指定库向量检索与草稿隔离通过;本地隔离服务的问答项目创建/分组、真实问答、方案整理、助手库创建/编辑/文件入库/向量检索/详情均通过。完整验收记录见仓库 `docs/ji-knowledge-projects-acceptance.md`。不在源码或文档中保存接口密钥。
|
||||
|
||||
2026-09-14 日常使用复查:补修项目历史入口与移动侧栏、默认智能体同步、项目加载重试、助手知识检索过期响应隔离及无结果指引;更新 ScrollArea 的 React 19 兼容修复。后端再次 273 项通过,前端 33 项通过。范围及限制见仓库 docs/daily-usage-audit-20260914.md。
|
||||
|
||||
## 2026-09-20 知识库扩展、统计检索与检索测试
|
||||
|
||||
普通 WeKnora Wiki 知识库支持按库维护说明、默认测试问题和检索设置。旧库自动提供四个测试问题;所有者可在知识库卡片的「编辑」中逐行调整,保存后用户选择该库时直接展示。问“这个知识库讲了什么”时,问答工具同时返回库说明与实际 Wiki 正文引用,不以说明代替正文证据。
|
||||
|
||||
`llmwiki_search` 在原混合检索上增加一跳 Wiki 关系扩展:先识别问题中的关注对象,再从命中页的别名、`[[Wiki 链接]]` 和 Markdown 链接生成有限扩展词,独立检索后使用 RRF 融合,原问题通道权重最高。日期/数量问题由后端解析和计数;支持 `YYYY-MM-DD`、`YYYY年M月D日`、`M月D号到M月D号` 及当月「几号到几号」。存在带稳定标识的 `source_refs` 时按新闻/来源去重计数,否则明确回退为 Wiki 页面数;日期缺失的记录不会悄悄进入日期区间统计,而会单列 `undated_excluded_count`。
|
||||
|
||||
知识库详情顶部的「检索测试」进入 `/page/workspace/knowledge/{id}/retrieval-debug`。页面调用 `POST /api/llmwiki/knowledge-bases/{id}/retrieval-debug`,返回 `request_id`、识别对象、日期范围、扩展词、实际子查询、确定性统计、具体明细、Wiki 参考文献、通道诊断和警告。浏览器 F12 的 Network 面板可直接检查完整响应,用于定位“问答说未查到数据”究竟是索引、阈值、日期元数据还是引用缺失。
|
||||
|
||||
## 回答评价与用户反馈分
|
||||
|
||||
每条持久化的智能体回答可通过
|
||||
`PUT /api/threads/{thread_id}/messages/{message_id}/feedback` 提交优秀/不佳评价;
|
||||
不佳评价支持“不正确或不完整、与期望不符、速度慢或存在问题、风格或语气、
|
||||
安全或法律疑虑、其他”六类稳定原因及可选详情。服务端从消息事件解析 run 和智能体,
|
||||
不接受客户端把评价归到另一个智能体;历史页可用批量
|
||||
`POST /api/threads/{thread_id}/feedback-contexts` 一次读取。
|
||||
|
||||
仅 `system_role=admin` 的管理员可调用
|
||||
`GET /api/agents/{agent_id}/feedback-score`;接口返回 0–100 的用户反馈回答质量分、
|
||||
原始好评率、样本量/置信度、五项任务质量维度和问题原因分布。总分使用
|
||||
Beta(8,2) 先验抑制小样本极值;零样本返回 `score: null` 和
|
||||
`insufficient_data`,不会把先验当成真实成绩。该指标不调用额外模型,也不替代对
|
||||
规划、推理轨迹、技能/工具使用、延迟、可靠性或安全性的专项评测。完整契约与公式见
|
||||
`docs/AGENT_ANSWER_FEEDBACK_SCORING_ZH.md`。
|
||||
|
||||
## 用户菜单与管理员默认菜单
|
||||
|
||||
全量模式和简洁模式菜单都支持用户个性化。管理员在「默认菜单管理」中只维护共享默认值;
|
||||
普通用户在「我的菜单」中保存自己的完整菜单快照,不会修改其他账号或管理员默认值。
|
||||
用户未保存个人配置时直接使用管理员默认;保存个人配置后,快照内已有菜单继续使用用户的
|
||||
名称、位置、顺序和启停状态,而后续新增、尚未进入快照的菜单自动继承管理员配置。
|
||||
「恢复默认」只删除当前用户对应的个人快照。简洁模式仍按部署配置的
|
||||
`VITE_COMPACT_MENU_TYPE` 隔离 A/B 两套菜单。
|
||||
## Large uploaded-file safety
|
||||
|
||||
The singleton `upload_policy` database row is the source of truth for every
|
||||
chat attachment picker and Gateway upload. The administrator-facing
|
||||
「设置 → 上传设置」 page edits file count, total bytes, per-category formats and
|
||||
sizes, plus the large-file threshold and output budgets; every save increments
|
||||
the policy revision, and reset writes the built-in defaults back to the row.
|
||||
|
||||
Model-facing file reads are bounded. Large text and converted documents are
|
||||
scanned as streams and returned as whole-file statistics plus deterministic
|
||||
head/middle/tail samples; use `read_file` line ranges or `grep` for follow-up
|
||||
inspection. The active database upload policy controls the sampling threshold
|
||||
and output budgets. Image analysis validates decoded dimensions and uses a
|
||||
bounded derivative, so original image bytes are not injected unboundedly.
|
||||
Reference in new issue
Block a user