diff --git a/README.md b/README.md index 2382a0a..aa53ea6 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,8 @@ Use `GET /api/capabilities` to inspect the grouped full-function readiness matrix used by the web dashboard and agents. Use `GET /api/results/curves` to inspect parsed training curves discovered from YOLO, SegModel, MMSeg, visual-tool, and analysis output directories. +Use `GET /api/agents/evaluate` and `GET /api/agents/validate` to surface the +same evaluation and validation feedback shown in the web dashboard Agent panel. ## Agents @@ -171,3 +173,8 @@ backend/frontend endpoints when the services are running. With live validation enabled it also runs the lightweight acceptance smoke above. By default it also runs the deep training acceptance; set `SEG_VALIDATE_DEEP=0` when a quick non-training validation pass is needed. + +The web dashboard calls validation in light mode by default: +`/api/agents/validate?run_build=false&run_acceptance=false&run_deep=false`. +Pass `run_acceptance=true` or `run_deep=true` only when you explicitly want the +agent to launch the heavier runtime acceptance checks from the browser/API. diff --git a/backend/app/agents/evaluation_agent.py b/backend/app/agents/evaluation_agent.py index 24186b4..f442743 100644 --- a/backend/app/agents/evaluation_agent.py +++ b/backend/app/agents/evaluation_agent.py @@ -56,6 +56,8 @@ def evaluate_project() -> dict: "deep_acceptance_api": "/api/acceptance/deep" in backend_text, "deep_acceptance_ui": "runDeepAcceptance" in frontend_text and "深度训练" in frontend_text, "deep_yolo_heatmap_validation": "yolo_tiny_heatmap_generation" in acceptance_text, + "agent_api": "/api/agents/evaluate" in backend_text and "/api/agents/validate" in backend_text, + "agent_panel_ui": "runAgentValidation" in frontend_text and "评价建议" in frontend_text and "Validation Agent" in frontend_text, "coverage_api": "/api/coverage" in backend_text and coverage["task_build_passed"], "visual_tools": "visual.yolo11_heatmap_v2" in catalog["task_types"] and "visual.fps" in catalog["task_types"], "yolo_custom_train": "yolo.train_custom" in catalog["task_types"], diff --git a/backend/app/agents/validation_agent.py b/backend/app/agents/validation_agent.py index e57ab74..d3978dd 100644 --- a/backend/app/agents/validation_agent.py +++ b/backend/app/agents/validation_agent.py @@ -42,7 +42,7 @@ def _fetch(url: str, timeout: int = 5) -> dict: return {"url": url, "error": str(exc), "passed": False} -def validate_project(run_build: bool = False) -> dict: +def validate_project(run_build: bool = False, run_acceptance: bool | None = None, run_deep: bool | None = None) -> dict: """Validate current runtime readiness without launching heavy training.""" checks = [] catalog = get_catalog() @@ -140,10 +140,12 @@ def validate_project(run_build: bool = False) -> dict: checks.append({"name": "live_coverage_api", "passed": live_coverage["passed"] and '"task_build_passed":true' in live_coverage.get("body", "").replace(" ", ""), "detail": live_coverage}) checks.append({"name": "live_training_curves_api", "passed": live_curves["passed"] and live_curves.get("body", "").lstrip().startswith("["), "detail": live_curves}) checks.append({"name": "live_frontend_index", "passed": frontend["passed"] and "Seg Data Server" in frontend.get("body", ""), "detail": frontend}) - if os.getenv("SEG_VALIDATE_ACCEPTANCE", "1") == "1": + acceptance_enabled = run_acceptance if run_acceptance is not None else os.getenv("SEG_VALIDATE_ACCEPTANCE", "1") == "1" + deep_enabled = run_deep if run_deep is not None else os.getenv("SEG_VALIDATE_DEEP", "1") == "1" + if acceptance_enabled: acceptance = run_live_acceptance(backend_url) checks.append({"name": "live_acceptance_smoke", "passed": acceptance["passed"], "detail": acceptance}) - if os.getenv("SEG_VALIDATE_DEEP", "1") == "1": + if deep_enabled: deep_acceptance = run_deep_acceptance() checks.append({"name": "deep_training_acceptance", "passed": deep_acceptance["passed"], "detail": deep_acceptance}) diff --git a/backend/app/main.py b/backend/app/main.py index 739de74..93c9e8d 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -269,5 +269,5 @@ def api_agent_evaluate() -> dict: @app.get("/api/agents/validate") -def api_agent_validate(run_build: bool = False) -> dict: - return validate_project(run_build=run_build) +def api_agent_validate(run_build: bool = False, run_acceptance: bool = False, run_deep: bool = False) -> dict: + return validate_project(run_build=run_build, run_acceptance=run_acceptance, run_deep=run_deep) diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index ca566dc..76cabe1 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client"; import { Activity, BarChart3, + Bot, Boxes, ClipboardCheck, Cpu, @@ -231,6 +232,26 @@ type CapabilityPayload = { domains: CapabilityDomain[]; }; +type AgentCheck = { + name: string; + passed: boolean; + detail?: unknown; + details?: unknown; +}; + +type EvaluationAgentPayload = { + agent: string; + score: number; + checks: AgentCheck[]; + suggestions: string[]; +}; + +type ValidationAgentPayload = { + agent: string; + passed: boolean; + checks: AgentCheck[]; +}; + async function api(path: string, init?: RequestInit): Promise { const res = await fetch(`${API_BASE}${path}`, { headers: { "Content-Type": "application/json" }, @@ -305,11 +326,12 @@ function useData() { const [deepAcceptance, setDeepAcceptance] = useState(null); const [runtimeReadiness, setRuntimeReadiness] = useState(null); const [capabilities, setCapabilities] = useState(null); + const [agentEvaluation, setAgentEvaluation] = useState(null); const [error, setError] = useState(""); async function refresh() { try { - const [catalogNext, gpusNext, readinessNext, capabilitiesNext, jobsNext, resultsNext, curvesNext, datasetsNext, coverageNext, acceptanceNext, deepAcceptanceNext] = await Promise.all([ + const [catalogNext, gpusNext, readinessNext, capabilitiesNext, jobsNext, resultsNext, curvesNext, datasetsNext, coverageNext, acceptanceNext, deepAcceptanceNext, agentEvaluationNext] = await Promise.all([ api("/api/catalog"), api("/api/system/gpus"), api("/api/system/readiness"), @@ -320,7 +342,8 @@ function useData() { api("/api/datasets"), api("/api/coverage"), api("/api/acceptance/latest"), - api("/api/acceptance/deep/latest") + api("/api/acceptance/deep/latest"), + api("/api/agents/evaluate") ]); setCatalog(catalogNext); setGpus(gpusNext); @@ -345,6 +368,7 @@ function useData() { setCoverage(coverageNext); setAcceptance(acceptanceNext); setDeepAcceptance(deepAcceptanceNext); + setAgentEvaluation(agentEvaluationNext); setError(""); } catch (err) { setError(String(err)); @@ -357,7 +381,7 @@ function useData() { return () => window.clearInterval(timer); }, []); - return { catalog, gpus, runtimeReadiness, capabilities, jobs, results, curves, datasets, datasetValidations, coverage, acceptance, deepAcceptance, error, refresh }; + return { catalog, gpus, runtimeReadiness, capabilities, agentEvaluation, jobs, results, curves, datasets, datasetValidations, coverage, acceptance, deepAcceptance, error, refresh }; } function StatusPill({ status }: { status: string }) { @@ -380,7 +404,7 @@ function JobProgressBar({ progress }: { progress?: JobProgress }) { } function App() { - const { catalog, gpus, runtimeReadiness, capabilities, jobs, results, curves, datasets, datasetValidations, coverage, acceptance, deepAcceptance, error, refresh } = useData(); + const { catalog, gpus, runtimeReadiness, capabilities, agentEvaluation, jobs, results, curves, datasets, datasetValidations, coverage, acceptance, deepAcceptance, error, refresh } = useData(); const [taskType, setTaskType] = useState("mock.echo"); const [params, setParams] = useState(JSON.stringify(defaultParams["mock.echo"], null, 2)); const [selectedJob, setSelectedJob] = useState(null); @@ -392,6 +416,8 @@ function App() { const [selectedCurvePath, setSelectedCurvePath] = useState(""); const [uploadKind, setUploadKind] = useState<"images" | "labels" | "masks">("images"); const [uploadFiles, setUploadFiles] = useState(null); + const [agentValidation, setAgentValidation] = useState(null); + const [agentBusy, setAgentBusy] = useState(false); const runningCount = jobs.filter((job) => job.status === "running").length; const successCount = jobs.filter((job) => job.status === "success").length; @@ -491,6 +517,16 @@ function App() { } } + async function runAgentValidation() { + setAgentBusy(true); + try { + const result = await api("/api/agents/validate?run_build=false&run_acceptance=false&run_deep=false"); + setAgentValidation(result); + } finally { + setAgentBusy(false); + } + } + async function createDataset() { setBusy(true); try { @@ -575,6 +611,7 @@ function App() { GPU 环境 覆盖 + Agent 权重 结果 @@ -892,6 +929,45 @@ function App() { +
+
+
+
+

