dsh-data-domain-knowledge 0.1.0-alpha.13 → 0.1.0-alpha.15
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 +89 -56
- package/cordis.patch.yml +36 -129
- package/eval/benchmark-extraction-format.mjs +20 -0
- package/lib/client.js +3262 -4142
- package/lib/doc-page.js +1 -1
- package/lib/pages.js +1147 -364
- package/lib/types/axis-registry.d.ts +8 -1
- package/lib/types/axis-registry.d.ts.map +1 -1
- package/lib/types/axis-registry.js +62 -7
- package/lib/types/axis-registry.js.map +1 -1
- package/lib/types/convert/host.d.ts.map +1 -1
- package/lib/types/convert/host.js +3 -0
- package/lib/types/convert/host.js.map +1 -1
- package/lib/types/convert/ingest.d.ts +9 -0
- package/lib/types/convert/ingest.d.ts.map +1 -1
- package/lib/types/convert/ingest.js +68 -9
- package/lib/types/convert/ingest.js.map +1 -1
- package/lib/types/diagnosis/cards.d.ts +7 -3
- package/lib/types/diagnosis/cards.d.ts.map +1 -1
- package/lib/types/diagnosis/cards.js +13 -8
- package/lib/types/diagnosis/cards.js.map +1 -1
- package/lib/types/diagnosis/run.d.ts +4 -13
- package/lib/types/diagnosis/run.d.ts.map +1 -1
- package/lib/types/diagnosis/run.js +26 -16
- package/lib/types/diagnosis/run.js.map +1 -1
- package/lib/types/diagnosis/schema.js +2 -2
- package/lib/types/diagnosis/schema.js.map +1 -1
- package/lib/types/diagnosis/seed-source.d.ts +1 -1
- package/lib/types/diagnosis/seed-source.d.ts.map +1 -1
- package/lib/types/diagnosis/seed-source.js +5 -4
- package/lib/types/diagnosis/seed-source.js.map +1 -1
- package/lib/types/diagnosis/seed.d.ts +4 -4
- package/lib/types/diagnosis/seed.d.ts.map +1 -1
- package/lib/types/diagnosis/seed.js +6 -8
- package/lib/types/diagnosis/seed.js.map +1 -1
- package/lib/types/diagnosis/store.d.ts +18 -17
- package/lib/types/diagnosis/store.d.ts.map +1 -1
- package/lib/types/diagnosis/store.js +94 -66
- package/lib/types/diagnosis/store.js.map +1 -1
- package/lib/types/diagnosis/types.d.ts +10 -16
- package/lib/types/diagnosis/types.d.ts.map +1 -1
- package/lib/types/diagnosis/types.js.map +1 -1
- package/lib/types/environment/dsh-python.d.ts +77 -0
- package/lib/types/environment/dsh-python.d.ts.map +1 -0
- package/lib/types/environment/dsh-python.js +139 -0
- package/lib/types/environment/dsh-python.js.map +1 -0
- package/lib/types/environment/install.d.ts +9 -1
- package/lib/types/environment/install.d.ts.map +1 -1
- package/lib/types/environment/install.js +149 -24
- package/lib/types/environment/install.js.map +1 -1
- package/lib/types/environment/model-catalog.d.ts +34 -2
- package/lib/types/environment/model-catalog.d.ts.map +1 -1
- package/lib/types/environment/model-catalog.js +40 -2
- package/lib/types/environment/model-catalog.js.map +1 -1
- package/lib/types/environment/service.d.ts +13 -3
- package/lib/types/environment/service.d.ts.map +1 -1
- package/lib/types/environment/service.js +127 -23
- package/lib/types/environment/service.js.map +1 -1
- package/lib/types/environment/types.d.ts +9 -0
- package/lib/types/environment/types.d.ts.map +1 -1
- package/lib/types/events.d.ts +2 -0
- package/lib/types/events.d.ts.map +1 -1
- package/lib/types/events.js +13 -0
- package/lib/types/events.js.map +1 -1
- package/lib/types/extract-contract.d.ts +1 -1
- package/lib/types/extract-contract.d.ts.map +1 -1
- package/lib/types/extract-contract.js +34 -31
- package/lib/types/extract-contract.js.map +1 -1
- package/lib/types/extract-model.d.ts +2 -0
- package/lib/types/extract-model.d.ts.map +1 -1
- package/lib/types/extract-model.js.map +1 -1
- package/lib/types/extract-table-contract.d.ts +3 -0
- package/lib/types/extract-table-contract.d.ts.map +1 -0
- package/lib/types/extract-table-contract.js +30 -0
- package/lib/types/extract-table-contract.js.map +1 -0
- package/lib/types/extract-table.d.ts +8 -0
- package/lib/types/extract-table.d.ts.map +1 -0
- package/lib/types/extract-table.js +151 -0
- package/lib/types/extract-table.js.map +1 -0
- package/lib/types/extraction-runs.d.ts +30 -6
- package/lib/types/extraction-runs.d.ts.map +1 -1
- package/lib/types/extraction-runs.js +69 -8
- package/lib/types/extraction-runs.js.map +1 -1
- package/lib/types/fs-atomic.d.ts +0 -7
- package/lib/types/fs-atomic.d.ts.map +1 -1
- package/lib/types/fs-atomic.js +17 -2
- package/lib/types/fs-atomic.js.map +1 -1
- package/lib/types/images.d.ts +1 -1
- package/lib/types/images.d.ts.map +1 -1
- package/lib/types/images.js +2 -2
- package/lib/types/images.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +232 -50
- package/lib/types/index.js.map +1 -1
- package/lib/types/intent/scope.d.ts.map +1 -1
- package/lib/types/intent/scope.js +1 -0
- package/lib/types/intent/scope.js.map +1 -1
- package/lib/types/intent/tools.d.ts +19 -0
- package/lib/types/intent/tools.d.ts.map +1 -1
- package/lib/types/intent/tools.js +37 -1
- package/lib/types/intent/tools.js.map +1 -1
- package/lib/types/knowledge-bases.d.ts.map +1 -1
- package/lib/types/knowledge-bases.js +5 -16
- package/lib/types/knowledge-bases.js.map +1 -1
- package/lib/types/knowledge.d.ts +3 -0
- package/lib/types/knowledge.d.ts.map +1 -1
- package/lib/types/knowledge.js +21 -5
- package/lib/types/knowledge.js.map +1 -1
- package/lib/types/materialize-snapshot.d.ts +49 -0
- package/lib/types/materialize-snapshot.d.ts.map +1 -0
- package/lib/types/materialize-snapshot.js +2 -0
- package/lib/types/materialize-snapshot.js.map +1 -0
- package/lib/types/model-text.d.ts +1 -1
- package/lib/types/model-text.d.ts.map +1 -1
- package/lib/types/model-text.js +5 -4
- package/lib/types/model-text.js.map +1 -1
- package/lib/types/oplog.d.ts.map +1 -1
- package/lib/types/oplog.js +7 -0
- package/lib/types/oplog.js.map +1 -1
- package/lib/types/pipeline/engine.d.ts +60 -0
- package/lib/types/pipeline/engine.d.ts.map +1 -0
- package/lib/types/pipeline/engine.js +338 -0
- package/lib/types/pipeline/engine.js.map +1 -0
- package/lib/types/pipeline/store.d.ts +73 -0
- package/lib/types/pipeline/store.d.ts.map +1 -0
- package/lib/types/pipeline/store.js +143 -0
- package/lib/types/pipeline/store.js.map +1 -0
- package/lib/types/pipeline/types.d.ts +101 -0
- package/lib/types/pipeline/types.d.ts.map +1 -0
- package/lib/types/pipeline/types.js +5 -0
- package/lib/types/pipeline/types.js.map +1 -0
- package/lib/types/present.d.ts +2 -0
- package/lib/types/present.d.ts.map +1 -1
- package/lib/types/present.js +9 -4
- package/lib/types/present.js.map +1 -1
- package/lib/types/retention.d.ts +39 -0
- package/lib/types/retention.d.ts.map +1 -0
- package/lib/types/retention.js +42 -0
- package/lib/types/retention.js.map +1 -0
- package/lib/types/runtime.d.ts +115 -5
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/runtime.js +862 -132
- package/lib/types/runtime.js.map +1 -1
- package/lib/types/source-evidence.d.ts +9 -1
- package/lib/types/source-evidence.d.ts.map +1 -1
- package/lib/types/source-evidence.js +13 -5
- package/lib/types/source-evidence.js.map +1 -1
- package/lib/types/store/axis-references.js +3 -3
- package/lib/types/store/axis-references.js.map +1 -1
- package/lib/types/store/derived.d.ts +1 -1
- package/lib/types/store/derived.d.ts.map +1 -1
- package/lib/types/store/derived.js +41 -7
- package/lib/types/store/derived.js.map +1 -1
- package/lib/types/store/knowledge-db.d.ts +18 -0
- package/lib/types/store/knowledge-db.d.ts.map +1 -1
- package/lib/types/store/knowledge-db.js +111 -6
- package/lib/types/store/knowledge-db.js.map +1 -1
- package/lib/types/store/migrate.js +1 -1
- package/lib/types/store/migrate.js.map +1 -1
- package/lib/types/trajectory-types.d.ts +172 -0
- package/lib/types/trajectory-types.d.ts.map +1 -0
- package/lib/types/trajectory-types.js +36 -0
- package/lib/types/trajectory-types.js.map +1 -0
- package/lib/types/types.d.ts +3 -4
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/lib/types/wiki-finalize.d.ts +16 -0
- package/lib/types/wiki-finalize.d.ts.map +1 -1
- package/lib/types/wiki-finalize.js +26 -0
- package/lib/types/wiki-finalize.js.map +1 -1
- package/lib/types/wiki-materialize.d.ts.map +1 -1
- package/lib/types/wiki-materialize.js +3 -15
- package/lib/types/wiki-materialize.js.map +1 -1
- package/lib/types/wiki-trial-types.d.ts +3 -0
- package/lib/types/wiki-trial-types.d.ts.map +1 -1
- package/lib/types/wiki-trial.d.ts +2 -0
- package/lib/types/wiki-trial.d.ts.map +1 -1
- package/lib/types/wiki-trial.js +31 -7
- package/lib/types/wiki-trial.js.map +1 -1
- package/package.json +6 -3
- package/preset/tita-data-agent/agent.cordis.yml +36 -129
- package/src/axis-registry.ts +57 -9
- package/src/client/AttributionEventGuide.tsx +10 -9
- package/src/client/CompileDialogs.tsx +10 -2
- package/src/client/EnvironmentSetup.tsx +76 -16
- package/src/client/ExpansionGraph.tsx +13 -7
- package/src/client/ExtractionTasksPage.tsx +543 -156
- package/src/client/ImportFilesDialog.tsx +2 -13
- package/src/client/IntentTab.tsx +3 -1
- package/src/client/KnowledgeBaseTab.tsx +139 -122
- package/src/client/KnowledgeLayerSection.tsx +19 -2
- package/src/client/KnowledgePanel.tsx +17 -3
- package/src/client/ListPager.tsx +15 -5
- package/src/client/MaterializeTrajectoryView.tsx +124 -0
- package/src/client/NodeSettings.tsx +90 -25
- package/src/client/NormalizeTrajectoryView.tsx +136 -0
- package/src/client/PipelineNotice.tsx +26 -0
- package/src/client/RecallPanel.tsx +55 -25
- package/src/client/TabGuide.tsx +4 -4
- package/src/client/TrialReportView.tsx +61 -16
- package/src/client/TypeDefinitionDrawer.tsx +33 -9
- package/src/client/WikiCardPreview.tsx +43 -10
- package/src/client/WikiFlowPanel.tsx +4 -4
- package/src/client/architecture.tsx +1 -1
- package/src/client/attribution/AttributionTab.tsx +37 -36
- package/src/client/attribution/CaseView.tsx +3 -1
- package/src/client/attribution/EventView.tsx +14 -4
- package/src/client/attribution/RunView.tsx +2 -2
- package/src/client/attribution/ViewSwitch.tsx +20 -5
- package/src/client/attribution/graph-options.ts +38 -31
- package/src/client/attribution/model.ts +16 -9
- package/src/client/graph/palette.ts +165 -0
- package/src/client/pages.css +224 -28
- package/src/client/pages.tsx +33 -11
- package/src/client/styles.css +61 -6
- package/src/client/wiki-trial.ts +30 -1
- package/src/convert/host.ts +3 -0
- package/src/convert/ingest.ts +73 -9
- package/src/diagnosis/cards.ts +13 -8
- package/src/diagnosis/run.ts +27 -17
- package/src/diagnosis/schema.ts +2 -2
- package/src/diagnosis/seed-source.ts +5 -4
- package/src/diagnosis/seed.ts +6 -8
- package/src/diagnosis/store.ts +99 -69
- package/src/diagnosis/types.ts +10 -16
- package/src/environment/dsh-python.ts +156 -0
- package/src/environment/install.ts +134 -19
- package/src/environment/model-catalog.ts +45 -3
- package/src/environment/service.ts +111 -23
- package/src/environment/types.ts +6 -0
- package/src/events.ts +12 -0
- package/src/extract-contract.ts +6 -3
- package/src/extract-model.ts +2 -0
- package/src/extract-table-contract.ts +29 -0
- package/src/extract-table.ts +126 -0
- package/src/extraction-runs.ts +70 -11
- package/src/fs-atomic.ts +19 -2
- package/src/images.ts +2 -2
- package/src/index.ts +207 -72
- package/src/intent/scope.ts +1 -0
- package/src/intent/tools.ts +38 -1
- package/src/knowledge-bases.ts +4 -12
- package/src/knowledge.ts +24 -4
- package/src/materialize-snapshot.ts +46 -0
- package/src/model-text.ts +5 -3
- package/src/oplog.ts +7 -0
- package/src/pipeline/engine.ts +312 -0
- package/src/pipeline/store.ts +147 -0
- package/src/pipeline/types.ts +92 -0
- package/src/present.ts +10 -4
- package/src/retention.ts +76 -0
- package/src/runtime.ts +853 -131
- package/src/source-evidence.ts +12 -5
- package/src/store/axis-references.ts +3 -3
- package/src/store/derived.ts +40 -7
- package/src/store/knowledge-db.ts +111 -5
- package/src/store/migrate.ts +1 -1
- package/src/trajectory-types.ts +142 -0
- package/src/types.ts +3 -4
- package/src/wiki-finalize.ts +28 -0
- package/src/wiki-materialize.ts +3 -14
- package/src/wiki-trial-types.ts +3 -0
- package/src/wiki-trial.ts +26 -7
- package/src/client/convert/ConvertPanel.tsx +0 -583
- package/src/client/convert/styles.css +0 -138
- package/src/client/convert/styles.ts +0 -49
package/src/wiki-trial.ts
CHANGED
|
@@ -65,6 +65,7 @@ import type {
|
|
|
65
65
|
TrialStepItem, TrialStep, TrialCheck, TrialModelCallTrace, TrialReport, TrialTokenUsage,
|
|
66
66
|
} from './wiki-trial-types.js'
|
|
67
67
|
import { buildTrialSystem } from './extract-contract.js'
|
|
68
|
+
import { decodeExtractionTable } from './extract-table.js'
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* 抽取契约(0063 §5.6)。**这是契约,不是要抄进代码的字符串。**
|
|
@@ -702,7 +703,9 @@ export function materialize(knowledge: TrialKnowledge[], events: TrialEvent[] =
|
|
|
702
703
|
}
|
|
703
704
|
for (const event of events) {
|
|
704
705
|
if (event.noCoordinate) continue
|
|
705
|
-
|
|
706
|
+
const key = `${event.object ?? ''}\u0001${event.action ?? ''}\u0001${event.scene ?? ''}`
|
|
707
|
+
// A WikiCard is created by Knowledge. Event only adds a reference to an existing knowledge group.
|
|
708
|
+
groups.get(key)?.events.push(event.id)
|
|
706
709
|
}
|
|
707
710
|
for (const card of groups.values()) {
|
|
708
711
|
card.placements.sort((left, right) =>
|
|
@@ -1006,7 +1009,7 @@ export function buildReport(input: {
|
|
|
1006
1009
|
{ label: '三步', value: '按 (object, action, scene) 分组 → 每组物化成一张 Wiki Card → 生成自然语言标题' },
|
|
1007
1010
|
{ label: '标题组织', value: '完整坐标写成「对象在场景下的动作」;缺少分量时退化为通顺的短标题;旧拼接标题保留为 alias' },
|
|
1008
1011
|
{ label: '为什么不让模型做', value: '坐标是卡片主键 · 标题是确定的展示投影 · 模型判会漂移(同一坐标每次给不同标题会污染召回)' },
|
|
1009
|
-
{ label: '
|
|
1012
|
+
{ label: '卡片由 Knowledge 生成', value: '坐标下至少有一条 Knowledge 才物化 WikiCard;同坐标 Event 只建立引用,不单独建卡' },
|
|
1010
1013
|
{ label: '不成卡的那些', value: noCoordinate.length + events.filter(event => event.noCoordinate).length > 0 ? `${noCoordinate.length} 条 Knowledge、${events.filter(event => event.noCoordinate).length} 个 Event 缺少坐标,不归入坐标卡` : '无' },
|
|
1011
1014
|
],
|
|
1012
1015
|
items: wikiCards.length > 0
|
|
@@ -1053,7 +1056,7 @@ export function buildReport(input: {
|
|
|
1053
1056
|
],
|
|
1054
1057
|
items: [
|
|
1055
1058
|
makeItem('召回单元', `${sections.size} 个 section`, '卡片按 ## 小节切成一节一条'),
|
|
1056
|
-
makeItem('Knowledge / Event', `${knowledge.length} / ${events.length}`, '两类并列真源;
|
|
1059
|
+
makeItem('Knowledge / Event', `${knowledge.length} / ${events.length}`, '两类并列真源;Knowledge 生成 WikiCard,Event 通过引用关联'),
|
|
1057
1060
|
makeItem('轴注册表', `${axes.length} 条`, 'canonical name + aliases —— 不是索引'),
|
|
1058
1061
|
],
|
|
1059
1062
|
},
|
|
@@ -1202,12 +1205,14 @@ export async function runWikiTrial(input: {
|
|
|
1202
1205
|
modelRequest?: Omit<NonNullable<TrialReport['model']['request']>, 'sessionId'>
|
|
1203
1206
|
call?: ModelCall
|
|
1204
1207
|
callWhy?: string
|
|
1208
|
+
outputFormat?: 'table' | 'json'
|
|
1209
|
+
onDelta?: (text: string) => void
|
|
1205
1210
|
}): Promise<TrialReport> {
|
|
1206
1211
|
const subject = (input.subject ?? '').trim()
|
|
1207
1212
|
const docId = (input.docId ?? '').trim()
|
|
1208
1213
|
// 提示词先组装好再走分支:模型不可用时它照样要回给界面 —— 用户要看的正是"本来会发出去什么"。
|
|
1209
1214
|
const promptUser = buildTrialPrompt({ title: input.title, text: input.text, ...(input.axes === undefined ? {} : { axes: input.axes }), ...(input.note ? { note: input.note } : {}) })
|
|
1210
|
-
const system = buildTrialSystem(input.sections)
|
|
1215
|
+
const system = buildTrialSystem(input.sections, input.outputFormat)
|
|
1211
1216
|
const sessionId = input.sessionId ?? 'knowledge:trial'
|
|
1212
1217
|
const request = { ...input.modelRequest, sessionId }
|
|
1213
1218
|
const axesContext = input.axes === undefined ? undefined : {
|
|
@@ -1228,7 +1233,7 @@ export async function runWikiTrial(input: {
|
|
|
1228
1233
|
let raw = ''
|
|
1229
1234
|
let usage: TrialTokenUsage | undefined
|
|
1230
1235
|
try {
|
|
1231
|
-
raw = await input.call({ system, prompt: promptUser, sessionId, onUsage: value => { usage = value } })
|
|
1236
|
+
raw = await input.call({ system, prompt: promptUser, sessionId, onUsage: value => { usage = value }, onDelta: text => { raw += text; input.onDelta?.(text) } })
|
|
1232
1237
|
} catch (cause) {
|
|
1233
1238
|
return emptyReport({
|
|
1234
1239
|
title: input.title, text: input.text, subject: subject || input.title, promptUser, system,
|
|
@@ -1237,12 +1242,20 @@ export async function runWikiTrial(input: {
|
|
|
1237
1242
|
ok: false,
|
|
1238
1243
|
why: `调用模型失败:${cause instanceof Error ? cause.message : String(cause)}`,
|
|
1239
1244
|
request,
|
|
1245
|
+
...(raw ? { response: raw } : {}),
|
|
1240
1246
|
...(usage ? { usage } : {}),
|
|
1241
1247
|
},
|
|
1242
1248
|
})
|
|
1243
1249
|
}
|
|
1244
1250
|
|
|
1245
|
-
|
|
1251
|
+
let parsed: unknown
|
|
1252
|
+
let outputFormat: 'table' | 'json' = 'json'
|
|
1253
|
+
let parseError = ''
|
|
1254
|
+
const body = raw.trim().replace(/^```(?:toon|text)?\s*\n/, '').replace(/\n```\s*$/, '')
|
|
1255
|
+
try {
|
|
1256
|
+
if (/^format:\s*knowledge-table-v1\s*$/m.test(body)) { parsed = decodeExtractionTable(body); outputFormat = 'table' }
|
|
1257
|
+
else parsed = parseJsonObject(raw)
|
|
1258
|
+
} catch (cause) { parseError = cause instanceof Error ? cause.message : String(cause) }
|
|
1246
1259
|
const record = parsed !== null && typeof parsed === 'object' ? parsed as Record<string, unknown> : undefined
|
|
1247
1260
|
if (!record) {
|
|
1248
1261
|
return emptyReport({
|
|
@@ -1250,7 +1263,7 @@ export async function runWikiTrial(input: {
|
|
|
1250
1263
|
axesContext,
|
|
1251
1264
|
model: {
|
|
1252
1265
|
ok: false,
|
|
1253
|
-
why: '
|
|
1266
|
+
why: parseError || '模型返回不是有效的抽取表格或兼容 JSON',
|
|
1254
1267
|
request,
|
|
1255
1268
|
response: raw,
|
|
1256
1269
|
...(usage ? { usage } : {}),
|
|
@@ -1331,6 +1344,12 @@ export async function runWikiTrial(input: {
|
|
|
1331
1344
|
dropped,
|
|
1332
1345
|
model: {
|
|
1333
1346
|
ok: knowledgeRead.knowledge.length > 0 || eventRead.events.length > 0,
|
|
1347
|
+
parsed: Array.isArray(record.knowledge) && Array.isArray(record.events ?? [])
|
|
1348
|
+
&& knowledgeRead.knowledge.length === record.knowledge.length
|
|
1349
|
+
&& eventRead.events.length === (Array.isArray(record.events) ? record.events.length : 0)
|
|
1350
|
+
&& knowledgeRead.knowledge.every(item => item.sources.length > 0 && item.sources.every(source => source.found))
|
|
1351
|
+
&& eventRead.events.every(item => [...item.sources, ...item.timeline.flatMap(step => step.sources)].every(source => source.found)),
|
|
1352
|
+
outputFormat,
|
|
1334
1353
|
...(!(knowledgeRead.knowledge.length > 0 || eventRead.events.length > 0) ? { why: '模型没有给出 Knowledge 或 Event' } : {}),
|
|
1335
1354
|
request,
|
|
1336
1355
|
response: raw,
|