dsh-data-domain-knowledge 0.1.0-alpha.9 → 0.1.1-alpha.2
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 +118 -567
- package/cordis.patch.yml +5 -418
- package/eval/README.md +19 -8
- package/eval/benchmark-extraction-format.mjs +20 -0
- package/eval/evaluate-retrieval.mjs +17 -8
- package/eval/queries.example.jsonl +1 -0
- package/lib/client.js +4181 -3239
- package/lib/contract-envelope.d.ts +91 -0
- package/lib/contract-envelope.js +106 -0
- package/lib/contract-layout.d.ts +130 -0
- package/lib/contract-layout.js +138 -0
- package/lib/contract-refs.d.ts +39 -0
- package/lib/contract-refs.js +9 -0
- package/lib/contract-version.d.ts +311 -0
- package/lib/contract-version.js +270 -0
- package/lib/contract-wire.d.ts +147 -0
- package/lib/contract-wire.js +99 -0
- package/lib/contracts.d.ts +12 -0
- package/lib/contracts.js +12 -0
- package/lib/doc-page.js +2 -2
- package/lib/pages.js +3329 -1296
- package/lib/types/agent-behavior-rules.d.ts +10 -0
- package/lib/types/agent-behavior-rules.d.ts.map +1 -0
- package/lib/types/agent-behavior-rules.js +28 -0
- package/lib/types/agent-behavior-rules.js.map +1 -0
- package/lib/types/axis-registry.d.ts +37 -5
- package/lib/types/axis-registry.d.ts.map +1 -1
- package/lib/types/axis-registry.js +234 -26
- package/lib/types/axis-registry.js.map +1 -1
- package/lib/types/card-organize.d.ts +27 -12
- package/lib/types/card-organize.d.ts.map +1 -1
- package/lib/types/card-organize.js +58 -73
- package/lib/types/card-organize.js.map +1 -1
- package/lib/types/compiler/embedding-identity.d.ts +3 -0
- package/lib/types/compiler/embedding-identity.d.ts.map +1 -0
- package/lib/types/compiler/embedding-identity.js +24 -0
- package/lib/types/compiler/embedding-identity.js.map +1 -0
- package/lib/types/compiler/snapshot.d.ts +16 -0
- package/lib/types/compiler/snapshot.d.ts.map +1 -0
- package/lib/types/compiler/snapshot.js +2 -0
- package/lib/types/compiler/snapshot.js.map +1 -0
- package/lib/types/config-schema.d.ts +6 -3
- package/lib/types/config-schema.d.ts.map +1 -1
- package/lib/types/config-schema.js +6 -2
- package/lib/types/config-schema.js.map +1 -1
- package/lib/types/convert/host.d.ts +6 -5
- package/lib/types/convert/host.d.ts.map +1 -1
- package/lib/types/convert/host.js +58 -18
- package/lib/types/convert/host.js.map +1 -1
- package/lib/types/convert/ingest.d.ts +10 -1
- 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/derive-contract.d.ts +3 -0
- package/lib/types/derive-contract.d.ts.map +1 -0
- package/lib/types/derive-contract.js +15 -0
- package/lib/types/derive-contract.js.map +1 -0
- 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 +24 -18
- package/lib/types/diagnosis/store.d.ts.map +1 -1
- package/lib/types/diagnosis/store.js +130 -65
- package/lib/types/diagnosis/store.js.map +1 -1
- package/lib/types/diagnosis/types.d.ts +47 -15
- 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 +15 -0
- package/lib/types/environment/install.d.ts.map +1 -0
- package/lib/types/environment/install.js +297 -0
- package/lib/types/environment/install.js.map +1 -0
- package/lib/types/environment/manifest.d.ts +208 -0
- package/lib/types/environment/manifest.d.ts.map +1 -0
- package/lib/types/environment/manifest.js +26 -0
- package/lib/types/environment/manifest.js.map +1 -0
- package/lib/types/environment/model-catalog.d.ts +223 -0
- package/lib/types/environment/model-catalog.d.ts.map +1 -0
- package/lib/types/environment/model-catalog.js +129 -0
- package/lib/types/environment/model-catalog.js.map +1 -0
- package/lib/types/environment/process.d.ts +10 -0
- package/lib/types/environment/process.d.ts.map +1 -0
- package/lib/types/environment/process.js +54 -0
- package/lib/types/environment/process.js.map +1 -0
- package/lib/types/environment/selection.d.ts +9 -0
- package/lib/types/environment/selection.d.ts.map +1 -0
- package/lib/types/environment/selection.js +29 -0
- package/lib/types/environment/selection.js.map +1 -0
- package/lib/types/environment/service.d.ts +64 -0
- package/lib/types/environment/service.d.ts.map +1 -0
- package/lib/types/environment/service.js +424 -0
- package/lib/types/environment/service.js.map +1 -0
- package/lib/types/environment/types.d.ts +56 -0
- package/lib/types/environment/types.d.ts.map +1 -0
- package/lib/types/environment/types.js +2 -0
- package/lib/types/environment/types.js.map +1 -0
- package/lib/types/events.d.ts +76 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/events.js +52 -0
- package/lib/types/events.js.map +1 -0
- package/lib/types/extract-contract.d.ts +3 -0
- package/lib/types/extract-contract.d.ts.map +1 -0
- package/lib/types/extract-contract.js +41 -0
- package/lib/types/extract-contract.js.map +1 -0
- package/lib/types/extract-model.d.ts +5 -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 +27 -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 +158 -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 +26 -0
- package/lib/types/images.d.ts.map +1 -0
- package/lib/types/images.js +196 -0
- package/lib/types/images.js.map +1 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +598 -209
- package/lib/types/index.js.map +1 -1
- package/lib/types/intent/engine.d.ts +12 -4
- package/lib/types/intent/engine.d.ts.map +1 -1
- package/lib/types/intent/engine.js +43 -5
- package/lib/types/intent/engine.js.map +1 -1
- package/lib/types/intent/host.d.ts +5 -8
- package/lib/types/intent/host.d.ts.map +1 -1
- package/lib/types/intent/host.js +56 -11
- package/lib/types/intent/host.js.map +1 -1
- package/lib/types/intent/scope.d.ts +25 -0
- package/lib/types/intent/scope.d.ts.map +1 -0
- package/lib/types/intent/scope.js +116 -0
- package/lib/types/intent/scope.js.map +1 -0
- package/lib/types/intent/tools.d.ts +24 -20
- package/lib/types/intent/tools.d.ts.map +1 -1
- package/lib/types/intent/tools.js +65 -23
- package/lib/types/intent/tools.js.map +1 -1
- package/lib/types/intent/types.d.ts +11 -4
- package/lib/types/intent/types.d.ts.map +1 -1
- package/lib/types/knowledge-bases.d.ts +11 -5
- package/lib/types/knowledge-bases.d.ts.map +1 -1
- package/lib/types/knowledge-bases.js +52 -20
- package/lib/types/knowledge-bases.js.map +1 -1
- package/lib/types/knowledge-contract.d.ts +32 -0
- package/lib/types/knowledge-contract.d.ts.map +1 -0
- package/lib/types/knowledge-contract.js +116 -0
- package/lib/types/knowledge-contract.js.map +1 -0
- package/lib/types/knowledge.d.ts +31 -9
- package/lib/types/knowledge.d.ts.map +1 -1
- package/lib/types/knowledge.js +137 -60
- package/lib/types/knowledge.js.map +1 -1
- package/lib/types/layout.d.ts +10 -29
- package/lib/types/layout.d.ts.map +1 -1
- package/lib/types/layout.js +17 -36
- package/lib/types/layout.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/migrate.d.ts +11 -0
- package/lib/types/migrate.d.ts.map +1 -1
- package/lib/types/migrate.js +83 -2
- package/lib/types/migrate.js.map +1 -1
- package/lib/types/model-text.d.ts +58 -1
- package/lib/types/model-text.d.ts.map +1 -1
- package/lib/types/model-text.js +85 -30
- 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/organize-contract.d.ts +18 -0
- package/lib/types/organize-contract.d.ts.map +1 -0
- package/lib/types/organize-contract.js +82 -0
- package/lib/types/organize-contract.js.map +1 -0
- package/lib/types/pipeline/engine.d.ts +66 -0
- package/lib/types/pipeline/engine.d.ts.map +1 -0
- package/lib/types/pipeline/engine.js +352 -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 +102 -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/preset-ids.d.ts +4 -0
- package/lib/types/preset-ids.d.ts.map +1 -0
- package/lib/types/preset-ids.js +6 -0
- package/lib/types/preset-ids.js.map +1 -0
- package/lib/types/query-analysis.d.ts +13 -1
- package/lib/types/query-analysis.d.ts.map +1 -1
- package/lib/types/query-analysis.js +62 -6
- package/lib/types/query-analysis.js.map +1 -1
- package/lib/types/recall-rank.d.ts +3 -3
- package/lib/types/recall-rank.d.ts.map +1 -1
- package/lib/types/recall-rank.js +4 -4
- package/lib/types/recall-rank.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/retrieval/vector-index.d.ts +32 -0
- package/lib/types/retrieval/vector-index.d.ts.map +1 -0
- package/lib/types/retrieval/vector-index.js +15 -0
- package/lib/types/retrieval/vector-index.js.map +1 -0
- package/lib/types/retrieval/visibility.d.ts +6 -0
- package/lib/types/retrieval/visibility.d.ts.map +1 -0
- package/lib/types/retrieval/visibility.js +11 -0
- package/lib/types/retrieval/visibility.js.map +1 -0
- package/lib/types/runtime.d.ts +272 -27
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/runtime.js +2751 -537
- package/lib/types/runtime.js.map +1 -1
- package/lib/types/settings-schema.d.ts +17 -15
- package/lib/types/settings-schema.d.ts.map +1 -1
- package/lib/types/settings-schema.js +50 -47
- package/lib/types/settings-schema.js.map +1 -1
- package/lib/types/settings-volatile.d.ts +4 -4
- package/lib/types/settings-volatile.js +4 -4
- package/lib/types/source-evidence.d.ts +14 -0
- package/lib/types/source-evidence.d.ts.map +1 -0
- package/lib/types/source-evidence.js +36 -0
- package/lib/types/source-evidence.js.map +1 -0
- package/lib/types/store/axis-references.d.ts +5 -0
- package/lib/types/store/axis-references.d.ts.map +1 -0
- package/lib/types/store/axis-references.js +106 -0
- package/lib/types/store/axis-references.js.map +1 -0
- package/lib/types/store/derived.d.ts +12 -1
- package/lib/types/store/derived.d.ts.map +1 -1
- package/lib/types/store/derived.js +71 -12
- package/lib/types/store/derived.js.map +1 -1
- package/lib/types/store/knowledge-db.d.ts +31 -1
- package/lib/types/store/knowledge-db.d.ts.map +1 -1
- package/lib/types/store/knowledge-db.js +252 -18
- package/lib/types/store/knowledge-db.js.map +1 -1
- package/lib/types/store/migrate.d.ts.map +1 -1
- package/lib/types/store/migrate.js +17 -6
- 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 +59 -27
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js +6 -15
- 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 +4 -0
- package/lib/types/wiki-materialize.d.ts.map +1 -1
- package/lib/types/wiki-materialize.js +21 -7
- package/lib/types/wiki-materialize.js.map +1 -1
- package/lib/types/wiki-trial-types.d.ts +87 -0
- package/lib/types/wiki-trial-types.d.ts.map +1 -1
- package/lib/types/wiki-trial-types.js +0 -16
- package/lib/types/wiki-trial-types.js.map +1 -1
- package/lib/types/wiki-trial.d.ts +40 -16
- package/lib/types/wiki-trial.d.ts.map +1 -1
- package/lib/types/wiki-trial.js +337 -224
- package/lib/types/wiki-trial.js.map +1 -1
- package/package.json +29 -20
- package/python/prepare-models.py +19 -0
- package/python/requirements.txt +8 -6
- package/scripts/doctor.mjs +13 -19
- package/scripts/environment.mjs +29 -0
- package/scripts/setup-embedding.sh +15 -5
- package/src/agent-behavior-rules.ts +37 -0
- package/src/axis-registry.ts +234 -27
- package/src/card-organize.ts +69 -75
- package/src/client/AgentBehaviorRulesCard.tsx +65 -0
- package/src/client/AttributionEventGuide.tsx +41 -39
- package/src/client/AxisRegistrySection.tsx +204 -164
- package/src/client/CompileDialogs.tsx +44 -29
- package/src/client/DeleteDocumentDialog.tsx +36 -5
- package/src/client/DirectoryPicker.tsx +0 -10
- package/src/client/EnvironmentSetup.tsx +243 -0
- package/src/client/ExpansionGraph.tsx +13 -7
- package/src/client/ExtractionTasksPage.tsx +578 -0
- package/src/client/GuideArchitectureCanvas.tsx +470 -0
- package/src/client/ImportFilesDialog.tsx +2 -13
- package/src/client/IntentLogic.tsx +2 -2
- package/src/client/IntentTab.tsx +118 -47
- package/src/client/KnowledgeBaseTab.tsx +277 -197
- package/src/client/KnowledgeLayerSection.tsx +24 -6
- package/src/client/KnowledgePanel.tsx +58 -93
- package/src/client/KnowledgeSettingsDrawer.tsx +90 -0
- package/src/client/ListPager.tsx +15 -5
- package/src/client/MaterializeTrajectoryView.tsx +124 -0
- package/src/client/NodeSettings.tsx +210 -89
- package/src/client/NormalizeTrajectoryView.tsx +136 -0
- package/src/client/PipelineNotice.tsx +26 -0
- package/src/client/PreviewSections.tsx +118 -51
- package/src/client/RecallPanel.tsx +89 -85
- package/src/client/TabGuide.tsx +159 -184
- package/src/client/TrialReportView.tsx +391 -214
- package/src/client/TypeDefinitionDrawer.tsx +150 -23
- package/src/client/WikiCardPreview.tsx +62 -16
- package/src/client/WikiFlowPanel.tsx +4 -4
- package/src/client/arch/NodeLogicPanel.tsx +3 -4
- package/src/client/arch/model.ts +6 -9
- package/src/client/architecture.tsx +23 -33
- package/src/client/attribution/AttributionGraph.tsx +10 -6
- package/src/client/attribution/AttributionTab.tsx +136 -84
- package/src/client/attribution/CaseView.tsx +3 -1
- package/src/client/attribution/EventView.tsx +108 -0
- package/src/client/attribution/RunView.tsx +2 -2
- package/src/client/attribution/StageChrome.tsx +34 -3
- package/src/client/attribution/ViewSwitch.tsx +20 -5
- package/src/client/attribution/graph-options.ts +47 -39
- package/src/client/attribution/model.ts +17 -10
- package/src/client/config-scope.ts +3 -3
- package/src/client/graph/palette.ts +165 -0
- package/src/client/index.ts +49 -42
- package/src/client/pages.css +459 -135
- package/src/client/pages.tsx +37 -9
- package/src/client/problem-domains.ts +1 -1
- package/src/client/session-remote.ts +9 -0
- package/src/client/styles.css +205 -62
- package/src/client/wiki-trial.ts +44 -3
- package/src/compiler/embedding-identity.ts +21 -0
- package/src/compiler/snapshot.ts +17 -0
- package/src/config-schema.ts +8 -3
- package/src/convert/host.ts +56 -21
- package/src/convert/ingest.ts +74 -10
- package/src/derive-contract.ts +14 -0
- 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 +138 -69
- package/src/diagnosis/types.ts +34 -15
- package/src/environment/dsh-python.ts +156 -0
- package/src/environment/install.ts +244 -0
- package/src/environment/manifest.ts +28 -0
- package/src/environment/model-catalog.ts +147 -0
- package/src/environment/process.ts +54 -0
- package/src/environment/selection.ts +29 -0
- package/src/environment/service.ts +348 -0
- package/src/environment/types.ts +45 -0
- package/src/events.ts +108 -0
- package/src/extract-contract.ts +42 -0
- package/src/extract-model.ts +10 -1
- package/src/extract-table-contract.ts +26 -0
- package/src/extract-table.ts +132 -0
- package/src/extraction-runs.ts +70 -11
- package/src/fs-atomic.ts +19 -2
- package/src/images.ts +203 -0
- package/src/index.ts +553 -205
- package/src/intent/README.md +8 -6
- package/src/intent/engine.ts +44 -6
- package/src/intent/host.ts +59 -18
- package/src/intent/scope.ts +125 -0
- package/src/intent/tools.ts +70 -28
- package/src/intent/types.ts +11 -4
- package/src/knowledge-bases.ts +56 -20
- package/src/knowledge-contract.ts +114 -0
- package/src/knowledge.ts +138 -69
- package/src/layout.ts +17 -37
- package/src/materialize-snapshot.ts +46 -0
- package/src/migrate.ts +75 -2
- package/src/model-text.ts +109 -4
- package/src/oplog.ts +7 -0
- package/src/organize-contract.ts +83 -0
- package/src/pipeline/engine.ts +323 -0
- package/src/pipeline/store.ts +147 -0
- package/src/pipeline/types.ts +93 -0
- package/src/present.ts +10 -4
- package/src/preset-ids.ts +6 -0
- package/src/python/embedding_worker.py +66 -2
- package/src/query-analysis.ts +68 -8
- package/src/recall-rank.ts +5 -5
- package/src/retention.ts +76 -0
- package/src/retrieval/vector-index.ts +45 -0
- package/src/retrieval/visibility.ts +14 -0
- package/src/runtime.ts +2708 -567
- package/src/settings-schema.ts +11 -8
- package/src/settings-volatile.ts +4 -4
- package/src/source-evidence.ts +37 -0
- package/src/store/axis-references.ts +96 -0
- package/src/store/derived.ts +70 -12
- package/src/store/knowledge-db.ts +248 -17
- package/src/store/migrate.ts +16 -6
- package/src/trajectory-types.ts +142 -0
- package/src/types.ts +61 -35
- package/src/wiki-finalize.ts +28 -0
- package/src/wiki-materialize.ts +25 -6
- package/src/wiki-trial-types.ts +83 -1
- package/src/wiki-trial.ts +357 -185
- package/lib/types/intent/preset-tools.d.ts +0 -37
- package/lib/types/intent/preset-tools.d.ts.map +0 -1
- package/lib/types/intent/preset-tools.js +0 -45
- package/lib/types/intent/preset-tools.js.map +0 -1
- package/preset/tita-data-agent/agent.cordis.yml +0 -394
- package/preset/tita-data-agent/preset.yml +0 -3
- package/scripts/install-agent-preset.mjs +0 -92
- package/scripts/sync-agent-preset.mjs +0 -188
- package/src/client/AgentPresetCard.tsx +0 -247
- package/src/client/agent-preset.ts +0 -121
- 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/intent/preset-tools.ts +0 -48
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
|
|
31
31
|
import { useMemo, useState, type ReactNode } from 'react'
|
|
32
32
|
import {
|
|
33
|
-
Bot, ChevronDown, Copy,
|
|
33
|
+
Bot, ChevronDown, Copy, Settings2,
|
|
34
34
|
TriangleAlert, UserRound,
|
|
35
35
|
} from '@tita-agent/ui/icons'
|
|
36
|
-
import { cn } from '@tita-agent/ui/components'
|
|
36
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger, cn } from '@tita-agent/ui/components'
|
|
37
37
|
import type {
|
|
38
|
-
TrialActor, TrialKnowledge, TrialMatrix, TrialMatrixGroup, TrialReportView, TrialSource,
|
|
38
|
+
TrialActor, TrialEvent, TrialEventStepKind, TrialKnowledge, TrialMatrix, TrialMatrixGroup, TrialReportView, TrialSource, TrialTokenUsage,
|
|
39
39
|
} from './wiki-trial.ts'
|
|
40
40
|
import { AxisMatrix, coordLabel, sceneLabel, type MatrixPick, type MatrixView } from './AxisMatrix.tsx'
|
|
41
41
|
import { styles } from './styles.ts'
|
|
42
42
|
|
|
43
43
|
/** 执行人 → 图标 + 说明。三档固定,不再多分。 */
|
|
44
44
|
const ACTOR: Record<TrialActor, { icon: typeof Bot; hint: string }> = {
|
|
45
|
-
模型: { icon: Bot, hint: '抽取 Knowledge
|
|
45
|
+
模型: { icon: Bot, hint: '抽取 Knowledge 与坐标;编译时可对候选歧义补判' },
|
|
46
46
|
系统: { icon: Settings2, hint: '确定性规则,每次结果一致:归一、绑定、物化、建索引' },
|
|
47
47
|
人: { icon: UserRound, hint: '只看规则与模型都覆盖不到的:同义裁决、冲突裁决、editorial' },
|
|
48
48
|
}
|
|
@@ -53,6 +53,212 @@ const ITEM_CAP = 24
|
|
|
53
53
|
/** 知识是平铺清单,给得比步骤宽一点,但也要有上限。 */
|
|
54
54
|
const LIST_CAP = 60
|
|
55
55
|
|
|
56
|
+
function tokenCount(value: number | undefined): string {
|
|
57
|
+
return value === undefined ? '—' : value.toLocaleString('zh-CN')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function usageSummary(usage?: TrialTokenUsage): string {
|
|
61
|
+
if (!usage) return '用量未返回'
|
|
62
|
+
const hasInput = usage.inputTokens !== undefined || usage.cacheReadTokens !== undefined || usage.cacheWriteTokens !== undefined
|
|
63
|
+
const input = hasInput
|
|
64
|
+
? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0)
|
|
65
|
+
: undefined
|
|
66
|
+
const total = usage.totalTokens ?? (input !== undefined && usage.outputTokens !== undefined ? input + usage.outputTokens : undefined)
|
|
67
|
+
return `输入 ${tokenCount(input)} · 输出 ${tokenCount(usage.outputTokens)} · 合计 ${tokenCount(total)} tokens`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function totalTokensOf(usage?: TrialTokenUsage): number | undefined {
|
|
71
|
+
if (!usage) return undefined
|
|
72
|
+
if (usage.totalTokens !== undefined) return usage.totalTokens
|
|
73
|
+
if (usage.outputTokens === undefined) return undefined
|
|
74
|
+
const hasInput = usage.inputTokens !== undefined || usage.cacheReadTokens !== undefined || usage.cacheWriteTokens !== undefined
|
|
75
|
+
if (!hasInput) return undefined
|
|
76
|
+
return (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0) + usage.outputTokens
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const EVENT_STEP_LABEL: Record<TrialEventStepKind, string> = {
|
|
80
|
+
observation: '观察', check: '核对', action: '操作', result: '结果', conclusion: '结论',
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 区块导航。
|
|
85
|
+
*
|
|
86
|
+
* 这份报告可以有七步、几十条知识、几百 KB —— 打开它的人第一件事是「跳到我要看的那一段」,
|
|
87
|
+
* 而不是从上往下读。所以顶上放一条**锚点条**:它是这一页的目录,不是第二个流程说明。
|
|
88
|
+
*
|
|
89
|
+
* 用 `<a href>` 而不是按钮:这一页就是一份文档,锚点带来的是「复制链接给同事」这种
|
|
90
|
+
* 浏览器本来就有的能力(`#steps` 直接落到处理步骤)。
|
|
91
|
+
*/
|
|
92
|
+
const SECTIONS: Array<{ id: string; label: string }> = [
|
|
93
|
+
{ id: 'trial-overview', label: '概览' },
|
|
94
|
+
{ id: 'trial-output', label: '抽取内容' },
|
|
95
|
+
{ id: 'trial-steps', label: '处理步骤' },
|
|
96
|
+
{ id: 'trial-requests', label: '模型请求' },
|
|
97
|
+
{ id: 'trial-review', label: '核验结果' },
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
function SectionNav({ items }: { items: typeof SECTIONS }): ReactNode {
|
|
101
|
+
return <nav className={styles.trialNav} aria-label="报告区块">
|
|
102
|
+
{items.map(section => <a key={section.id} href={`#${section.id}`}>{section.label}</a>)}
|
|
103
|
+
</nav>
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function InlineDisclosure({ summary, children }: { summary: string; children: ReactNode }): ReactNode {
|
|
107
|
+
const [expanded, setExpanded] = useState(false)
|
|
108
|
+
return <>
|
|
109
|
+
<button type="button" className={styles.trialDetailToggle} aria-expanded={expanded}
|
|
110
|
+
onClick={() => setExpanded(value => !value)}>
|
|
111
|
+
<ChevronDown size={11} className={cn(styles.trialChevron, expanded && styles.trialChevronOpen)} />{summary}
|
|
112
|
+
</button>
|
|
113
|
+
{expanded && <div className={styles.trialDetailBody}>{children}</div>}
|
|
114
|
+
</>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function KnowledgeOutputItem({ item }: { item: TrialKnowledge }): ReactNode {
|
|
118
|
+
return <li className={styles.trialOutputItem}>
|
|
119
|
+
<div className={styles.trialCandHead}>
|
|
120
|
+
<span className={cn(styles.trialCandName, item.noCoordinate && styles.trialCandBad)}>{item.text}</span>
|
|
121
|
+
<span className={styles.trialCandMeta}>{item.id}</span>
|
|
122
|
+
</div>
|
|
123
|
+
<div className={styles.trialOutputMeta}>
|
|
124
|
+
{coordLabel(item.object, item.action, item.scene)} · {item.section} 第 {item.order} 位 · {item.sources.length} 处来源
|
|
125
|
+
{item.noCoordinate && <strong>缺少坐标</strong>}
|
|
126
|
+
</div>
|
|
127
|
+
{item.sources.length > 0 && <InlineDisclosure summary={`查看 ${item.sources.length} 处来源`}>
|
|
128
|
+
<ul className={styles.trialSources}>{item.sources.map((source, index) => <SourceLine key={index} source={source} />)}</ul>
|
|
129
|
+
</InlineDisclosure>}
|
|
130
|
+
</li>
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function EventOutputItem({ event }: { event: TrialEvent }): ReactNode {
|
|
134
|
+
const coordinate = coordLabel(event.object, event.action, event.scene)
|
|
135
|
+
const sourceCount = event.sources.length + event.timeline.reduce((sum, step) => sum + step.sources.length, 0)
|
|
136
|
+
return <li className={styles.trialOutputItem}>
|
|
137
|
+
<div className={styles.trialCandHead}>
|
|
138
|
+
<span className={styles.trialCandName}>{event.title || '未命名 Event'}</span>
|
|
139
|
+
<span className={styles.trialCandMeta}>{event.occurredAt ?? '时间未记录'}</span>
|
|
140
|
+
</div>
|
|
141
|
+
<p className={styles.trialOutputText}>{event.summary || event.symptom || '没有摘要'}</p>
|
|
142
|
+
<div className={styles.trialOutputMeta}>
|
|
143
|
+
{coordinate} · {event.timeline.length} 个步骤 · {sourceCount} 处来源
|
|
144
|
+
{event.noCoordinate && <strong>缺少坐标</strong>}
|
|
145
|
+
</div>
|
|
146
|
+
<InlineDisclosure summary="查看事件过程与结论">
|
|
147
|
+
{event.symptom && <p className={styles.trialOutputText}><b>现象:</b>{event.symptom}</p>}
|
|
148
|
+
{event.timeline.length > 0 && <ol className={styles.trialEventTimeline}>
|
|
149
|
+
{event.timeline.map(step => <li key={step.id}>
|
|
150
|
+
<span>{EVENT_STEP_LABEL[step.type] ?? step.type}</span>
|
|
151
|
+
<div>{step.description}{step.result ? ` · ${step.result}` : ''}</div>
|
|
152
|
+
{step.sources.length > 0 && <ul className={styles.trialSources}>{step.sources.map((source, index) => <SourceLine key={index} source={source} />)}</ul>}
|
|
153
|
+
</li>)}
|
|
154
|
+
</ol>}
|
|
155
|
+
{event.rootCause && <p className={styles.trialOutputText}><b>原因:</b>{event.rootCause}{event.rootCauseStatus === 'suspected' ? '(待确认)' : ''}</p>}
|
|
156
|
+
{event.outcome && <p className={styles.trialOutputText}><b>结果:</b>{event.outcome}</p>}
|
|
157
|
+
{event.missing.length > 0 && <p className={styles.trialOutputMeta}>待补信息:{event.missing.join('、')}</p>}
|
|
158
|
+
{event.sources.length > 0 && <ul className={styles.trialSources}>{event.sources.map((source, index) => <SourceLine key={index} source={source} />)}</ul>}
|
|
159
|
+
</InlineDisclosure>
|
|
160
|
+
</li>
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function WikiCardOutputItem({ card, report }: { card: TrialReportView['wikiCards'][number]; report: TrialReportView }): ReactNode {
|
|
164
|
+
const eventNames = card.events.map(id => report.events?.find(event => event.id === id)?.title ?? id)
|
|
165
|
+
return <li className={styles.trialOutputItem}>
|
|
166
|
+
<div className={styles.trialCandHead}>
|
|
167
|
+
<span className={styles.trialCandName}>{card.name}</span>
|
|
168
|
+
<span className={styles.trialCandMeta}>{card.placements.length} Knowledge · {card.events.length} Event</span>
|
|
169
|
+
</div>
|
|
170
|
+
<div className={styles.trialOutputMeta}>{coordLabel(card.object, card.action, card.scene)}</div>
|
|
171
|
+
{(card.placements.length > 0 || eventNames.length > 0) && <InlineDisclosure summary="查看卡片内容">
|
|
172
|
+
{card.placements.length > 0 && <ul className={styles.trialSources}>
|
|
173
|
+
{card.placements.map(placement => <li key={placement.item} className={styles.trialSource}>
|
|
174
|
+
<span className={styles.trialSourceQuote}>{placement.section} 第 {placement.order} 位</span>
|
|
175
|
+
<span className={styles.trialSourceWhere}>{report.knowledge.find(item => item.id === placement.item)?.text ?? placement.item}</span>
|
|
176
|
+
</li>)}
|
|
177
|
+
</ul>}
|
|
178
|
+
{eventNames.length > 0 && <ul className={styles.trialCardEvents}>{eventNames.map((name, index) => <li key={`${card.events[index]}-${index}`}>{name}</li>)}</ul>}
|
|
179
|
+
</InlineDisclosure>}
|
|
180
|
+
</li>
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** 一条模型请求的输入、输出和用量放在同一个默认折叠区块里。 */
|
|
184
|
+
function ModelRequestDisclosure({
|
|
185
|
+
title,
|
|
186
|
+
status,
|
|
187
|
+
request,
|
|
188
|
+
prompt,
|
|
189
|
+
response,
|
|
190
|
+
responseLabel,
|
|
191
|
+
usage,
|
|
192
|
+
why,
|
|
193
|
+
onCopy,
|
|
194
|
+
copied,
|
|
195
|
+
}: {
|
|
196
|
+
title: string
|
|
197
|
+
status: string
|
|
198
|
+
request?: NonNullable<TrialReportView['model']['request']>
|
|
199
|
+
prompt: { system: string; user: string }
|
|
200
|
+
response?: string
|
|
201
|
+
responseLabel: string
|
|
202
|
+
usage?: TrialTokenUsage
|
|
203
|
+
why?: string
|
|
204
|
+
onCopy?: () => void
|
|
205
|
+
copied?: string
|
|
206
|
+
}): ReactNode {
|
|
207
|
+
const [expanded, setExpanded] = useState(false)
|
|
208
|
+
const usageText = usageSummary(usage)
|
|
209
|
+
const usageDetails = usage ? [
|
|
210
|
+
usage.inputTokens !== undefined ? `普通输入 ${tokenCount(usage.inputTokens)}` : undefined,
|
|
211
|
+
usage.cacheReadTokens !== undefined ? `缓存读 ${tokenCount(usage.cacheReadTokens)}` : undefined,
|
|
212
|
+
usage.cacheWriteTokens !== undefined ? `缓存写 ${tokenCount(usage.cacheWriteTokens)}` : undefined,
|
|
213
|
+
usage.reasoningTokens !== undefined ? `推理 ${tokenCount(usage.reasoningTokens)}` : undefined,
|
|
214
|
+
].filter(Boolean).join(' · ') : ''
|
|
215
|
+
|
|
216
|
+
return <>
|
|
217
|
+
<button type="button" className={cn(styles.trialToggle, styles.trialRequestToggle)} aria-expanded={expanded}
|
|
218
|
+
onClick={() => setExpanded(value => !value)}>
|
|
219
|
+
<span className={styles.trialRequestTitle}>
|
|
220
|
+
<ChevronDown size={12} className={cn(styles.trialChevron, expanded && styles.trialChevronOpen)} />
|
|
221
|
+
<strong>{title}</strong><span>{status}</span>
|
|
222
|
+
</span>
|
|
223
|
+
<span className={styles.trialRequestUsage}>{usageText}</span>
|
|
224
|
+
</button>
|
|
225
|
+
{expanded && <div className={styles.trialPrompt}>
|
|
226
|
+
{request && <div className={styles.trialPromptHead}>
|
|
227
|
+
<span>
|
|
228
|
+
{[request.provider, request.model].filter(Boolean).join(' / ') || '未记录模型路由'}
|
|
229
|
+
{request.reasoningEffort ? ` · ${request.reasoningEffort}` : ''}
|
|
230
|
+
{request.sessionId ? ` · ${request.sessionId}` : ''}
|
|
231
|
+
</span>
|
|
232
|
+
</div>}
|
|
233
|
+
{why && <div className={styles.trialCandWhy}>{why}</div>}
|
|
234
|
+
{usage && <div className={styles.trialPromptHead}>
|
|
235
|
+
<span>{usageText}{usageDetails ? `(${usageDetails})` : ''}</span>
|
|
236
|
+
</div>}
|
|
237
|
+
<div className={styles.trialPromptHead}>
|
|
238
|
+
<span>System 输入 · {prompt.system.length} 字</span>
|
|
239
|
+
{onCopy && <button type="button" className={styles.trialCopy} onClick={onCopy}>
|
|
240
|
+
<Copy size={11} />{copied || '复制输入'}
|
|
241
|
+
</button>}
|
|
242
|
+
</div>
|
|
243
|
+
<pre className={styles.trialPromptText} tabIndex={0} role="region" aria-label={`${title} system 输入`}>
|
|
244
|
+
{prompt.system}
|
|
245
|
+
</pre>
|
|
246
|
+
<div className={styles.trialPromptHead}>
|
|
247
|
+
<span>User 输入 · {prompt.user.length} 字</span>
|
|
248
|
+
</div>
|
|
249
|
+
<pre className={styles.trialPromptText} tabIndex={0} role="region" aria-label={`${title} user 输入`}>
|
|
250
|
+
{prompt.user}
|
|
251
|
+
</pre>
|
|
252
|
+
<div className={styles.trialPromptHead}>
|
|
253
|
+
<span>{responseLabel}{response === undefined ? '' : ` · ${response.length} 字`}</span>
|
|
254
|
+
</div>
|
|
255
|
+
<pre className={styles.trialPromptText} tabIndex={0} role="region" aria-label={`${title} 输出`}>
|
|
256
|
+
{response ?? '这次没有保存模型返回内容。'}
|
|
257
|
+
</pre>
|
|
258
|
+
</div>}
|
|
259
|
+
</>
|
|
260
|
+
}
|
|
261
|
+
|
|
56
262
|
/** 一处出处:引文 + 定位 + 核验结果。 */
|
|
57
263
|
function SourceLine({ source }: { source: TrialSource }): ReactNode {
|
|
58
264
|
return <li className={cn(styles.trialSource, !source.found && styles.trialSourceBad)}>
|
|
@@ -206,12 +412,17 @@ function Matrix({ report }: { report: TrialReportView }): ReactNode {
|
|
|
206
412
|
* 例外**。反过来读的话,人得先读完七个步骤才看得到「这次到底抽出了什么」。
|
|
207
413
|
*/
|
|
208
414
|
export function TrialReport({ report }: { report: TrialReportView }): ReactNode {
|
|
209
|
-
const [
|
|
210
|
-
const [showKnowledge, setShowKnowledge] = useState(false)
|
|
211
|
-
const [showCards, setShowCards] = useState(false)
|
|
212
|
-
const [showPrompt, setShowPrompt] = useState(false)
|
|
213
|
-
const [showAudit, setShowAudit] = useState(false)
|
|
415
|
+
const [openStep, setOpenStep] = useState('')
|
|
214
416
|
const [copied, setCopied] = useState('')
|
|
417
|
+
const events = report.events ?? []
|
|
418
|
+
const recordedUsage = [report.model.usage, report.model.axisResolution?.usage]
|
|
419
|
+
.filter((usage): usage is TrialTokenUsage => usage !== undefined)
|
|
420
|
+
const totals = recordedUsage.map(totalTokensOf).filter((value): value is number => value !== undefined)
|
|
421
|
+
const recordedTokens = totals.length > 0 ? totals.reduce((sum, value) => sum + value, 0) : undefined
|
|
422
|
+
const usageLabel = recordedTokens === undefined ? '未返回' : `${recordedTokens.toLocaleString('zh-CN')} tokens`
|
|
423
|
+
const usageNote = recordedUsage.length === 0
|
|
424
|
+
? '模型未返回用量'
|
|
425
|
+
: `${recordedUsage.length} 次调用有用量`
|
|
215
426
|
|
|
216
427
|
const actorChip = (actor: TrialActor): ReactNode => {
|
|
217
428
|
const Icon = ACTOR[actor].icon
|
|
@@ -220,12 +431,6 @@ export function TrialReport({ report }: { report: TrialReportView }): ReactNode
|
|
|
220
431
|
</span>
|
|
221
432
|
}
|
|
222
433
|
|
|
223
|
-
/**
|
|
224
|
-
* 复制提示词。
|
|
225
|
-
*
|
|
226
|
-
* 人要拿它去改文档、贴到别处试。剪贴板会被权限或非安全上下文挡住,所以失败也要出声 ——
|
|
227
|
-
* 按钮点了没反应,比报错更难查。
|
|
228
|
-
*/
|
|
229
434
|
const copyPrompt = async (): Promise<void> => {
|
|
230
435
|
const text = `# system\n${report.prompt.system}\n\n# user\n${report.prompt.user}`
|
|
231
436
|
let label = '已复制'
|
|
@@ -238,212 +443,184 @@ export function TrialReport({ report }: { report: TrialReportView }): ReactNode
|
|
|
238
443
|
window.setTimeout(() => setCopied(''), 2000)
|
|
239
444
|
}
|
|
240
445
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
446
|
+
const defaultTab = report.knowledge.length > 0 ? 'knowledge' : events.length > 0 ? 'events' : 'cards'
|
|
447
|
+
/**
|
|
448
|
+
* 「这一次什么都没抽出来」。
|
|
449
|
+
*
|
|
450
|
+
* 一次模型没跑通的运行会有五行 0、一个三个空页签的内容区、一条空列表 —— 一屏全是
|
|
451
|
+
* 「没有」。而这时真正有信息的只有两样:**为什么失败**,以及**发出去的提示词**。
|
|
452
|
+
* 所以这种记录把概览压成一行、整段跳过内容区,直接把位置让给模型请求与核验。
|
|
453
|
+
*/
|
|
454
|
+
const empty = !report.model.ok && report.knowledge.length === 0 && events.length === 0 && report.wikiCards.length === 0
|
|
455
|
+
/** 流水线的抽取阶段落下的记录:报告里的 ②③④ 段只是试跑顺带算的预览。 */
|
|
456
|
+
const extractOnly = report.scope === 'extract-only'
|
|
246
457
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
{
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
458
|
+
return <div className={styles.trialReport}>
|
|
459
|
+
{/* 只列真的会渲染出来的区块:空运行的「抽取内容」整段被跳过,留着就是一个点了没反应的锚点。 */}
|
|
460
|
+
<SectionNav items={empty ? SECTIONS.filter(section => section.id !== 'trial-output') : SECTIONS} />
|
|
461
|
+
<section id="trial-overview" className={styles.trialOverview} aria-labelledby="trial-overview-title">
|
|
462
|
+
<div className={styles.trialSectionHead}>
|
|
463
|
+
<h2 id="trial-overview-title">结果概览</h2>
|
|
464
|
+
<span>{report.model.ok ? '已完成' : '需检查'}</span>
|
|
465
|
+
</div>
|
|
466
|
+
{/* 空运行不排五行 0:那五行没有一个数字是结论,而失败原因在上面那一条里。 */}
|
|
467
|
+
{empty
|
|
468
|
+
// 一行平话,不是虚线空态框:框会在红色报错上方再压一层「这里什么都没有」,
|
|
469
|
+
// 而真正该被读到的是下面那句失败原因。
|
|
470
|
+
? <p className={styles.trialOverviewEmpty}>这一次没有形成任何 Knowledge、Event 或 WikiCard。</p>
|
|
471
|
+
: <dl className={styles.trialOverviewStats}>
|
|
472
|
+
<div><dt>Knowledge</dt><dd>{report.knowledge.length}</dd></div>
|
|
473
|
+
<div><dt>Event</dt><dd>{events.length}</dd></div>
|
|
474
|
+
<div><dt>坐标</dt><dd>{report.objects.length} / {report.actions.length} / {report.scenes.length}<small>对象 / 动作 / 场景</small></dd></div>
|
|
475
|
+
{!extractOnly && <div><dt>WikiCard</dt><dd>{report.wikiCards.length}</dd></div>}
|
|
476
|
+
<div><dt>已报告 Token</dt><dd>{usageLabel}<small>{usageNote}</small></dd></div>
|
|
477
|
+
</dl>}
|
|
478
|
+
<p className={styles.trialOverviewTitle}>
|
|
479
|
+
<strong>{report.title}</strong><span>{report.lines} 行 · {report.chars.toLocaleString('zh-CN')} 字</span>
|
|
480
|
+
</p>
|
|
481
|
+
{report.subject && report.subject !== report.title && <p className={styles.trialOverviewSubject}>主题:{report.subject}</p>}
|
|
262
482
|
</section>
|
|
263
483
|
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
onClick={() => setShowKnowledge(value => !value)}>
|
|
268
|
-
<ChevronDown size={12} className={cn(styles.trialChevron, showKnowledge && styles.trialChevronOpen)} />
|
|
269
|
-
<Quote size={11} />知识清单({report.knowledge.length})
|
|
270
|
-
</button>
|
|
271
|
-
{showKnowledge && <ul className={styles.trialCandidates}>
|
|
272
|
-
{report.knowledge.slice(0, LIST_CAP).map(item => <li key={item.id}>
|
|
273
|
-
<div className={styles.trialCandHead}>
|
|
274
|
-
<span className={cn(styles.trialCandName, item.noCoordinate && styles.trialCandBad)}>{item.text}</span>
|
|
275
|
-
<span className={styles.trialCandMeta}>{item.id}</span>
|
|
276
|
-
</div>
|
|
277
|
-
<div className={styles.trialCandWhy}>
|
|
278
|
-
坐标:{coordLabel(item.object, item.action, item.scene)}
|
|
279
|
-
{' · '}位置:{item.section} 第 {item.order} 位
|
|
280
|
-
</div>
|
|
281
|
-
{item.sources.length > 0
|
|
282
|
-
? <ul className={styles.trialSources}>{item.sources.map((source, index) => <SourceLine key={index} source={source} />)}</ul>
|
|
283
|
-
: <div className={styles.trialCandWhy}>没有出处 —— 没有原文依据的判断不可信</div>}
|
|
284
|
-
</li>)}
|
|
285
|
-
{report.knowledge.length > LIST_CAP && <p className={styles.trialMore}>
|
|
286
|
-
另有 {report.knowledge.length - LIST_CAP} 条知识。
|
|
287
|
-
</p>}
|
|
288
|
-
</ul>}
|
|
289
|
-
</>}
|
|
290
|
-
|
|
291
|
-
<div className={styles.kbSubHead}><h4>四个阶段,七个动作</h4><span className={styles.trialLegend}>
|
|
292
|
-
{(['系统', '模型', '人'] as TrialActor[]).map(actor => <span key={actor}>{actorChip(actor)}</span>)}
|
|
293
|
-
</span></div>
|
|
294
|
-
|
|
295
|
-
<ol className={styles.trialSteps}>
|
|
296
|
-
{report.steps.map((step, index) => {
|
|
297
|
-
const expanded = open === step.id
|
|
298
|
-
// 前端刷新可能先于服务端重启。旧服务端不带 `items`,这里兜一下,
|
|
299
|
-
// 免得整块面板白屏 —— 那种失败最难查。
|
|
300
|
-
const items = step.items ?? []
|
|
301
|
-
const phaseStart = index === 0 || report.steps[index - 1]!.phase !== step.phase
|
|
302
|
-
return <li key={step.id} className={styles.trialStepWrap}>
|
|
303
|
-
{/* 阶段头只在阶段变化时出现。七个动作是四段里的,不是并列的七件事。*/}
|
|
304
|
-
{phaseStart && <p className={styles.trialPhaseHead}>{step.phase}</p>}
|
|
305
|
-
<div className={cn(styles.trialStep, step.needsHuman && styles.trialStepWarn)}>
|
|
306
|
-
<button
|
|
307
|
-
type="button"
|
|
308
|
-
className={styles.trialStepHead}
|
|
309
|
-
onClick={() => setOpen(expanded ? '' : step.id)}
|
|
310
|
-
aria-expanded={expanded}
|
|
311
|
-
>
|
|
312
|
-
<span className={styles.trialStepOrder}>{step.order}</span>
|
|
313
|
-
<span className={styles.trialStepName}>{step.name}</span>
|
|
314
|
-
{actorChip(step.actor)}
|
|
315
|
-
<ChevronDown size={12} className={cn(styles.trialChevron, expanded && styles.trialChevronOpen)} />
|
|
316
|
-
<span className={styles.trialStepSum}>{step.summary}</span>
|
|
317
|
-
</button>
|
|
318
|
-
{expanded && <div className={styles.trialStepBody}>
|
|
319
|
-
{/* 产出在前,判据在后:review 时先看"判出了什么",再看"按什么判"。*/}
|
|
320
|
-
<section className={styles.trialProduce}>
|
|
321
|
-
<h5 className={styles.trialProduceHead}>
|
|
322
|
-
产出{items.length > 0 ? ` · ${items.length} 条` : ''}
|
|
323
|
-
</h5>
|
|
324
|
-
{items.length === 0
|
|
325
|
-
? <p className={styles.trialItemsNone}>
|
|
326
|
-
{report.model.ok ? '这一步没有产出。' : '模型没参与,这一步没有判定。'}
|
|
327
|
-
</p>
|
|
328
|
-
: <>
|
|
329
|
-
<ul className={styles.trialItems}>
|
|
330
|
-
{items.slice(0, ITEM_CAP).map((entry, itemIndex) => <li
|
|
331
|
-
key={`${step.id}-${itemIndex}`}
|
|
332
|
-
className={cn(styles.trialItem, entry.flag === 'warn' && styles.trialItemWarn)}
|
|
333
|
-
>
|
|
334
|
-
<span className={styles.trialItemRef}>{entry.ref}</span>
|
|
335
|
-
<span className={styles.trialItemArrow} aria-hidden="true">→</span>
|
|
336
|
-
<span className={styles.trialItemValue}>{entry.value}</span>
|
|
337
|
-
{entry.note && <span className={styles.trialItemNote}>({entry.note})</span>}
|
|
338
|
-
</li>)}
|
|
339
|
-
</ul>
|
|
340
|
-
{items.length > ITEM_CAP && <p className={styles.trialItemsMore}>
|
|
341
|
-
另有 {items.length - ITEM_CAP} 条,是这一步的同类判定。
|
|
342
|
-
</p>}
|
|
343
|
-
</>}
|
|
344
|
-
</section>
|
|
345
|
-
{step.rows.length > 0 && <dl className={styles.trialRows}>
|
|
346
|
-
{step.rows.map(row => <div className={styles.trialRow} key={`${step.id}-${row.label}`}>
|
|
347
|
-
<dt>{row.label}</dt><dd>{row.value}</dd>
|
|
348
|
-
</div>)}
|
|
349
|
-
</dl>}
|
|
350
|
-
</div>}
|
|
351
|
-
</div>
|
|
352
|
-
</li>
|
|
353
|
-
})}
|
|
354
|
-
</ol>
|
|
355
|
-
|
|
356
|
-
{report.exceptions.length > 0 && <div className={styles.trialExceptions}>
|
|
357
|
-
<h4><TriangleAlert size={12} />{report.exceptions.length} 处要人看</h4>
|
|
358
|
-
<ul>
|
|
359
|
-
{report.exceptions.slice(0, 6).map((item, index) => <li key={`${item.step}-${index}`}>
|
|
360
|
-
<span className={styles.trialExcStep}>{item.step}</span>
|
|
361
|
-
<span>{item.message}</span>
|
|
362
|
-
</li>)}
|
|
363
|
-
</ul>
|
|
364
|
-
{report.exceptions.length > 6 && <p className={styles.trialMore}>
|
|
365
|
-
另有 {report.exceptions.length - 6} 处同类,规则调好之后会一起消失。
|
|
366
|
-
</p>}
|
|
367
|
-
</div>}
|
|
368
|
-
|
|
369
|
-
<button type="button" className={styles.trialToggle} onClick={() => setShowCards(value => !value)} aria-expanded={showCards}>
|
|
370
|
-
<ChevronDown size={12} className={cn(styles.trialChevron, showCards && styles.trialChevronOpen)} />
|
|
371
|
-
<Layers3 size={11} />WikiCard 明细({report.wikiCards.length})—— 每张卡引用了哪些知识
|
|
372
|
-
</button>
|
|
484
|
+
{!report.model.ok && <p className={styles.trialError} role="alert">
|
|
485
|
+
<TriangleAlert size={12} />{report.model.why ?? '模型没有参与'} · 本次没有形成有效 Knowledge 或 Event。
|
|
486
|
+
</p>}
|
|
373
487
|
|
|
374
|
-
{
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
</
|
|
383
|
-
<
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
<
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
<
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
</
|
|
404
|
-
|
|
405
|
-
{/* 提示词摊在这里。显示的必须是**真发出去的那条** —— 文档写一套、代码跑另一套
|
|
406
|
-
而没人发现,是最贵的错。模型没参与时也照给:那正是"本来会发出去什么"。*/}
|
|
407
|
-
<button type="button" className={styles.trialToggle} aria-expanded={showPrompt}
|
|
408
|
-
onClick={() => setShowPrompt(value => !value)}>
|
|
409
|
-
<ChevronDown size={12} className={cn(styles.trialChevron, showPrompt && styles.trialChevronOpen)} />
|
|
410
|
-
给模型的提示词(一次调用,system + user 全文)
|
|
411
|
-
</button>
|
|
488
|
+
{!empty && <section id="trial-output" className={styles.trialSection} aria-labelledby="trial-output-title">
|
|
489
|
+
<div className={styles.trialSectionHead}>
|
|
490
|
+
<h2 id="trial-output-title">抽取内容</h2>
|
|
491
|
+
<span>按类型查看抽取结果</span>
|
|
492
|
+
</div>
|
|
493
|
+
<Tabs defaultValue={defaultTab} className={styles.trialOutputTabs}>
|
|
494
|
+
<TabsList variant="segmented" aria-label="抽取结果类型">
|
|
495
|
+
<TabsTrigger value="knowledge">Knowledge · {report.knowledge.length}</TabsTrigger>
|
|
496
|
+
<TabsTrigger value="events">Event · {events.length}</TabsTrigger>
|
|
497
|
+
<TabsTrigger value="cards">WikiCard · {report.wikiCards.length}</TabsTrigger>
|
|
498
|
+
</TabsList>
|
|
499
|
+
<TabsContent value="knowledge">
|
|
500
|
+
{(report.matrix.objects.length > 0 || report.matrix.actions.length > 0) && <Matrix report={report} />}
|
|
501
|
+
{report.knowledge.length > 0
|
|
502
|
+
? <ul className={styles.trialOutputList}>{report.knowledge.slice(0, LIST_CAP).map(item => <KnowledgeOutputItem key={item.id} item={item} />)}</ul>
|
|
503
|
+
: <p className={styles.trialEmpty}>这次没有抽取到 Knowledge。</p>}
|
|
504
|
+
{report.knowledge.length > LIST_CAP && <p className={styles.trialMore}>另有 {report.knowledge.length - LIST_CAP} 条 Knowledge 未展开。</p>}
|
|
505
|
+
</TabsContent>
|
|
506
|
+
<TabsContent value="events">
|
|
507
|
+
{events.length > 0
|
|
508
|
+
? <ul className={styles.trialOutputList}>{events.slice(0, LIST_CAP).map(event => <EventOutputItem key={event.id} event={event} />)}</ul>
|
|
509
|
+
: <p className={styles.trialEmpty}>这次没有抽取到 Event。</p>}
|
|
510
|
+
{events.length > LIST_CAP && <p className={styles.trialMore}>另有 {events.length - LIST_CAP} 个 Event 未展开。</p>}
|
|
511
|
+
</TabsContent>
|
|
512
|
+
<TabsContent value="cards">
|
|
513
|
+
{report.wikiCards.length > 0
|
|
514
|
+
? <ul className={styles.trialOutputList}>{report.wikiCards.map((card, index) => <WikiCardOutputItem key={`${card.name}-${index}`} card={card} report={report} />)}</ul>
|
|
515
|
+
: <p className={styles.trialEmpty}>没有可物化的 WikiCard。</p>}
|
|
516
|
+
</TabsContent>
|
|
517
|
+
</Tabs>
|
|
518
|
+
</section>}
|
|
412
519
|
|
|
413
|
-
|
|
414
|
-
<div className={styles.
|
|
415
|
-
<
|
|
416
|
-
<
|
|
417
|
-
<Copy size={11} />{copied || '复制两段'}
|
|
418
|
-
</button>
|
|
520
|
+
<section id="trial-steps" className={styles.trialSection} aria-labelledby="trial-steps-title">
|
|
521
|
+
<div className={styles.trialSectionHead}>
|
|
522
|
+
<h2 id="trial-steps-title">处理步骤</h2>
|
|
523
|
+
<span>{extractOnly ? '1 个阶段 · 抽取' : `4 个阶段 · ${report.steps.length} 步`}</span>
|
|
419
524
|
</div>
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
525
|
+
{/* 只在流水线的抽取记录上说明:旧的全链路编译里这四段是真跑过的,说了反而错。 */}
|
|
526
|
+
{extractOnly && <p className={styles.trialNote}>
|
|
527
|
+
这里只列<b>抽取</b>这一步。② 归一、③ 物化、④ 建索引在这个库里是独立阶段,
|
|
528
|
+
各有自己的轨迹与任务;下面是抽取时按机械规则顺带算的预览,不代表库里的现状。
|
|
529
|
+
</p>}
|
|
530
|
+
<ol className={styles.trialSteps}>
|
|
531
|
+
{(extractOnly ? report.steps.filter(step => step.id === 'extract') : report.steps).map((step, index, list) => {
|
|
532
|
+
const expanded = openStep === step.id
|
|
533
|
+
const items = step.items ?? []
|
|
534
|
+
const phaseStart = index === 0 || list[index - 1]!.phase !== step.phase
|
|
535
|
+
return <li key={step.id} className={styles.trialStepWrap}>
|
|
536
|
+
{phaseStart && <p className={styles.trialPhaseHead}>{step.phase}</p>}
|
|
537
|
+
<div className={cn(styles.trialStep, step.needsHuman && styles.trialStepWarn)}>
|
|
538
|
+
<button type="button" className={styles.trialStepHead}
|
|
539
|
+
onClick={() => setOpenStep(expanded ? '' : step.id)} aria-expanded={expanded}>
|
|
540
|
+
<span className={styles.trialStepOrder}>{step.order}</span>
|
|
541
|
+
<span className={styles.trialStepName}>{step.name}</span>
|
|
542
|
+
{actorChip(step.actor)}
|
|
543
|
+
<ChevronDown size={12} className={cn(styles.trialChevron, expanded && styles.trialChevronOpen)} />
|
|
544
|
+
<span className={styles.trialStepSum}>{step.summary}</span>
|
|
545
|
+
</button>
|
|
546
|
+
{expanded && <div className={styles.trialStepBody}>
|
|
547
|
+
<section className={styles.trialProduce}>
|
|
548
|
+
<h3 className={styles.trialProduceHead}>产出{items.length > 0 ? ` · ${items.length} 条` : ''}</h3>
|
|
549
|
+
{items.length === 0
|
|
550
|
+
? <p className={styles.trialItemsNone}>{report.model.ok ? '这一步没有产出。' : '模型没有形成有效结果。'}</p>
|
|
551
|
+
: <ul className={styles.trialItems}>{items.slice(0, ITEM_CAP).map((entry, itemIndex) => <li
|
|
552
|
+
key={`${step.id}-${itemIndex}`} className={cn(styles.trialItem, entry.flag === 'warn' && styles.trialItemWarn)}>
|
|
553
|
+
<span className={styles.trialItemRef}>{entry.ref}</span>
|
|
554
|
+
<span className={styles.trialItemArrow} aria-hidden="true">→</span>
|
|
555
|
+
<span className={styles.trialItemValue}>{entry.value}</span>
|
|
556
|
+
{entry.note && <span className={styles.trialItemNote}>{entry.note}</span>}
|
|
557
|
+
</li>)}</ul>}
|
|
558
|
+
{items.length > ITEM_CAP && <p className={styles.trialItemsMore}>另有 {items.length - ITEM_CAP} 条同类产出。</p>}
|
|
559
|
+
</section>
|
|
560
|
+
{step.rows.length > 0 && <dl className={styles.trialRows}>
|
|
561
|
+
{step.rows.map(row => <div className={styles.trialRow} key={`${step.id}-${row.label}`}>
|
|
562
|
+
<dt>{row.label}</dt><dd>{row.value}</dd>
|
|
563
|
+
</div>)}
|
|
564
|
+
</dl>}
|
|
565
|
+
</div>}
|
|
566
|
+
</div>
|
|
567
|
+
</li>
|
|
568
|
+
})}
|
|
569
|
+
</ol>
|
|
570
|
+
</section>
|
|
571
|
+
|
|
572
|
+
<section id="trial-requests" className={styles.trialSection} aria-labelledby="trial-requests-title">
|
|
573
|
+
<div className={styles.trialSectionHead}>
|
|
574
|
+
<h2 id="trial-requests-title">模型请求</h2>
|
|
575
|
+
<span>逐次查看输入、输出和 Token 用量</span>
|
|
425
576
|
</div>
|
|
426
|
-
<
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
577
|
+
<ModelRequestDisclosure
|
|
578
|
+
title="Knowledge & Event 抽取"
|
|
579
|
+
status={report.model.response === undefined ? '未收到完整响应' : report.model.ok ? '有有效结果' : '无有效结果'}
|
|
580
|
+
request={report.model.request}
|
|
581
|
+
prompt={report.prompt}
|
|
582
|
+
response={report.model.response ?? report.model.raw}
|
|
583
|
+
responseLabel={report.model.response !== undefined ? '输出' : report.model.raw ? '失败摘录' : '输出'}
|
|
584
|
+
usage={report.model.usage}
|
|
585
|
+
why={report.model.why}
|
|
586
|
+
onCopy={() => void copyPrompt()}
|
|
587
|
+
copied={copied}
|
|
588
|
+
/>
|
|
589
|
+
{report.model.axisResolution && <ModelRequestDisclosure
|
|
590
|
+
title="坐标候选补判"
|
|
591
|
+
status={report.model.axisResolution.ok ? '完成' : '未完成'}
|
|
592
|
+
request={report.model.axisResolution.request}
|
|
593
|
+
prompt={report.model.axisResolution.prompt}
|
|
594
|
+
response={report.model.axisResolution.response}
|
|
595
|
+
responseLabel="输出"
|
|
596
|
+
usage={report.model.axisResolution.usage}
|
|
597
|
+
why={report.model.axisResolution.why}
|
|
598
|
+
/>}
|
|
599
|
+
</section>
|
|
430
600
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
<
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
<div className={styles.trialCandHead}>
|
|
442
|
-
<span className={styles.trialCandName}>{item.quote}</span>
|
|
443
|
-
</div>
|
|
444
|
-
<div className={styles.trialCandWhy}>{item.why}</div>
|
|
601
|
+
<section id="trial-review" className={styles.trialSection} aria-labelledby="trial-review-title">
|
|
602
|
+
<div className={styles.trialSectionHead}>
|
|
603
|
+
<h2 id="trial-review-title">核验结果</h2>
|
|
604
|
+
<span>{report.exceptions.length > 0 ? `${report.exceptions.length} 项需检查` : '本地核验已完成'}</span>
|
|
605
|
+
</div>
|
|
606
|
+
<ul className={styles.trialCheckList}>
|
|
607
|
+
{report.checks.map(check => <li key={check.name}>
|
|
608
|
+
<div><strong>{check.name}</strong><span>{check.what}</span></div>
|
|
609
|
+
<b data-hit={check.hits > 0}>{check.hits > 0 ? `${check.hits} 项` : '通过'}</b>
|
|
610
|
+
{check.hits > 0 && <small>{check.note}</small>}
|
|
445
611
|
</li>)}
|
|
446
|
-
</ul>
|
|
447
|
-
|
|
448
|
-
|
|
612
|
+
</ul>
|
|
613
|
+
{report.exceptions.length > 0 && <div className={styles.trialReviewIssues}>
|
|
614
|
+
<h3><TriangleAlert size={12} />需人工检查</h3>
|
|
615
|
+
<ul>{report.exceptions.map((item, index) => <li key={`${item.step}-${index}`}>
|
|
616
|
+
<span>{item.step}</span><p>{item.message}</p>
|
|
617
|
+
</li>)}</ul>
|
|
618
|
+
</div>}
|
|
619
|
+
{report.audit.dropped.length > 0 && <InlineDisclosure summary={`被丢弃的片段 · ${report.audit.dropped.length}`}>
|
|
620
|
+
<ul className={styles.trialCandidates}>{report.audit.dropped.map((item, index) => <li key={index}>
|
|
621
|
+
<strong>{item.quote}</strong><span>{item.why}</span>
|
|
622
|
+
</li>)}</ul>
|
|
623
|
+
</InlineDisclosure>}
|
|
624
|
+
</section>
|
|
625
|
+
</div>
|
|
449
626
|
}
|