Evaluation Agent

+

评价建议

+
+ = 1 ? "success" : "queued"} /> +
+
+ {Math.round((agentEvaluation?.score ?? 0) * 100)}% + {agentEvaluation?.checks.filter((item) => item.passed).length ?? 0}/{agentEvaluation?.checks.length ?? 0} checks passed +
+
+ {(agentEvaluation?.suggestions ?? ["等待评价 agent 返回建议。"]).slice(0, 6).map((item, index) => ( +
{item}
+ ))} +
+ +
+ +
+
+
+

Validation Agent

+

运行验证

+
+ +
+
+ {agentValidation ? (agentValidation.passed ? "OK" : "Check") : "Ready"} + {agentValidation ? `${agentValidation.checks.filter((item) => item.passed).length}/${agentValidation.checks.length} checks passed` : "轻量验证不会触发深度训练"} +
+ +
+
+
@@ -1047,6 +1123,22 @@ function App() { ); } +function AgentCheckList({ checks, limit }: { checks: AgentCheck[]; limit: number }) { + if (!checks.length) { + return

尚未运行验证。

; + } + return ( +
+ {checks.slice(0, limit).map((check) => ( +
+ {check.name} + {check.passed ? "passed" : "needs attention"} +
+ ))} +
+ ); +} + function ResultPreview({ results }: { results: ResultItem[] }) { if (!results.length) { return

暂无结果

; diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 2f834f9..ba524ef 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -610,6 +610,82 @@ textarea { white-space: nowrap; } +.agentPanel { + min-height: 360px; +} + +.agentScore { + display: grid; + grid-template-columns: auto minmax(0, 1fr); + align-items: end; + gap: 12px; + margin-bottom: 12px; +} + +.agentScore strong { + font-size: 38px; + line-height: 1; +} + +.agentScore span { + min-width: 0; + color: var(--muted); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.suggestionList, +.agentCheckList { + display: grid; + gap: 8px; +} + +.suggestionList { + margin-bottom: 12px; +} + +.suggestionList div, +.agentCheckList div { + min-width: 0; + padding: 9px; + border-radius: 6px; + border: 1px solid var(--line); + background: #101310; +} + +.suggestionList div { + color: var(--ink); + line-height: 1.45; +} + +.agentCheckList { + grid-template-columns: repeat(2, minmax(0, 1fr)); + max-height: 310px; + overflow: auto; +} + +.agentCheckList div.ok { + border-color: rgba(157, 226, 111, 0.32); +} + +.agentCheckList div.bad { + border-color: rgba(240, 113, 103, 0.55); +} + +.agentCheckList span, +.agentCheckList small { + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.agentCheckList small { + color: var(--muted); + margin-top: 2px; +} + .datasetCard { width: 100%; display: block; @@ -1126,6 +1202,7 @@ meter { .opGrid, .sampleStrip, .taskCheckList, + .agentCheckList, .qualityStats, .qualityChecks { grid-template-columns: repeat(2, minmax(0, 1fr));