Datasets:
Download code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/GenerationRows.tsx from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 3.58 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/GenerationRows.tsx
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/GenerationRows.tsx
-
curl -L -o GenerationRows.tsx https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/GenerationRows.tsx
3.58 kB
| import {explanation} from './text.ts'; | |
| import type {GenerationEvent, GenerationRecords, MetricUnits, Target} from './contract.ts'; | |
| import {metric} from './format.ts'; | |
| import type {ReviewClock} from './clock.ts'; | |
| const labels = {waiting: '等待', detour: '绕路', retargeting: '换目标', discard: '丢弃', proposal_failure: '提案失败', token: '令牌'}; | |
| const outcome: Record<string, string> = {time_conflict: '排时未通过', same_route: '仍是同一条路线', route_geometry_failed: '路线几何失败', accepted: '已接受'}; | |
| function target(value: Target | null) { | |
| if (!value) return '未提供'; | |
| return (value.stop_id || value.region_id || '目标') + (value.position_uv ? `(${value.position_uv.map(v => v.toFixed(2)).join(', ')} m)` : ''); | |
| } | |
| export function GenerationRows({records, actorId, clock, units}: {units: MetricUnits; records: GenerationRecords; actorId: string; clock: ReviewClock}) { | |
| const events = records.events.filter(e => e.actor_id === actorId && e.kind !== 'token'); | |
| function render(e: GenerationEvent, index: number) { | |
| return <button className={'generation-record event-' + e.kind} key={index} data-generation-record={e.kind} data-event-time={e.time_s} onClick={() => {clock.setPlaying(false); clock.seek(e.time_s);}}> | |
| <strong>{labels[e.kind]}{e.discard_class ? ` ${e.discard_class} 类` : ''} · 意图 {e.intent_index ?? '—'}</strong> | |
| <span>{e.time_s.toFixed(2)}{e.end_s > e.time_s ? '–' + e.end_s.toFixed(2) : ''} 秒{e.forced === true ? ' · 被迫' : ''}</span> | |
| {e.waiting_for.length > 0 && <span>在等:{e.waiting_for.join('、')}</span>} | |
| {e.kind === 'retargeting' && <span className="target-transition">{target(e.original_target)} → {target(e.new_target)}</span>} | |
| {e.kind === 'proposal_failure' && <span>未接受的站位:{target(e.new_target)} · 绑定意图保持原状态</span>} | |
| {e.detour && <span>{outcome[e.detour.status || ''] || e.detour.status || '未提供结果'}{e.detour.parameterization_result ? ' · 剖面:' + (outcome[e.detour.parameterization_result] || e.detour.parameterization_result) : ''}</span>} | |
| {e.detour && <small>避让成本单元 {e.detour.cost_cells ?? '未提供'} · 路线落在避让区的点 {e.detour.final_points_in_avoidance ?? '未提供'}{e.detour.hausdorff_m.length ? ' · 路线差异 ' + e.detour.hausdorff_m.map(v => v.toFixed(3)).join(' / ') + ' m' : ''}</small>} | |
| {e.blocked_by.length > 0 && <span>阻挡:{e.blocked_by.join('、')}</span>} | |
| {e.failed_step && <small>失败步骤:{explanation(e.failed_step)}</small>} | |
| {e.no_route_mechanism && <small>无路机制:{explanation(e.no_route_mechanism)}</small>} | |
| {e.reason && <small>{explanation(e.reason)}</small>} | |
| </button>; | |
| } | |
| return <details className="generation-events" data-generation-actor={actorId} open><summary>等待、绕路、换目标和丢弃记录</summary> | |
| <p data-event-counts>全段记录 · {Object.entries(records.event_counts).map(([kind, count]) => <span key={kind}>{labels[kind as keyof typeof labels]} {metric(count, kind, units)} 次 </span>)}</p> | |
| <p className="muted">点击跳到记录时刻;换目标和提案失败为瞬时事件。</p>{events.map(render)} | |
| {records.budgets.filter(b => b.actor_id === actorId).map(b => <p className="intent-budget" key={b.intent_index} data-intent-budget={b.intent_index}>意图 {b.intent_index}:已用 {b.used} / {b.limit} 次 · 每意图独立额度</p>)} | |
| {!events.length && <p className="muted">该主体没有这些记录。</p>} | |
| </details>; | |
| } | |