mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-23 13:01:58 +00:00
合入 nr6/b:评测「期望没有数据」只认数值格和叙述里的数、逐题 E1 比产出答案的那条查询、判错时给配对上的那一格、估不出金额时不写 0、没做完的模型调用也计一次、助手只给思考不给操作时自动重来一次(问数据与评测同一个决定)、目录两种计数照实说、自由形应用入口与岗位显示名;评分规则升到第 2 版
This commit is contained in:
@@ -783,6 +783,12 @@ export const TURN_COST_TEXT = {
|
||||
`其中 ${formatNumber(n)} 次调用的金额无法估算(模型不在价格目录中,或用量没有报全),未计入,实际花费不低于此数`,
|
||||
} as const
|
||||
|
||||
/** 问数据一轮自动重来一次时的进度说明(服务端 chat/turn.next_step 判的 retry) */
|
||||
export const CHAT_RETRY_TEXT = {
|
||||
/** 助手上一次只写了思考、一个操作都没给(error.next = retry) */
|
||||
empty: '助手上一次没有给出任何操作,正在重新生成工作流…',
|
||||
} as const
|
||||
|
||||
export const JUDGE_SETTING_TEXT = {
|
||||
label: '证据裁判',
|
||||
hint: '报告中的结论句(如「增长主要来自新客首单」)由另一个模型按证据逐句判断:正式运行由报告撰写节点当场裁判,探索运行在点击时逐句裁判。判断由模型给出,不是系统核对,界面上一律标注「非确定」。',
|
||||
@@ -2314,7 +2320,7 @@ export const CATALOG_TEXT = {
|
||||
missing: '表结构中已没有这张表',
|
||||
noCatalog: '没有目录',
|
||||
usage: (n: number) => `使用 ${formatNumber(n)} 次`,
|
||||
usageHint: '被运行查询过的次数,同一次运行中结果相同的重复查询只算一次',
|
||||
usageHint: '按查询算:被运行查询过的次数,同一次运行里查了几次算几次(结果相同的重复查询只算一次);「用过这张表的运行」按运行算,两个数可能不一样',
|
||||
relationCount: (n: number) => `${formatNumber(n)} 个关联`,
|
||||
countTitle: (label: string, n: number) => `${label} ${formatNumber(n)} 项`,
|
||||
noMatch: '没有符合条件的表',
|
||||
@@ -6092,6 +6098,8 @@ export const APP_EDITOR_TEXT = {
|
||||
slotAdd: '新增岗位',
|
||||
slotName: '岗位名',
|
||||
slotLabel: '显示名',
|
||||
/** 显示名和岗位名一样:派生时没有节点名可用(服务端 apps/tree.slot_label),照实用的是岗位名,不是起好的名字 */
|
||||
slotLabelRaw: '还没有起显示名,现在用的是图里的岗位名,可以改成一个好认的名字',
|
||||
slotUnbound: '未绑定:发布检查会拦下流程应用',
|
||||
slotRemove: (name: string) => `删除岗位「${name}」`,
|
||||
grants: '授权',
|
||||
|
||||
@@ -356,6 +356,8 @@ export const EVAL_TEXT = {
|
||||
estimateText: (items: number, cases: number, repeats: number, arms: number) =>
|
||||
`${formatNumber(cases)} 道题 × 每题 ${repeats} 次${arms > 1 ? ` × ${arms} 臂` : ''},共 ${formatNumber(items)} 项`,
|
||||
cost: (total: string, per: string) => `约 ${total}(每项约 ${per})`,
|
||||
/** 上一次有估不出金额的调用:估出来的只是下限 */
|
||||
costAtLeast: (total: string, per: string) => `至少约 ${total}(每项至少约 ${per})`,
|
||||
costNone: '估不出花费',
|
||||
budget: '生效的预算',
|
||||
parallel: (n: number) => `同时评 ${n} 题`,
|
||||
@@ -416,6 +418,8 @@ export const EVAL_TEXT = {
|
||||
cost: '花费',
|
||||
costHint: '助手(建图、挑表、复核)+ 写作(答案运行里的模型调用)+ 结论裁判;算期望不调模型',
|
||||
perCase: (v: string) => `每题约 ${v}`,
|
||||
/** 有估不出金额的调用:每题平均只是下限 */
|
||||
perCaseAtLeast: (v: string) => `每题至少约 ${v}`,
|
||||
e1: '逐题的口径命中(E1)',
|
||||
e1Hint: '答案执行的 SQL 和期望的取数被证明等价的比例(口径账本同一个比对函数)',
|
||||
citations: '报告引用率',
|
||||
@@ -441,7 +445,9 @@ export const EVAL_TEXT = {
|
||||
timing: { build_ms: '建图', run_wall_ms: '运行(墙钟)', run_active_ms: '运行(执行)', review_ms: '复核', total_ms: '整题' } as Record<string, string>,
|
||||
usage: '按角色的用量',
|
||||
tokens: (input: string, output: string) => `输入 ${input} · 输出 ${output}`,
|
||||
callsN: (n: number) => `${formatNumber(n)} 次调用`,
|
||||
/** unfinished:没做完的调用(被取消、超时,token 只计了已报的;服务端 providers/usage 的 unfinished_calls) */
|
||||
callsN: (n: number, unfinished = 0) =>
|
||||
`${formatNumber(n)} 次调用${unfinished > 0 ? `(其中 ${formatNumber(unfinished)} 次未完成:被取消或超时,token 只计了已报的部分)` : ''}`,
|
||||
role: { assistant: '助手', writer: '写作', judge: '结论裁判', gold: '算期望' } as Record<string, string>,
|
||||
passRates: '重复评的题的通过率',
|
||||
outcomes: '各期望的结论',
|
||||
@@ -464,6 +470,10 @@ export const EVAL_TEXT = {
|
||||
sqlMatch: {
|
||||
proven: '等价已证明', related: '不等价', none: '答案没有查询', skipped: '没比对',
|
||||
} as Record<string, string>,
|
||||
/** 逐题 SQL 比对比的是哪条查询(服务端 score.sql_match 的 basis)。答案引用了查询的不用多说 */
|
||||
sqlMatchBasis: {
|
||||
only_query: '答案没有引用查询;这次运行只执行了这一条查询(核查用的不算),按它比',
|
||||
} as Record<string, string>,
|
||||
aspect: {
|
||||
time: '时间口径', time_range: '时间范围', filter: '筛选条件', aggregate: '聚合', expression: '计算式', join: '关联',
|
||||
tables: '用到的表', group_by: '分组', limit: '行数限制', other: '其他', parse: '解析不了',
|
||||
@@ -495,6 +505,8 @@ export const EVAL_TEXT = {
|
||||
filter: '只看',
|
||||
repeat: (n: number) => `第 ${n + 1} 次`,
|
||||
attempts: (n: number) => `这一题自动重来了 ${n} 次`,
|
||||
/** 每次自动重来的原因(服务端 eval/answer 的 turn.retries) */
|
||||
retriesWhy: (reasons: string[]) => `:${reasons.join(';')}`,
|
||||
turnReason: '作答的经过',
|
||||
answer: '答案原文',
|
||||
expand: '展开',
|
||||
|
||||
@@ -60,6 +60,7 @@ export function AccessSection() {
|
||||
setBindings((b) => { const next = { ...b.slots }; delete next[name]; return { ...b, slots: next } })
|
||||
}} />
|
||||
</div>
|
||||
{slot.label.trim() === name && <p className="text-2xs text-faint" data-app-slot-raw="">{T.slotLabelRaw}</p>}
|
||||
<PrincipalPicker label={T.slots} value={bound as Picked[]}
|
||||
onChange={(v) => setBindings((b) => ({
|
||||
...b, slots: { ...b.slots, [name]: v.filter((x) => x.kind !== 'everyone') as { kind: 'user' | 'group'; name: string }[] },
|
||||
|
||||
@@ -215,8 +215,7 @@ function Overview({ run }: { run: EvalRun }) {
|
||||
<div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<RateCard title={O.accuracy} hint={O.accuracyHint} rate={s.accuracy} attr="accuracy" />
|
||||
<RateCard title={O.traced} hint={O.tracedHint} rate={s.traced_accuracy} attr="traced" />
|
||||
<StatCard title={O.cost} hint={O.costHint} value={cost} attr="cost"
|
||||
sub={s.per_case_cost_usd != null ? O.perCase(formatCost(s.per_case_cost_usd)) : undefined} />
|
||||
<StatCard title={O.cost} hint={O.costHint} value={cost} attr="cost" sub={perCaseText(s)} />
|
||||
<StatCard title={O.e1} hint={O.e1Hint} value={s.e1?.n ? pct(s.e1.rate) : '—'} sub={rateText(s.e1)} attr="e1" />
|
||||
</div>
|
||||
<Section title={O.verdicts} attr="verdicts">
|
||||
@@ -278,7 +277,7 @@ function Overview({ run }: { run: EvalRun }) {
|
||||
<li key={role} data-eval-usage-role={role}>
|
||||
{O.role[role]}:{usageCost(u)}
|
||||
{u.input_tokens != null && <span className="text-faint"> · {O.tokens(formatTokens(u.input_tokens, { compact: true }), formatTokens(u.output_tokens ?? 0, { compact: true }))}</span>}
|
||||
{u.calls != null && <span className="text-faint"> · {O.callsN(u.calls)}</span>}
|
||||
{u.calls != null && <span className="text-faint"> · {O.callsN(u.calls, u.unfinished_calls ?? 0)}</span>}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
@@ -296,6 +295,17 @@ function Overview({ run }: { run: EvalRun }) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 每题平均花费:有估不出金额的调用时只是下限(写「至少」);一分都没估出来的不写(老总表记成 0 的也一样,金额那一格已经写了
|
||||
* 「金额无法估算」)
|
||||
*/
|
||||
function perCaseText(s: EvalSummary): string | undefined {
|
||||
const per = s.per_case_cost_usd
|
||||
if (per == null) return undefined
|
||||
if (!s.unpriced_calls) return T.overview.perCase(formatCost(per))
|
||||
return per > 0 ? T.overview.perCaseAtLeast(formatCost(per)) : undefined
|
||||
}
|
||||
|
||||
function Section({ title, children, attr }: { title: string; children: ReactNode; attr?: string }) {
|
||||
return (
|
||||
<section className="space-y-1 rounded-lg border bg-panel p-3 text-xs" aria-label={title} data-eval-section={attr}>
|
||||
@@ -417,6 +427,9 @@ function Results({ id, live, focusCase }: { id: string; live: boolean; focusCase
|
||||
{s.reason && <span> · {s.reason}</span>}
|
||||
</p>
|
||||
))}
|
||||
{r.sql_match?.basis && T.sqlMatchBasis[r.sql_match.basis] && (
|
||||
<p className="text-faint" data-eval-sql-basis={r.sql_match.basis}>{T.sqlMatchBasis[r.sql_match.basis]}</p>
|
||||
)}
|
||||
{r.sql_match?.reason && <p className="text-faint">{r.sql_match.reason}</p>}
|
||||
<ResultDetail evaluationId={id} resultId={r.id} />
|
||||
<div className="flex flex-wrap gap-2">
|
||||
@@ -450,7 +463,11 @@ function ResultDetail({ evaluationId, resultId }: { evaluationId: string; result
|
||||
const R = T.results
|
||||
return (
|
||||
<div className="space-y-1" data-eval-result-details="">
|
||||
{(turn.attempts ?? 0) > 0 && <p className="text-faint">{R.attempts(turn.attempts)}</p>}
|
||||
{(turn.attempts ?? 0) > 0 && (
|
||||
<p className="text-faint" data-eval-retries={turn.retries?.length ?? 0}>
|
||||
{R.attempts(turn.attempts)}{turn.retries?.length ? R.retriesWhy(turn.retries) : ''}
|
||||
</p>
|
||||
)}
|
||||
{turn.reason && <p className="text-dim"><span className="text-faint">{R.turnReason}:</span>{turn.reason}</p>}
|
||||
{answer && (
|
||||
<details>
|
||||
|
||||
@@ -263,9 +263,8 @@ export function StartDialog({ open, onClose, suite, evaluations, onStarted }: {
|
||||
<>
|
||||
<p data-eval-estimate-items={est.estimate.items}>{T.estimateText(est.estimate.items, est.cases, est.repeats, est.arms.length)}</p>
|
||||
<p data-eval-estimate-cost="">
|
||||
{est.estimate.total_usd != null
|
||||
? T.cost(formatCost(est.estimate.total_usd), formatCost(est.estimate.per_item_usd))
|
||||
: T.costNone}
|
||||
{est.estimate.total_usd == null ? T.costNone
|
||||
: (est.estimate.at_least ? T.costAtLeast : T.cost)(formatCost(est.estimate.total_usd), formatCost(est.estimate.per_item_usd))}
|
||||
<span className="text-faint"> · {est.estimate.note}</span>
|
||||
</p>
|
||||
{est.arms.map((a, i) => (
|
||||
|
||||
@@ -2,7 +2,7 @@ import { create } from 'zustand'
|
||||
import { ApiError, api, streamCopilot, streamRun } from '../api/client'
|
||||
import type { CopilotOp, FixKind, RunFinal } from '../run/decode'
|
||||
import { copilotContext, copilotLook, decodeRun, looksOf } from '../run/decode'
|
||||
import { CHAT_BLUEPRINT_TEXT, LEDGER_TEXT, LOOK_TEXT, REJECTED_TEXT } from '../lib/terms'
|
||||
import { CHAT_BLUEPRINT_TEXT, CHAT_RETRY_TEXT, LEDGER_TEXT, LOOK_TEXT, REJECTED_TEXT } from '../lib/terms'
|
||||
import type { LookEvent } from '../typesApp'
|
||||
import { errorMessage, humanizeError, isNetworkError } from '../lib/errors'
|
||||
import { guardReview, hasEvidence } from '../lib/evidence'
|
||||
@@ -174,6 +174,8 @@ export interface UsageTotal {
|
||||
cost_usd?: number | null
|
||||
unpriced_calls?: number
|
||||
calls?: number
|
||||
/** 没做完的调用(被取消、超时):算在 calls 里,token 只计了已报的(服务端 providers/usage 的 unfinished_calls) */
|
||||
unfinished_calls?: number
|
||||
input_tokens?: number
|
||||
output_tokens?: number
|
||||
}
|
||||
@@ -498,7 +500,7 @@ function buildMeta(t: ChatTurn): TurnMeta {
|
||||
}
|
||||
}
|
||||
|
||||
const USAGE_KEYS = ['cost_usd', 'unpriced_calls', 'calls', 'input_tokens', 'output_tokens'] as const
|
||||
const USAGE_KEYS = ['cost_usd', 'unpriced_calls', 'calls', 'unfinished_calls', 'input_tokens', 'output_tokens'] as const
|
||||
|
||||
/** 两份用量相加(缺的当 0)。b 不是对象时原样交回 a */
|
||||
export function addUsage(a: UsageTotal | undefined, b: UsageTotal | null | undefined): UsageTotal | undefined {
|
||||
@@ -1417,14 +1419,14 @@ function plan(flow: Flow, args: PlanArgs) {
|
||||
* 这里会清空这一次的过程和答案——它是自动补救,用户还没拿到过答案。用户主动
|
||||
* 点的重试走 retryTurn,上一次要留档。
|
||||
*/
|
||||
const retry = (reason: string, instruction?: string) => {
|
||||
const retry = (reason: string, instruction?: string, status?: string) => {
|
||||
// 服务端给了那句话(复核的 retry_instruction)就是它已经按次数判过可以重来;老服务端由这里按次数判
|
||||
if ((!instruction && attempt + 1 >= MAX_ATTEMPTS) || !flow.alive()) return false
|
||||
const base = built && (built.nodes?.length ?? 0) > 0 ? built : null
|
||||
patch((t) => ({
|
||||
attempt: attempt + 1,
|
||||
phase: 'planning',
|
||||
status: base ? '上次运行未成功,正在调整工作流…' : '上次运行未成功,正在重新生成工作流…',
|
||||
status: status ?? (base ? '上次运行未成功,正在调整工作流…' : '上次运行未成功,正在重新生成工作流…'),
|
||||
ops: [], events: [], run: null, output: null, final: undefined, runStatus: undefined,
|
||||
review: null, reviewRaw: null, rawOutput: null, lastSeq: 0, failure: null, error: '',
|
||||
// 换下来的那次运行花的钱还是这一轮的
|
||||
@@ -1584,9 +1586,12 @@ function plan(flow: Flow, args: PlanArgs) {
|
||||
void flow.persist()
|
||||
break
|
||||
case 'error':
|
||||
settled = true
|
||||
// 生成过程一个操作都没给(模型只写了思考):服务端说重来一次(error.next = retry,backend/app/chat/turn.py 的
|
||||
// next_step),照它带着原因重来,次数照 MAX_ATTEMPTS;试满了才照实报。这一次建图的用量随后那条 usage 照样记进这一轮
|
||||
if (op.next === 'retry' && retry(String(op.reason ?? op.message ?? ''), undefined, CHAT_RETRY_TEXT.empty)) break
|
||||
// 后端给的是三段:message 人话、hint 怎么办、detail 原始异常。
|
||||
// 原文不再截成一行甩给用户,收进可展开、可复制的技术细节
|
||||
settled = true
|
||||
fail({
|
||||
...failureOf(op.message ?? '生成失败'),
|
||||
...(op.hint ? { hint: String(op.hint) } : {}),
|
||||
|
||||
@@ -365,7 +365,11 @@ export interface EvalEstimate {
|
||||
arms: { label: string | null; variant: EvalVariant; models: EvalResolvedModels; text: string }[]
|
||||
cases: number
|
||||
repeats: number
|
||||
estimate: { items: number; per_item_usd: number | null; total_usd: number | null; basis: string | null; note: string }
|
||||
/** at_least:上一次另有 unpriced_calls 次调用金额估不出,估算只是下限;total_usd 为空、unpriced_calls 有值:一分都没估出来 */
|
||||
estimate: {
|
||||
items: number; per_item_usd: number | null; total_usd: number | null; basis: string | null; note: string
|
||||
at_least?: boolean; unpriced_calls?: number
|
||||
}
|
||||
budget: EvalBudget
|
||||
parallel: number
|
||||
spend: EvalSpend
|
||||
@@ -415,7 +419,10 @@ export interface EvalUsage {
|
||||
calls?: number
|
||||
cost_usd?: number | null
|
||||
unpriced_calls?: number
|
||||
by_model?: Record<string, { input_tokens: number; output_tokens: number; calls: number; cost_usd: number; unpriced_calls: number }>
|
||||
/** 没做完的调用(被取消、超时):算在 calls 里,token 只计了已报的 */
|
||||
unfinished_calls?: number
|
||||
by_model?: Record<string, { input_tokens: number; output_tokens: number; calls: number; cost_usd: number; unpriced_calls: number
|
||||
unfinished_calls?: number }>
|
||||
}
|
||||
|
||||
export interface EvalTiming {
|
||||
@@ -531,6 +538,8 @@ export interface EvalSqlMatch {
|
||||
aspects?: string[]
|
||||
reason?: string | null
|
||||
cited?: boolean
|
||||
/** 比的是哪条查询:cited 答案引用的;only_query 答案没引用、这次运行只查了这一条 */
|
||||
basis?: 'cited' | 'only_query' | string
|
||||
}
|
||||
|
||||
export interface EvalResult {
|
||||
|
||||
Reference in New Issue
Block a user