mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-21 20:22:01 +00:00
双盲复算前端(三):检查器字段、节点卡片摘要,以及检查器与节点卡片的钩子
- nodeDefs:照约定一字不差地加 FieldDef.render 与 FieldRenderProps;NodeDef 加可选的 summary(ctx) 钩子 (ctx:id、config、画布上的 nodes 与 edges,只返回字符串);dual_check 换成真字段:要复算的口径卡、复算的指标、 口径说明、启用、审核人不采用原流程的结果时(基本),盲算模型的接入与模型、允许的相对误差(高级) - Inspector:照约定一字不差地在 FieldInput 的 switch 前交给 field.render - canvas/DualCheckFields.tsx(新):口径卡下拉分上游、其余两组,不在上游或不在画布上照实提醒;指标逐个勾, 全勾回到缺省不写、最后一个不让取消;口径说明逐个指标写,被取消的指标上已写的说明列出来可删;盲算模型照「结论句 裁判」的写法(只填模型时写明按模型名用哪个接入);相对误差的占位写出设置里的值;启用三态,跟随设置不留 null。 每个控件只写自己的键,留空写回 undefined - NodeCard:用只返回字符串的 studio 选择器调摘要钩子,有就用、没有照旧 summarize;摘要写「复算「卡名」 · N 个指标」, 关闭时标出;去掉 dual_check 的占位 case - 预览用例加检查器(小画布用真的节点卡片 + 360px 检查器),check-verify 加检查器写配置、摘要跟着变、窄屏和对比度 - 去掉 nodeDefs 里已经不成立的「下面两种还是占位」注释
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import {
|
||||
Bot, Braces, Brain, CheckCircle2, Code2, Combine, Database, FileInput, FileOutput, FileText,
|
||||
Gauge, GitBranch, GitCompareArrows, Hand, Repeat, Search, ShieldAlert, Shuffle, Users, Wrench,
|
||||
@@ -6,6 +7,7 @@ import {
|
||||
APPROVAL_POLICY_LABEL, CHALLENGE_TEXT, DUAL_CHECK_TEXT, MERGE_TEXT, NODE_TYPE_LABEL, UPGRADE_POLICY_LABEL,
|
||||
} from '../lib/terms'
|
||||
import type { NodeType } from '../types'
|
||||
import { dualCheckFields, dualCheckSummary } from './DualCheckFields'
|
||||
|
||||
export type FieldType =
|
||||
| 'text' | 'textarea' | 'prompt' | 'code' | 'number' | 'select' | 'switch'
|
||||
@@ -51,6 +53,23 @@ export interface FieldDef {
|
||||
*/
|
||||
unknownLabel?: (value: string) => string
|
||||
advanced?: boolean
|
||||
/**
|
||||
* 现有字段类型画不了的配置(选画布上某一类节点、三态开关、接入加模型)交给它画。
|
||||
* 给了 render 就不再按 type 渲染;type 仍用于默认值和校验
|
||||
*/
|
||||
render?: (p: FieldRenderProps) => ReactNode
|
||||
}
|
||||
|
||||
/** FieldDef.render 拿到的:当前值、写回、所在节点和配置,以及无障碍属性 */
|
||||
export interface FieldRenderProps {
|
||||
id: string
|
||||
nodeId: string
|
||||
value: any
|
||||
config: Record<string, any>
|
||||
invalid: boolean
|
||||
describedBy?: string
|
||||
disabled?: boolean
|
||||
onChange: (v: any) => void
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,6 +110,19 @@ export interface NodeDef {
|
||||
sources: HandleDef[] | null
|
||||
fields: FieldDef[]
|
||||
defaults: Record<string, any>
|
||||
/**
|
||||
* 卡片正文那一行摘要要提到画布上别的节点时给它(双盲复算复算的是哪张口径卡、几个指标),没给的照旧走
|
||||
* NodeCard 的 summarize。NodeCard 在 studio store 的选择器里调它、每条事件都会跑:要快、没有副作用、只返回字符串
|
||||
*/
|
||||
summary?: (ctx: NodeSummaryContext) => string
|
||||
}
|
||||
|
||||
/** NodeDef.summary 拿到的:这个节点的 id 和配置,以及画布上的全部节点和连线 */
|
||||
export interface NodeSummaryContext {
|
||||
id: string
|
||||
config: Record<string, any>
|
||||
nodes: readonly { id: string; data: { nodeType: NodeType; label?: string; config?: Record<string, any> } }[]
|
||||
edges: readonly { source: string; target: string }[]
|
||||
}
|
||||
|
||||
const MODEL_FIELDS: FieldDef[] = [
|
||||
@@ -658,14 +690,47 @@ export const NODE_DEFS: Record<NodeType, NodeDef> = {
|
||||
metrics: [{ id: 'total', name: '', unit: '', expression: '' }],
|
||||
},
|
||||
},
|
||||
// 下面两种还是占位:服务端的执行器原样跳过(engine/nodes/dual_check.py、challenge.py),没有可配的字段。
|
||||
// 说明里写明尚未生效,检查器顶上就是这一句;各自的工作包补上字段时把这句去掉
|
||||
dual_check: {
|
||||
type: 'dual_check', label: NODE_TYPE_LABEL.dual_check, category: '把关', icon: GitCompareArrows,
|
||||
description: DUAL_CHECK_TEXT.description,
|
||||
hasTarget: true, sources: [{ id: 'out', label: '' }],
|
||||
fields: [],
|
||||
// 配置的键和缺省见 types.ts 的 DualCheckConfig(期 3 约定)。口径卡、指标、口径说明要看画布上别的节点,
|
||||
// 盲算模型是接入加模型,启用是三态,都交给 DualCheckFields 画;type 只管默认值和校验时当什么看
|
||||
fields: [
|
||||
{ key: 'card', label: DUAL_CHECK_TEXT.field.card, type: 'select', help: DUAL_CHECK_TEXT.help.card, render: dualCheckFields.card },
|
||||
{
|
||||
key: 'metrics', label: DUAL_CHECK_TEXT.field.metrics, type: 'json', help: DUAL_CHECK_TEXT.help.metrics,
|
||||
render: dualCheckFields.metrics,
|
||||
},
|
||||
{
|
||||
key: 'definitions', label: DUAL_CHECK_TEXT.field.definitions, type: 'json', help: DUAL_CHECK_TEXT.help.definitions,
|
||||
render: dualCheckFields.definitions,
|
||||
},
|
||||
{
|
||||
key: 'enabled', label: DUAL_CHECK_TEXT.field.enabled, type: 'select', help: DUAL_CHECK_TEXT.help.enabled,
|
||||
render: dualCheckFields.enabled,
|
||||
},
|
||||
{
|
||||
// 没写和写 degrade 是一回事:选项从 degrade 排起,没写时下拉框落在它上面,正好是缺省
|
||||
key: 'on_reject', label: DUAL_CHECK_TEXT.field.onReject, type: 'select', help: DUAL_CHECK_TEXT.help.onReject,
|
||||
options: [
|
||||
{ value: 'degrade', label: DUAL_CHECK_TEXT.onReject.degrade },
|
||||
{ value: 'fail', label: DUAL_CHECK_TEXT.onReject.fail },
|
||||
],
|
||||
unknownLabel: DUAL_CHECK_TEXT.onRejectUnknown,
|
||||
},
|
||||
{ key: 'provider', label: DUAL_CHECK_TEXT.field.provider, type: 'select', advanced: true, render: dualCheckFields.provider },
|
||||
{
|
||||
key: 'model', label: DUAL_CHECK_TEXT.field.model, type: 'text', advanced: true, help: DUAL_CHECK_TEXT.help.model,
|
||||
render: dualCheckFields.model,
|
||||
},
|
||||
{
|
||||
key: 'tolerance', label: DUAL_CHECK_TEXT.field.tolerance, type: 'number', min: 0, advanced: true,
|
||||
help: DUAL_CHECK_TEXT.help.tolerance, render: dualCheckFields.tolerance,
|
||||
},
|
||||
],
|
||||
defaults: {},
|
||||
summary: dualCheckSummary,
|
||||
},
|
||||
challenge: {
|
||||
type: 'challenge', label: NODE_TYPE_LABEL.challenge, category: '把关', icon: ShieldAlert,
|
||||
|
||||
Reference in New Issue
Block a user