dsh-data-domain-knowledge 0.1.0-alpha.3 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -22
- package/cordis.patch.yml +25 -16
- package/lib/client.js +2144 -1571
- package/lib/doc-page.js +40 -19
- package/lib/types/convert/host.d.ts.map +1 -1
- package/lib/types/convert/host.js +27 -2
- package/lib/types/convert/host.js.map +1 -1
- package/lib/types/convert/ingest.d.ts +7 -4
- package/lib/types/convert/ingest.d.ts.map +1 -1
- package/lib/types/convert/ingest.js +52 -14
- package/lib/types/convert/ingest.js.map +1 -1
- package/lib/types/convert/types.d.ts +2 -2
- package/lib/types/convert/types.d.ts.map +1 -1
- package/lib/types/convert/types.js +2 -2
- package/lib/types/convert/types.js.map +1 -1
- package/lib/types/diagnosis/cards.js +2 -2
- package/lib/types/diagnosis/run.d.ts +7 -1
- package/lib/types/diagnosis/run.d.ts.map +1 -1
- package/lib/types/diagnosis/run.js +8 -2
- package/lib/types/diagnosis/run.js.map +1 -1
- package/lib/types/diagnosis/seed-source.js +1 -1
- package/lib/types/diagnosis/seed.d.ts +1 -1
- package/lib/types/diagnosis/seed.js +1 -1
- package/lib/types/diagnosis/store.d.ts +13 -31
- package/lib/types/diagnosis/store.d.ts.map +1 -1
- package/lib/types/diagnosis/store.js +33 -71
- package/lib/types/diagnosis/store.js.map +1 -1
- package/lib/types/diagnosis/types.d.ts +1 -1
- package/lib/types/diagnosis/types.js +1 -1
- package/lib/types/extract-model.d.ts +67 -27
- package/lib/types/extract-model.d.ts.map +1 -1
- package/lib/types/extract-model.js +225 -97
- package/lib/types/extract-model.js.map +1 -1
- package/lib/types/extract.d.ts +16 -0
- package/lib/types/extract.d.ts.map +1 -1
- package/lib/types/extract.js +19 -2
- package/lib/types/extract.js.map +1 -1
- package/lib/types/fs-atomic.d.ts +3 -4
- package/lib/types/fs-atomic.d.ts.map +1 -1
- package/lib/types/fs-atomic.js +3 -4
- package/lib/types/fs-atomic.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +302 -89
- package/lib/types/index.js.map +1 -1
- package/lib/types/intent/types.js +1 -1
- package/lib/types/intent/types.js.map +1 -1
- package/lib/types/knowledge-bases.d.ts +13 -10
- package/lib/types/knowledge-bases.d.ts.map +1 -1
- package/lib/types/knowledge-bases.js +18 -27
- package/lib/types/knowledge-bases.js.map +1 -1
- package/lib/types/layout.d.ts +3 -3
- package/lib/types/layout.d.ts.map +1 -1
- package/lib/types/layout.js +4 -4
- package/lib/types/layout.js.map +1 -1
- package/lib/types/migrate.d.ts +1 -1
- package/lib/types/migrate.js +2 -2
- package/lib/types/migrate.js.map +1 -1
- package/lib/types/model-text.d.ts +99 -0
- package/lib/types/model-text.d.ts.map +1 -0
- package/lib/types/model-text.js +103 -0
- package/lib/types/model-text.js.map +1 -0
- package/lib/types/present.d.ts +239 -0
- package/lib/types/present.d.ts.map +1 -0
- package/lib/types/present.js +255 -0
- package/lib/types/present.js.map +1 -0
- package/lib/types/recall-rank.d.ts +37 -0
- package/lib/types/recall-rank.d.ts.map +1 -1
- package/lib/types/recall-rank.js +41 -1
- package/lib/types/recall-rank.js.map +1 -1
- package/lib/types/runtime.d.ts +419 -78
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/runtime.js +2104 -334
- package/lib/types/runtime.js.map +1 -1
- package/lib/types/settings-schema.d.ts +2 -0
- package/lib/types/settings-schema.d.ts.map +1 -1
- package/lib/types/settings-schema.js +2 -0
- package/lib/types/settings-schema.js.map +1 -1
- package/lib/types/source-images.d.ts +118 -0
- package/lib/types/source-images.d.ts.map +1 -0
- package/lib/types/source-images.js +288 -0
- package/lib/types/source-images.js.map +1 -0
- package/lib/types/types.d.ts +316 -39
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js +57 -11
- package/lib/types/types.js.map +1 -1
- package/lib/types/wiki-finalize.d.ts +140 -0
- package/lib/types/wiki-finalize.d.ts.map +1 -0
- package/lib/types/wiki-finalize.js +269 -0
- package/lib/types/wiki-finalize.js.map +1 -0
- package/lib/types/wiki-types.d.ts +2 -1
- package/lib/types/wiki-types.d.ts.map +1 -1
- package/lib/types/wiki-types.js +13 -7
- package/lib/types/wiki-types.js.map +1 -1
- package/package.json +3 -3
- package/preset/tita-data-agent/agent.cordis.yml +25 -16
- package/src/client/DrawerSection.tsx +18 -0
- package/src/client/KnowledgeBaseTab.tsx +294 -104
- package/src/client/KnowledgePanel.tsx +4 -3
- package/src/client/KnowledgeToolRow.tsx +331 -0
- package/src/client/PreviewSections.tsx +115 -34
- package/src/client/RecallPanel.tsx +418 -127
- package/src/client/TypeDefinitionDrawer.tsx +82 -16
- package/src/client/WikiCardReview.tsx +266 -0
- package/src/client/WikiFlowCard.tsx +57 -95
- package/src/client/WikiTypeEditor.tsx +6 -20
- package/src/client/arch/AgentArchitectureGraph.tsx +22 -135
- package/src/client/architecture.css +22 -27
- package/src/client/architecture.tsx +12 -12
- package/src/client/asset-images.ts +125 -0
- package/src/client/attribution/AttributionTab.tsx +4 -10
- package/src/client/attribution/StageChrome.tsx +8 -24
- package/src/client/convert/ConvertPanel.tsx +30 -3
- package/src/client/doc-page.tsx +6 -27
- package/src/client/index.ts +18 -0
- package/src/client/problem-domains.ts +1 -1
- package/src/client/styles.css +80 -11
- package/src/convert/host.ts +27 -2
- package/src/convert/ingest.ts +61 -18
- package/src/convert/types.ts +2 -2
- package/src/diagnosis/cards.ts +2 -2
- package/src/diagnosis/run.ts +8 -2
- package/src/diagnosis/seed-source.ts +1 -1
- package/src/diagnosis/seed.ts +1 -1
- package/src/diagnosis/store.ts +32 -79
- package/src/diagnosis/types.ts +2 -2
- package/src/extract-model.ts +254 -99
- package/src/extract.ts +35 -3
- package/src/fs-atomic.ts +3 -4
- package/src/index.ts +338 -88
- package/src/intent/types.ts +1 -1
- package/src/knowledge-bases.ts +31 -32
- package/src/layout.ts +4 -4
- package/src/migrate.ts +2 -2
- package/src/model-text.ts +126 -0
- package/src/present.ts +367 -0
- package/src/recall-rank.ts +57 -2
- package/src/runtime.ts +2282 -374
- package/src/settings-schema.ts +2 -0
- package/src/source-images.ts +326 -0
- package/src/types.ts +354 -47
- package/src/wiki-finalize.ts +310 -0
- package/src/wiki-types.ts +13 -7
- package/lib/types/proposals.d.ts +0 -166
- package/lib/types/proposals.d.ts.map +0 -1
- package/lib/types/proposals.js +0 -238
- package/lib/types/proposals.js.map +0 -1
- package/src/client/ProposalReview.tsx +0 -313
- package/src/proposals.ts +0 -337
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-data-domain-knowledge
|
|
2
2
|
|
|
3
|
-
本地知识库插件:`
|
|
3
|
+
本地知识库插件:`01_source_raw` 保存 **SourceRaw**(原始可追溯文档),`02_wiki` 保存
|
|
4
4
|
按主题聚合、可双向链接的 wiki 卡片,`03_compiled` 输出可检索的 **wikiNotes**、wiki
|
|
5
5
|
知识图谱和向量索引,`<agentRoot>/memory/<库 id>` 保存版本快照、访问审计与反馈。默认使用本地 WeMM Python backend:从 WeMM
|
|
6
6
|
原生 2048 维向量按 MRL 截取 1024 维,先做 binary/Hamming 粗筛,再用 int8 点积精算余弦
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
| 段 | 名称 | 产物 | 关键配置 |
|
|
32
32
|
| --- | --- | --- | --- |
|
|
33
|
-
| 1 | SourceRaw | 原始可追溯文档:`
|
|
34
|
-
| 2 | 编译 Compile | wiki:`02_wiki
|
|
33
|
+
| 1 | SourceRaw | 原始可追溯文档:`01_source_raw/*.md` | `allowSourceTruth` / `rootDir` |
|
|
34
|
+
| 2 | 编译 Compile | wiki:`02_wiki`(**按 wiki 类型 schema 抽实体,直接入库**);wikiNotes:`03_compiled/wiki_notes.json` | `extractCandidates` / `extractWithModel` / `wikiTypes` |
|
|
35
35
|
| 3 | 构建 Build | wikiNotes → 向量索引;wiki → `03_compiled/knowledge_graph.json` | `embeddingProvider` / `embeddingModel` / `python` |
|
|
36
36
|
| 4 | 召回 Recall | 多路(关键词 + 向量 + 知识图谱)召回 wikiNotes,取 `recallTopK`(默认 10),再解析父级 wiki 与该 wiki 的 1 跳知识图谱 | `recallTopK` / `recallMode` |
|
|
37
37
|
| 5 | 重排 Rerank | BERT cross-encoder 对候选 wikiNotes 精排,取 `contextTopN`(默认 5)组成 `context` | `contextTopN` / `rerankProvider` / `rerankModel` |
|
|
@@ -40,15 +40,100 @@
|
|
|
40
40
|
> 但「跑一次真实召回长什么样」是一个问题,分两栏会让用户先跑召回、再切到重排才能
|
|
41
41
|
> 看到同一次运行的全貌。
|
|
42
42
|
|
|
43
|
-
> 术语迁移:SourceRaw 曾叫 SourceRow / SourceTruth。磁盘目录 `
|
|
43
|
+
> 术语迁移:SourceRaw 曾叫 SourceRow / SourceTruth。磁盘目录 `01_source_raw`、工具名
|
|
44
44
|
> `add_source` / `query_source_truth`、HTTP `/knowledge/sources`、设置键 `allowSourceTruth`
|
|
45
45
|
> 与错误码 `SOURCE_TRUTH_DISABLED` 作为兼容名保留,语义等同 SourceRaw。
|
|
46
|
-
> 「编译 / 构建」是同一次 `rebuild()
|
|
47
|
-
>
|
|
46
|
+
> 「编译 / 构建」是同一次 `rebuild()`:编译**按 wiki 类型 schema 抽实体**(模型优先、
|
|
47
|
+
> 规则兜底),判重后直接写 `02_wiki`;**wiki↔wiki 双向链接**与**分阶段重建**是设计目标,
|
|
48
|
+
> 图谱当前只有 `supported_by` 溯源边加规则抽出的 `relates_to`。
|
|
48
49
|
|
|
49
50
|
- 设置项**不再有独立入口**:它们挂在 Agent 概览架构图的对应节点上(SourceRaw → 收录开关与
|
|
50
51
|
知识库根目录;编译 → Schema;构建 → Embedding / Python;召回 → topK / 默认路线;
|
|
51
52
|
重排 → topN / reranker;意图与上下文 → 意图路由),每个节点只保存本节点字段。
|
|
53
|
+
- **编译直接入库(0044)**:`rebuild_knowledge` 的 Pass 0 对指纹变了的来源做实体抽取,
|
|
54
|
+
按 `entityType:entityId` / `title` / `metadata.aliases` 三重索引判重 —— 命中已有卡片就把
|
|
55
|
+
新正文**追加**进去(不覆盖、不丢弃),没命中就新建。缺必填小节 / 字段的卡片**照常入库**,
|
|
56
|
+
问题写进 `metadata.schema_issues`,面板显示成「待补」。**没有任何确认门**:卡片一写盘就进
|
|
57
|
+
wikiNotes、向量与图谱,立刻可召回。
|
|
58
|
+
- **正文只读,备注可加**:卡片正文由编译产出,人改不了(手工写正文返回
|
|
59
|
+
`WIKI_CARD_IMMUTABLE`)。人的判断落在 front matter 的 `annotations` 上
|
|
60
|
+
(`kind: 'anomaly'` 表示异常点),**编译不会覆盖它**。review(`review_wiki_card`)在入库
|
|
61
|
+
之后做,它把卡片评分抬到 `REVIEWED_SCORE_FLOOR`,让它在召回时排前面一点(倍率 0.85–1.2);
|
|
62
|
+
同时把生命周期从 `unreviewed` / `draft` 推进到 `reviewed`(撤销时只退回这一档,
|
|
63
|
+
不动 `active` / `deprecated` / `problem` —— 那些是人另外做过的决定)。
|
|
64
|
+
标注异常点会把有效评分压到 `ANOMALY_SCORE`,但卡片**照样召回得到**,只是排在后面。
|
|
65
|
+
|
|
66
|
+
**合并按小节折进去**:同一实体被第二份文档命中时,新正文并进相同标签的小节里,
|
|
67
|
+
每个小节只出现一次;原来还是占位(「(文档未说明)」)的小节被真内容替换。
|
|
68
|
+
两份正文里只要有一份没有 `##` 结构(规则路径切出来的原文),退回整段拼接。
|
|
69
|
+
- **批量导入只编译一次**(0045):`import_sources` 收一组来源(一次最多 50 份),逐份写入、
|
|
70
|
+
**整批只编译一次**,逐条汇报成败 —— 第 7 份坏了不会让前 6 份白写。十份文档不再是十次审批、
|
|
71
|
+
十次往返、十次抽取。它与 `POST /knowledge/import` 落到同一个运行时方法 `runtime.importSources`,
|
|
72
|
+
与单份的 `add_source` 只差「一次多少份」。
|
|
73
|
+
- **对话流里有专用卡片**(0045):`import_sources` / `recall_knowledge` / `rebuild_knowledge` /
|
|
74
|
+
`add_source` / `propose_wiki_cards` 各自带 `presentationMeta`,浏览器半按**工具名**注册
|
|
75
|
+
`tool.call.toolview`,于是对话里显示的是「导入 3 份来源并编译 · 写入 3 份 · 新建 2 张卡」
|
|
76
|
+
与可展开的命中列表(名次、分数、`entityType:entityId`、review 评分),而不是一坨 JSON。
|
|
77
|
+
meta 随会话日志落盘,所以**回放与当时看到的一致**。
|
|
78
|
+
- **来源里的图跟着文字进卡片**(0047):抽取那一段交给模型的是文字,模型不会把图带回来,
|
|
79
|
+
所以图由编译**单独**落位 —— 拿「图前最近那一段话」去各张卡片正文里比对(12 字滑窗,
|
|
80
|
+
容忍改写与「(参见图表12)」这类图号指引),命中就插在那段话后面;锚点对不上时退回
|
|
81
|
+
「图所在的来源小节」整节比对(还要至少命中 3 个滑窗),落点在正文里再用 4 字滑窗分高下;
|
|
82
|
+
两档都不够就**不挂** —— 宁可少一张图,也不把图挂到一张讲别的事的卡上,没落位的张数如实
|
|
83
|
+
进 `warnings`。收尾的署名图 / 二维码(图后没有正文且锚点很短)故意不挂。每张 wikiNote
|
|
84
|
+
只带**自己那一节**的图,因为多模态编码只吃每条的**第一张**图。图不参与抽取指纹,所以
|
|
85
|
+
0047 之前编好的库重编时,来源虽然被指纹跳过,图仍然会被补上。
|
|
86
|
+
- **图片引用有三种写法,解析只认「真实存在的那个」**(0047):`01_source_raw/_assets/…`
|
|
87
|
+
(规范形,知识库根相对)、`_assets/…`(转换内核早期写进 SourceRaw 的形式)、
|
|
88
|
+
`../../01_source_raw/_assets/…`(`cardHints` 给手工建卡的形式)。文档的资产清单与卡片的
|
|
89
|
+
`imagePaths` 走同一个 `assetRefCandidates`(根目录 → `01_source_raw/` → 文件自己的目录),
|
|
90
|
+
否则同一张图在文档里找得到、在卡片里找不到。派生字段(图片路径、来源分类)变了也算
|
|
91
|
+
「语料变了」,否则增量编译的空操作会把刷新结果丢掉。
|
|
92
|
+
- **SourceRaw 的 front matter 是 OKF v0.2 形状**(0048):`type`(唯一必填键,值就是
|
|
93
|
+
来源分类)、`title`、`description`、`resource`(底层资产地址)、`tags`、
|
|
94
|
+
`generated: {by, at}`(`by` = 谁解析的,`at` = **采集时间** —— OKF 里没有「抓取时间」
|
|
95
|
+
这个概念)、`sources: [{id, resource, title, author, last_modified}]`(对网页就是那个页面
|
|
96
|
+
本身:地址、标题、作者、发布时间)。`source_id` / `external_id` / `created_at` /
|
|
97
|
+
`updated_at` / `metadata` / `lineage` 是我们的扩展键(OKF 明确允许,且要求消费者容忍
|
|
98
|
+
未知键)。**旧文件的 `source_type` 仍然读得到**,存量文件由 `ensureLayout` 一次性迁移
|
|
99
|
+
(只搬已有的值,不编作者与发布时间 —— 0048 之前适配器把它们抽出来就扔了)。
|
|
100
|
+
规范:<https://github.com/GoogleCloudPlatform/open-knowledge-format>(v0.2)。
|
|
101
|
+
- **来源分类可以声明元数据字段**(0048):`SourceTypeDef.metadataFields` 是
|
|
102
|
+
`{key, label, description, required}` 的清单,`key` 用 front matter 顶层键或
|
|
103
|
+
`sources[0].author` 这种路径。面板「类型定义 → 来源分类」里可编辑;缺必填字段时
|
|
104
|
+
`add_source` 回一条 warning(`status: partial`)而**不拒收** —— 元数据缺失是信息不全,
|
|
105
|
+
不是「这份知识不存在」,拒收的代价是知识直接丢了。
|
|
106
|
+
- **召回组装按「卡片」而不是按「片段」**(0050):R1–R3 不变(多路召回 + RRF + 对候选池重排,
|
|
107
|
+
召回与重排的对象都是 wikiNotes),R4 改成四步 —— ① 取 notes 对应的 wiki 去重,一张卡片的等级
|
|
108
|
+
取它名下 note 的**最高重排分**,命中的小节挂在同一条上;② **在这之后**做 wiki → wiki 的
|
|
109
|
+
1 跳扩展(图上的 `relates_to` 边 + 共同来源,上限 20 张);③ 按 `contextMaxChars`
|
|
110
|
+
(默认 20000,`0` = 不限)装箱:命中的 note 正文优先,扩展卡片先给标题 + 摘要 + 来路,
|
|
111
|
+
有余量才给正文;④ 装不下的落**系统临时目录**(`<os.tmpdir()>/dsh-knowledge-recall/<库>/<recallId>.md`),
|
|
112
|
+
上下文里留一行绝对路径 —— Agent 用自己的文件读取能力去取,读不到就调大
|
|
113
|
+
`context_max_chars` 重新召回。响应里 `budget` 是这次的真实账,`expansion` 是 1 跳扩展的结果。
|
|
114
|
+
- **召回栏是一条三步的步骤轨**(0050):召回(找)→ 重排(排)→ 扩展(展),箭头相连,每一步
|
|
115
|
+
带自己的真实计数(`关键词 12 · 向量 9` / `保留 5 · 丢 7` / `3 张 + 2 张`),没跑过时写「未运行」。
|
|
116
|
+
第一步的路由标签可点(点一下只看关键词或向量那一路的候选与分数);第二步列出**全部**候选的
|
|
117
|
+
逐条 logit 与 sigmoid,被丢弃的置灰并写明「低于阈值 0.2」;第三步分两块(命中的卡片 / 1 跳扩展,
|
|
118
|
+
含被预算挡住的),末尾写「最终 N 个 wiki 进上下文」。旋钮跟着步骤走:路线与召回 topK 在第一步,
|
|
119
|
+
上下文 topN 在第三步。这份「面板账本」只在 HTTP 的 `detail=true` 上返回,工具调用不带它。
|
|
120
|
+
- **编译的收尾段产出三样东西**(0049),都不调模型:
|
|
121
|
+
①**索引页** `03_compiled/wiki-index.md` —— 按类型分组列出库里现有的卡片(链接 + 状态 +
|
|
122
|
+
待补数),末尾单列断链。它刻意不写生成时间与版本号:写了它每次重建都变一个字节,而增量
|
|
123
|
+
编译要靠「索引页变了没有」判断这一轮要不要真的落盘。落在 `03_compiled/` 而不是 `02_wiki/`,
|
|
124
|
+
因为后者每一份 `.md` 都会被当成一张卡片读进卡片清单。
|
|
125
|
+
②**相关卡片** —— 写进卡片正文末尾一块(块首带 `<!-- compiled:related -->`,整块替换而不是
|
|
126
|
+
追加)。关系来源有两个:来源文档里写明的关系(双向都记),以及「同一份来源」(补前面没覆盖
|
|
127
|
+
到的,每张卡片上限 8 条)。**它不进召回单元**:相关块是导航不是知识,切进去会让
|
|
128
|
+
「毛利率怎么算」同时命中所有提到毛利率的卡片。
|
|
129
|
+
③**断链检查** —— 正文里 `[[类型/名称]]` 指向不存在的卡片时,写成 `metadata.schema_issues` 里
|
|
130
|
+
`level: 'reference'` 的问题(卡片抽屉上那枚「引用」徽标终于有了内容),同时进 `lintCards()`
|
|
131
|
+
的待补清单。判据与判重同一套(类型 + entityId / 标题 / 别名)。
|
|
132
|
+
- **工具返回值必须能被 JSON 装下**(0046):`envelopeSuccess` / `envelopeFailure` 统一过一遍
|
|
133
|
+
`jsonSafe()`。原因很具体:`rebuild_knowledge` 只重建 wiki 时报告里的 `vectorQuantization` /
|
|
134
|
+
`embeddingDimension` 是 `undefined` —— 卡片、`wiki_notes`、图谱、FTS 全都已经落盘,调用方
|
|
135
|
+
收到的却是 `value is not lossless JSON`。工具返回值要原样进会话日志,而 HTTP 那条路是
|
|
136
|
+
`JSON.stringify`,同一个 `undefined` 在那里无声无息,所以这个错只在工具调用上现形。
|
|
52
137
|
- 编译期一条 wiki 至少产出一条 note;正文按 `##`/`###` 分节且超过 800 字符时按节切分,
|
|
53
138
|
首条 note 的 `unitId` 保持 `<entityType>:<entityId>`,后续为 `<entityType>:<entityId>#<n>`,
|
|
54
139
|
每条 note 都带 `wikiId` 指回父级 wiki。`03_compiled/knowledge_units.json` 作为旧版兼容镜像保留。
|
|
@@ -82,7 +167,7 @@ Tita Data Agent → Agent 概览 →「构建」节点的设置中确认:
|
|
|
82
167
|
|
|
83
168
|
知识库默认保存在 `~/.tita-data-agent/knowledge`;设置了 `DSH_KNOWLEDGE_ROOT`
|
|
84
169
|
或已有旧的 `domain_knowledge` 目录时会优先沿用。点击「编译」后,
|
|
85
|
-
`03_compiled` 会生成 `wiki_notes.json`、`knowledge_graph.json`、
|
|
170
|
+
`03_compiled` 会生成 `wiki_notes.json`、`knowledge_graph.json`、`wiki-index.md`、
|
|
86
171
|
`vector-manifest.json`、`vectors.binary` 和 `vectors.int8`。未修改的 wikiNote
|
|
87
172
|
会复用已有向量,只有新增或变更的 note 重新编码;编码与重排各自使用常驻 Python
|
|
88
173
|
worker(同一份 `src/python/embedding_worker.py`),避免每个请求重复加载模型。
|
|
@@ -107,7 +192,9 @@ BERT 重排默认使用 `BAAI/bge-reranker-base`;如需完全离线,可把
|
|
|
107
192
|
多格式转换是本插件的一个子模块(`src/convert/`),与知识库共用同一次挂载、同一个
|
|
108
193
|
侧边栏 Tab、同一套 runtime。解析由可选内核 `dsh-convert-core` 完成(内核不挂载,可独立
|
|
109
194
|
运行),底层是 `@firecrawl/anydoc`(MIT / Rust / 预编译绑定),支持 doc、docx、ppt、
|
|
110
|
-
pptx、xls、xlsx、odt、ods、odp、rtf、epub、csv 与文本层 PDF
|
|
195
|
+
pptx、xls、xlsx、odt、ods、odp、rtf、epub、csv 与文本层 PDF;另有本地音视频/图片
|
|
196
|
+
(`iddoc`)、扫描件轻量 OCR(`scanned`:`.pdf` 报 `needsOcr` 时**自动兜底**)与
|
|
197
|
+
网页 / 微信公众号文章(`web`:`kind=url` 抓链接,`.html/.htm` 收另存下来的页面)。
|
|
111
198
|
|
|
112
199
|
| 项 | 值 |
|
|
113
200
|
| --- | --- |
|
|
@@ -132,7 +219,7 @@ pptx、xls、xlsx、odt、ods、odp、rtf、epub、csv 与文本层 PDF。
|
|
|
132
219
|
**不传 `kb` 的旧接口与旧工具一律作用于默认库,行为不变**。
|
|
133
220
|
|
|
134
221
|
```ts
|
|
135
|
-
interface KnowledgeBase { id; name; description; rootDir; isDefault; sourceTypes; wikiTypes;
|
|
222
|
+
interface KnowledgeBase { id; name; description; rootDir; isDefault; sourceTypes; wikiTypes; createdAt; updatedAt; sourceCount; cardCount; noteCount; buildVersion }
|
|
136
223
|
```
|
|
137
224
|
|
|
138
225
|
`sourceCount` / `cardCount` / `noteCount` / `buildVersion` 和每条分类/类型的计数都是
|
|
@@ -161,12 +248,12 @@ HTTP `GET /knowledge/bases` 在返回前先刷新。
|
|
|
161
248
|
|
|
162
249
|
| 段 | 装什么 | 删掉的后果 |
|
|
163
250
|
| --- | --- | --- |
|
|
164
|
-
| `
|
|
251
|
+
| `01_source_raw/<source_type>/` | SourceRaw,一级是**来源分类**,二级是文档(**文件名 = 标题**,0051) | 丢数据 |
|
|
165
252
|
| `02_wiki/<entity_type>/` | Wiki 卡片,一级是卡片类型 | 丢结论 |
|
|
166
253
|
| `03_compiled/` | wikiNotes / 向量 / 知识图谱 / 归因图谱 | 可重建 |
|
|
167
254
|
|
|
168
255
|
**归因图谱也在这三段里**(v1.1):一次排查的产物是一条来源分类为 `agent_diagnosis_case`
|
|
169
|
-
的 SourceRaw(落 `
|
|
256
|
+
的 SourceRaw(落 `01_source_raw/`),模板卡由类型定义派生、不落盘,字段级的归因图
|
|
170
257
|
落 `03_compiled/diagnosis_graph.json`。旧的 `05_diagnosis/` 撤销了;它里面的 `*.jsonl`
|
|
171
258
|
如果还在,角色是**只读的迁移输入与历史快照** —— 不再被写,但仍然读得出来(证据与根因
|
|
172
259
|
就从那里来),所以旧知识根不会因为这次改动而读不出内容。
|
|
@@ -176,7 +263,16 @@ schema 段已撤掉:它从建出来那天起就是一个**空目录**,分类
|
|
|
176
263
|
启动时会把空的那个目录删掉 —— **非空则保留**:那就不属于「没用的空文件夹」了,
|
|
177
264
|
删掉别人的文件比留一个空目录危险得多。
|
|
178
265
|
|
|
179
|
-
`
|
|
266
|
+
**文件名用标题(0051)。** `01_source_raw/<分类>/阿里集团大数据建设OneData体系.md` —— `ls`
|
|
267
|
+
认得出、`grep` 文件名有用、`git diff` 看得出改的是哪份材料;`source_id`(`article:bc82…`)仍是
|
|
268
|
+
稳定身份,住在 front matter 里。三条配套规则:①标题里的路径不安全字符换成 `-`、截断到 120 字符、
|
|
269
|
+
只剩替换字符时退回 `source_id`;②**重名默认拒收**(`SOURCE_TITLE_DUPLICATED`,报错指出被谁占着,
|
|
270
|
+
改标题再来)—— 标题是来源的核心属性,两份不同的东西同名是要人处理的信号,不该由命名规则悄悄加后缀;
|
|
271
|
+
③确实要留两份同标题材料时显式传 `allow_duplicate_title: true`,落成 `<标题>-<内容哈希前 6 位>.md`
|
|
272
|
+
并回一条 warning。改名与迁移(老段名 `01_source_truth` → `01_source_raw`、文件名换成标题)在
|
|
273
|
+
`ensureLayout` 里一次性完成,**可重入**;存量正文里带老段名的图片引用不改写,解析器认两个段名。
|
|
274
|
+
|
|
275
|
+
`01_source_raw` 按分类分目录(而不是平铺)的理由与 `02_wiki` 一致:分类是每份来源的
|
|
180
276
|
必备元数据(frontmatter 的 `source_type`),提到目录名上之后「按分类找东西」在文件系统
|
|
181
277
|
层面直接成立,不依赖界面。平铺在真实使用里会先变成垃圾场 —— 几十份来源混在一层,`ls`
|
|
182
278
|
读不出「我的指标口径在哪」。启动时一次性把平铺的文档搬进分类目录;读路径不依赖这个层级
|
|
@@ -220,7 +316,7 @@ GB);旧的 `TITA_DATA_AGENT_HOME` 留在解析链上作为兜底,所以搬
|
|
|
220
316
|
```text
|
|
221
317
|
GET /knowledge/bases → { bases, defaultBaseId }
|
|
222
318
|
POST /knowledge/bases { name, description?, rootDir? } → { base }
|
|
223
|
-
PATCH /knowledge/bases/:id { name?, description?, sourceTypes?, wikiTypes
|
|
319
|
+
PATCH /knowledge/bases/:id { name?, description?, sourceTypes?, wikiTypes? } → { base }
|
|
224
320
|
DELETE /knowledge/bases/:id → { deleted: true }
|
|
225
321
|
GET /knowledge/documents?kb=&query=&source_type=&limit=&offset= → { documents, total }
|
|
226
322
|
GET /knowledge/documents/:docId?kb= → { document }(正文截前 4000 字符)
|
|
@@ -231,17 +327,25 @@ POST /knowledge/documents/:docId/revert?kb= { versionId } → { documen
|
|
|
231
327
|
DELETE /knowledge/documents/:docId?kb= → { deleted: true }
|
|
232
328
|
GET /knowledge/assets/:kb/* → 知识库根目录下的文件流
|
|
233
329
|
GET /knowledge/doc-page.js → 独立整页的脚本(构建产物)
|
|
234
|
-
|
|
235
|
-
POST /knowledge/card-
|
|
236
|
-
POST /
|
|
330
|
+
POST /knowledge/import { kb, sources[], compile? } → { written[], failed[], attempted, compile|null }
|
|
331
|
+
POST /knowledge/card-annotate { kb, entity_id, kind?, note?, remove_id? } → { entityId, annotations, reviewScore }
|
|
332
|
+
POST /knowledge/card-review { kb, entity_id, action } → { entityId, review, reviewScore, status }
|
|
333
|
+
POST /diagnosis/run { kb, record } → { sourceId, entityId }
|
|
237
334
|
```
|
|
238
335
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
336
|
+
**0044:入库之后才 review,不再是「确认之后才入库」。** 编译(Pass 0)与
|
|
337
|
+
`propose_wiki_cards` 都**直接写 `02_wiki`**,卡片立刻进编译、进图、能被召回。
|
|
338
|
+
人在面板上做的是 `POST /knowledge/card-review`(review 抬分 / 撤销)与
|
|
339
|
+
`POST /knowledge/card-annotate`(加备注 / 标异常点)—— 两个动作都可逆,
|
|
340
|
+
而且都作用在**已经存在于库里的卡片**上。原来的提议队列
|
|
341
|
+
(`/knowledge/card-proposals*`、`write_knowledge_card`、`list_card_proposals`)已随确认门
|
|
342
|
+
一起退役;`memory/<库 id>/card-proposals/` 不再被写入。
|
|
343
|
+
|
|
344
|
+
**为什么撤回那道门**:它把知识挡在了门外。抽到的实体停在待办队列里等人一条条点,而人
|
|
345
|
+
不会点 —— 表现就是「文档导进去了,wiki 是空的」。review 的价值不需要靠排队实现:
|
|
346
|
+
「这张卡片对不对」可以在它已经能召回之后回答,而「没 review 就不许进来」等于把
|
|
347
|
+
「暂时没人看的正确知识」和「错误知识」一起丢掉。要否掉一条知识就把它标成 `problem`
|
|
348
|
+
或 `deprecated`,那会留痕、也能撤回。
|
|
245
349
|
|
|
246
350
|
**原文预览只发前 4000 个字符。** `GET /knowledge/documents/:docId` 返回的 `content` 是
|
|
247
351
|
截断过的,全文长度在 `contentChars`、是否截断在 `contentTruncated`。理由是抽屉只有
|
package/cordis.patch.yml
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
## What you work with
|
|
78
78
|
|
|
79
79
|
- **The knowledge store.** Each knowledge base on disk is a tree.
|
|
80
|
-
`
|
|
80
|
+
`01_source_raw` holds SourceRaw: the original business documents, never
|
|
81
81
|
rewritten, kept so that a conclusion can point back at where it came from.
|
|
82
82
|
`02_wiki` holds the cards people read — one per entity, each with mandatory
|
|
83
83
|
`source_refs`, each following a type (`concept`, `metric`, `table`, `event`,
|
|
@@ -112,21 +112,30 @@
|
|
|
112
112
|
3. **Never invent a number.** Every figure you report must come from a tool
|
|
113
113
|
result in this turn, and you must say which one. "I don't have that data" is
|
|
114
114
|
a correct answer; a made-up number is not.
|
|
115
|
-
4. **
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
the
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
5. **
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
4. **Compiling is the normal path, and it writes cards by itself.** You do not
|
|
116
|
+
have to create wiki cards: when a source is added or changed, `rebuild_knowledge`
|
|
117
|
+
extracts entities from it, follows each wiki type's schema (required sections and
|
|
118
|
+
fields), checks whether the wiki already has that entity, and either appends to
|
|
119
|
+
the existing card or creates a new one. A card with missing sections is still
|
|
120
|
+
written — the store keeps what it knows and fills the rest in when a later
|
|
121
|
+
document covers it. So after adding a source, rebuild; then `recall_knowledge`
|
|
122
|
+
and answer from what comes back. **More than one document at a time: use
|
|
123
|
+
`import_sources`** — it writes the whole batch and compiles once, in one call.
|
|
124
|
+
Ten documents through `add_source` means ten approvals and ten compiles, and the
|
|
125
|
+
first nine results are thrown away by the tenth.
|
|
126
|
+
5. **You can add to the wiki, but you cannot rewrite it.** Call `propose_wiki_cards`
|
|
127
|
+
with the `source_id` you just wrote and cards whose `source_refs` already exist in
|
|
128
|
+
the store when you already have structured cards in hand — it writes them
|
|
129
|
+
straight into `02_wiki`, they are recalled from the next compile on. A card whose
|
|
130
|
+
refs point nowhere is rejected, and rightly so. **A card body is read-only**: it
|
|
131
|
+
belongs to the compiler. When something in the store is wrong, or a card and its
|
|
132
|
+
source disagree, do not rewrite it — attach an annotation with
|
|
133
|
+
`annotate_wiki_card` (`kind: anomaly` when the numbers or definitions do not add
|
|
134
|
+
up), or call `set_knowledge_status` to mark it `problem` and say what is wrong.
|
|
135
|
+
Cards marked `problem` drop out of recall by default — that is how a wrong
|
|
136
|
+
definition stops propagating. Everything else is reviewed by a human after entry:
|
|
137
|
+
review raises a card's score, and an anomaly lowers it, but an
|
|
138
|
+
anomaly-flagged card is still recalled.
|
|
130
139
|
6. **Never invent a knowledge base id.** Call `list_knowledge_bases` before
|
|
131
140
|
addressing one you have not seen this session; omit `kb` only when the
|
|
132
141
|
default base is genuinely the right one.
|