mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-21 20:22:01 +00:00
可点击证据第一期:报告里的每个数字都点得开出处
「引用即渲染」:写报告的模型只写引用标记([[m:指标id]]、[[i:输入字段]]、[[see:…]]),数值由系统按口径卡
填进去,每个数字都挂着一条能复算的证据链。本期是数字层闭环;实体、结论句的概率性证据放在后续几期。
内核(engine/evidence.py,口径卡、出具契约、表达式等)
- 口径卡记录每个指标的来源:原式、代入式(每个输入写成「值 ← 路径」)、复算结果、口径与版本
- 出具契约的数值匹配改为按位置标注;同一个值有几个出处时记为「出处不唯一」并列出候选,不再随便挑一个
- 证据 id 由内容派生,事后对不上就是被改过;零值、结构性数字(列表序号、代码块标签)单独处理
- 口径卡新增 on_missing:缺输入时默认仍是整个节点失败,可以改成记为空值、交给契约判档
报告撰写节点(report)与引用模式的出具契约
- 流式生成时 token 里就是真实数字,不会漏出原始标记;裸数字、不存在的引用当场判违规,交回去重写
(max_repairs,默认 1 次);仍不过时按 on_violation 失败(正式运行默认)或把违规标在报告里(探索运行默认)
- report.checked 事件记下核对结果,落在封存范围内;fail 模式下仍不过时带 failed,运行记录里画成失败
- 出具契约写了 report_from 就按引用核对:取回文档时复验哈希,独立重算一遍,全部带引用才判完整出具
- 成果字段逐字等于报告正文时标注 _evidence;复核只能加说明,不能改写带证据的答案(前后端各拦一道)
证据接口
- GET /api/runs/{id}/evidence 返回证据图;GET …/evidence/segments/{id} 返回一个片段的证据链
- 只认封存范围内的事件能追到的工件,不读 artifacts 表;封存被改过时不把任何一项标成已封存
- 没有报告的旧运行降级为 none 或 legacy_contract
界面
- EvidenceDoc 按块、句、片段渲染报告,片段是和正文一样的按钮;整份报告只占一个 Tab 位,
←/→ 在片段间移动、↑/↓ 按句、n/N 跳到下一处「无证据」、Enter 打开面板、Esc 关闭并把焦点还回去
- EvidencePanel:宽屏侧边、窄屏底部抽屉、360px 画布右栏里栏内展开;显示指标步骤、代入式、复算结果、
封存状态。正文不是封存的那份报告时明确说出来,不拿别的报告的封存画绿
- 出具横幅多一行「N/N 数字有出处 · 无证据 M」和「定位下一处」;没有 _evidence 的旧回答渲染一字不差
- 画布认得报告撰写节点;Copilot 手册补上口径卡、报告节点、出具契约的写法;新增模板「⑨ 可追溯周报」
验证(沙箱):tsc 干净,生产构建通过,pytest 1601 passed,check-all 16 项检查全绿(新增 check-evidence)。
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
Bot, Braces, Brain, CheckCircle2, Code2, Database, FileInput, FileOutput,
|
||||
Bot, Braces, Brain, CheckCircle2, Code2, Database, FileInput, FileOutput, FileText,
|
||||
Gauge, GitBranch, Hand, Repeat, Search, Shuffle, Users, Wrench,
|
||||
} from 'lucide-react'
|
||||
import { APPROVAL_POLICY_LABEL, NODE_TYPE_LABEL } from '../lib/terms'
|
||||
@@ -8,7 +8,7 @@ import type { NodeType } from '../types'
|
||||
export type FieldType =
|
||||
| 'text' | 'textarea' | 'prompt' | 'code' | 'number' | 'select' | 'switch'
|
||||
| 'json' | 'model' | 'tools' | 'skills' | 'collection'
|
||||
| 'ioFields' | 'cases' | 'agents' | 'metricsList'
|
||||
| 'ioFields' | 'cases' | 'agents' | 'metricsList' | 'nodeRefs'
|
||||
|
||||
/**
|
||||
* 这个字段里写的是什么语法。
|
||||
@@ -36,6 +36,8 @@ export interface FieldDef {
|
||||
step?: number
|
||||
/** 只在满足条件时显示,避免面板一次糊一屏用不上的选项 */
|
||||
when?: (config: Record<string, any>) => boolean
|
||||
/** nodeRefs:只能选这一类的上游节点(报告的 metrics_from 只收口径卡) */
|
||||
refType?: NodeType
|
||||
advanced?: boolean
|
||||
}
|
||||
|
||||
@@ -470,6 +472,47 @@ export const NODE_DEFS: Record<NodeType, NodeDef> = {
|
||||
schema: { type: 'object', properties: {}, required: [] },
|
||||
},
|
||||
},
|
||||
report: {
|
||||
type: 'report', label: NODE_TYPE_LABEL.report, category: '模型', icon: FileText,
|
||||
description: '带引用的报告:模型只写引用标记,数字由系统从口径卡取出来渲染,每个数字都能点开看出处',
|
||||
hasTarget: true, sources: [{ id: 'out', label: '' }],
|
||||
fields: [
|
||||
{
|
||||
key: 'instructions', label: '写作要求', type: 'prompt', placeholder: '为 {{ input.week }} 写周报,先总后分',
|
||||
help: '写什么、怎么写。上游口径卡的指标和运行输入会自动整理成证据目录交给模型,不用在这里手抄',
|
||||
},
|
||||
{
|
||||
key: 'metrics_from', label: '指标来自', type: 'nodeRefs', refType: 'metrics',
|
||||
help: '留空 = 用上游全部口径卡。报告里的数字只能引用这些卡里的指标',
|
||||
},
|
||||
{
|
||||
// 后端只认 strict / off(report.py 的 NUMBERS)
|
||||
key: 'numbers', label: '没写引用的数字', type: 'select',
|
||||
options: [
|
||||
{ value: 'strict', label: '算违规,要求重写(默认)' },
|
||||
{ value: 'off', label: '只标出来,不要求重写' },
|
||||
],
|
||||
help: '报告里每个数字都该写成引用标记,由系统取值渲染。模型自己写的数字核对不到出处',
|
||||
},
|
||||
{
|
||||
// 留空不是「不处理」:后端按运行类别取默认,探索运行照常产出、正式运行判失败
|
||||
key: 'on_violation', label: '重写后仍有违规时', type: 'select',
|
||||
options: [
|
||||
{ value: '', label: '按运行类别:探索运行照常产出,正式运行判失败' },
|
||||
{ value: 'flag', label: '照常产出,把违规的地方标出来' },
|
||||
{ value: 'fail', label: '判为失败,报告不往下交' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'max_repairs', label: '最多重写几次', type: 'number', min: 0, max: 3, placeholder: '1',
|
||||
help: '有违规时把清单交回去让模型重写。每次都是一整篇的调用,写不对的模型多给几次也大多写不对',
|
||||
},
|
||||
...MODEL_FIELDS,
|
||||
{ key: 'system', label: '角色设定', type: 'textarea', advanced: true, placeholder: '你是…' },
|
||||
...COMMON_TAIL,
|
||||
],
|
||||
defaults: { instructions: '', numbers: 'strict', max_repairs: 1 },
|
||||
},
|
||||
metrics: {
|
||||
type: 'metrics', label: NODE_TYPE_LABEL.metrics, category: '把关', icon: Gauge,
|
||||
description: '受控指标集:所有算术在这里发生,叙述层只能引用',
|
||||
@@ -478,6 +521,11 @@ export const NODE_DEFS: Record<NodeType, NodeDef> = {
|
||||
{ key: 'caliber', label: '口径名称', type: 'text', syntax: 'template', placeholder: '周报口径' },
|
||||
{ key: 'caliber_version', label: '口径版本', type: 'text', placeholder: 'v1' },
|
||||
{ key: 'metrics', label: '指标定义', type: 'metricsList' },
|
||||
{
|
||||
key: 'on_missing', label: '缺输入时', type: 'select', advanced: true,
|
||||
options: [{ value: '', label: '整个节点失败' }, { value: 'null', label: '记为空值,交给出具契约判档' }],
|
||||
help: '上游没给出某个指标要的数时怎么办。记为空值的指标在报告里显示「—」,出具契约按必需 / 期望项降档',
|
||||
},
|
||||
{
|
||||
key: 'assign_to', label: '结果存为变量', type: 'text',
|
||||
help: '叙述节点用 {{ nodes.节点id.text }} 引用指标清单',
|
||||
|
||||
Reference in New Issue
Block a user