Add RAGAS evaluation web console (FastAPI + vanilla JS)
- webapp/: FastAPI backend with runs/scenarios/evaluations API routers; services for run_reader, report_builder, scenario_scanner, task_manager (lazy ragas import — server boots even without ragas); Pydantic models - webapp/static/: single-page console (layout A: left-nav + main area); report detail with metric cards, Chart.js distribution histogram, grouping table, lowest-score sample review; trigger evaluation + log polling - webmain.py: uvicorn entry point (alongside existing main.py CLI) - start.bat: Windows one-click launcher with env checks and auto-browser open - rag_eval/datasets/: implement missing loader + normalizer modules (load_dataset_records, normalize_records) required by evaluator - scripts/seed_sample_run.py: generate realistic demo run artifacts - .gitignore: exclude datasets/ data files but keep rag_eval/datasets/ source Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
This commit is contained in:
267
webapp/static/css/app.css
Normal file
267
webapp/static/css/app.css
Normal file
@@ -0,0 +1,267 @@
|
||||
/* Siemens RAGAS 评估控制台 — 样式表
|
||||
配色取自西门子品牌色(petrol / 深青)与中性灰,呼应企业语境。 */
|
||||
|
||||
:root {
|
||||
--petrol: #009999;
|
||||
--petrol-dark: #007a7a;
|
||||
--ink: #0f1b2d;
|
||||
--ink-soft: #1a2942;
|
||||
--slate: #64748b;
|
||||
--slate-light: #94a3b8;
|
||||
--line: #e2e8f0;
|
||||
--bg: #f4f6f9;
|
||||
--surface: #ffffff;
|
||||
--good: #16a34a;
|
||||
--warn: #eab308;
|
||||
--bad: #dc2626;
|
||||
--shadow: 0 1px 3px rgba(15, 27, 45, 0.08), 0 1px 2px rgba(15, 27, 45, 0.04);
|
||||
--radius: 10px;
|
||||
font-synthesis: none;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.app { display: flex; min-height: 100vh; }
|
||||
|
||||
/* ---------- 左侧导航 ---------- */
|
||||
.sidebar {
|
||||
width: 208px;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 100%);
|
||||
color: #cbd5e1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px 14px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.brand { padding: 0 8px 22px; }
|
||||
.brand-mark {
|
||||
font-size: 20px; font-weight: 700; letter-spacing: 1px; color: #fff;
|
||||
}
|
||||
.brand-sub { font-size: 12px; color: var(--petrol); margin-top: 2px; letter-spacing: 2px; }
|
||||
|
||||
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
|
||||
.nav-item {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
background: transparent; border: none; color: #cbd5e1;
|
||||
padding: 10px 12px; border-radius: 8px; cursor: pointer;
|
||||
font-size: 14px; text-align: left; width: 100%;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
|
||||
.nav-item.active { background: var(--petrol); color: #fff; }
|
||||
.nav-item.active .nav-ico { color: #fff; }
|
||||
.nav-item:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
.nav-ico { width: 18px; text-align: center; color: var(--petrol); font-weight: 700; }
|
||||
.nav-item.active .nav-ico { color: #fff; }
|
||||
|
||||
.sidebar-foot {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
font-size: 12px; color: var(--slate-light);
|
||||
padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--slate-light); }
|
||||
.dot.ok { background: var(--good); }
|
||||
.dot.bad { background: var(--bad); }
|
||||
|
||||
/* ---------- 主内容区 ---------- */
|
||||
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
|
||||
|
||||
.topbar {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 18px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
|
||||
position: sticky; top: 0; z-index: 5;
|
||||
}
|
||||
.topbar h1 { font-size: 18px; font-weight: 600; }
|
||||
|
||||
.view { padding: 24px 28px; }
|
||||
|
||||
/* ---------- 按钮 ---------- */
|
||||
.btn {
|
||||
border: 1px solid var(--line); background: var(--surface); color: var(--ink);
|
||||
padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px;
|
||||
transition: all 0.15s; font-family: inherit;
|
||||
}
|
||||
.btn:hover { border-color: var(--petrol); color: var(--petrol); }
|
||||
.btn-primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
|
||||
.btn-primary:hover { background: var(--petrol-dark); border-color: var(--petrol-dark); color: #fff; }
|
||||
.btn-primary:disabled { background: var(--slate-light); border-color: var(--slate-light); cursor: not-allowed; }
|
||||
.btn-ghost { background: transparent; }
|
||||
|
||||
/* ---------- 运行列表 ---------- */
|
||||
.runs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
|
||||
.run-card {
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
padding: 16px; cursor: pointer; transition: all 0.15s; box-shadow: var(--shadow);
|
||||
}
|
||||
.run-card:hover { border-color: var(--petrol); transform: translateY(-1px); }
|
||||
.run-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
|
||||
.run-card-title { font-size: 15px; font-weight: 600; word-break: break-all; }
|
||||
.run-card-meta { font-size: 12px; color: var(--slate); margin-top: 6px; line-height: 1.7; }
|
||||
.run-card-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
|
||||
.metric-chip {
|
||||
font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--bg);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.metric-chip b { font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ---------- 通用面板 ---------- */
|
||||
.panel {
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
|
||||
}
|
||||
.panel h2 { font-size: 16px; margin-bottom: 6px; }
|
||||
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
|
||||
|
||||
.muted { color: var(--slate); }
|
||||
.tiny { font-size: 11px; margin-top: 8px; }
|
||||
.tight { margin: 0 !important; }
|
||||
code {
|
||||
background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
|
||||
padding: 1px 6px; font-size: 12px; font-family: "Cascadia Code", Consolas, monospace;
|
||||
}
|
||||
|
||||
/* ---------- 新建评估 ---------- */
|
||||
.scenario-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
|
||||
.scenario-item {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
||||
border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.scenario-item:hover { border-color: var(--petrol); background: #f0fbfb; }
|
||||
.scenario-item.selected { border-color: var(--petrol); background: #e6f7f7; box-shadow: inset 0 0 0 1px var(--petrol); }
|
||||
.scenario-item.invalid { opacity: 0.55; cursor: not-allowed; }
|
||||
.scenario-name { font-weight: 600; font-size: 14px; }
|
||||
.scenario-path { font-size: 12px; color: var(--slate); font-family: monospace; }
|
||||
.scenario-tags { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
|
||||
.tag {
|
||||
font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg);
|
||||
border: 1px solid var(--line); color: var(--slate);
|
||||
}
|
||||
.tag.mode-online { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
|
||||
.tag.mode-offline { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
|
||||
|
||||
.run-actions { display: flex; align-items: center; gap: 14px; }
|
||||
.selected-scenario { font-size: 13px; }
|
||||
|
||||
/* ---------- 任务进度 ---------- */
|
||||
.task-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
|
||||
.badge {
|
||||
font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
|
||||
background: var(--bg); color: var(--slate); border: 1px solid var(--line);
|
||||
}
|
||||
.badge.queued { background: #f1f5f9; color: var(--slate); }
|
||||
.badge.running { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
|
||||
.badge.completed { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
|
||||
.badge.failed { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
|
||||
.log-box {
|
||||
background: #0b1220; color: #cbd5e1; border-radius: 8px; padding: 14px;
|
||||
font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; line-height: 1.7;
|
||||
max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
|
||||
}
|
||||
.task-actions { margin-top: 12px; }
|
||||
|
||||
/* ---------- 报告详情 ---------- */
|
||||
.report-meta {
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
padding: 14px 18px; display: flex; justify-content: space-between; align-items: center;
|
||||
flex-wrap: wrap; gap: 10px; box-shadow: var(--shadow); margin-bottom: 18px;
|
||||
}
|
||||
.report-meta-title { font-size: 15px; font-weight: 600; }
|
||||
.report-meta-info { font-size: 12px; color: var(--slate); }
|
||||
.status-pill { font-size: 12px; font-weight: 600; }
|
||||
.status-pill.completed { color: var(--good); }
|
||||
|
||||
.section-label {
|
||||
font-size: 12px; font-weight: 600; letter-spacing: 0.5px; color: var(--slate);
|
||||
text-transform: uppercase; margin: 18px 0 10px;
|
||||
}
|
||||
|
||||
.metric-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
|
||||
.metric-card {
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
padding: 16px; text-align: center; box-shadow: var(--shadow);
|
||||
}
|
||||
.metric-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
.metric-value.good { color: var(--good); }
|
||||
.metric-value.warn { color: var(--warn); }
|
||||
.metric-value.bad { color: var(--bad); }
|
||||
.metric-value.na { color: var(--slate-light); }
|
||||
.metric-name { font-size: 12px; color: var(--slate); margin-top: 4px; }
|
||||
|
||||
.report-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
||||
.report-half { margin-bottom: 0; }
|
||||
|
||||
.select {
|
||||
border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px;
|
||||
background: var(--surface); color: var(--ink); font-family: inherit; cursor: pointer;
|
||||
}
|
||||
|
||||
.grouping-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
|
||||
.grouping-tab {
|
||||
font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line);
|
||||
background: var(--surface); cursor: pointer; color: var(--slate);
|
||||
}
|
||||
.grouping-tab.active { background: var(--petrol); color: #fff; border-color: var(--petrol); }
|
||||
|
||||
table.group-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||||
table.group-table th, table.group-table td { padding: 6px 8px; text-align: left; }
|
||||
table.group-table th { color: var(--slate); border-bottom: 1px solid var(--line); font-weight: 600; }
|
||||
table.group-table td { border-bottom: 1px solid #f1f5f9; font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* 最低分样本表 */
|
||||
.lowest-table {
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
overflow: hidden; box-shadow: var(--shadow);
|
||||
}
|
||||
.lowest-row {
|
||||
display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center;
|
||||
padding: 11px 16px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background 0.12s;
|
||||
}
|
||||
.lowest-row:hover { background: var(--bg); }
|
||||
.lowest-row .sid { font-size: 12px; color: var(--slate); font-family: monospace; }
|
||||
.lowest-row .q { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.lowest-row .scores { display: flex; gap: 8px; }
|
||||
.score-badge {
|
||||
font-size: 12px; padding: 2px 8px; border-radius: 6px; font-variant-numeric: tabular-nums;
|
||||
font-weight: 600;
|
||||
}
|
||||
.score-badge.good { background: #dcfce7; color: #166534; }
|
||||
.score-badge.warn { background: #fef9c3; color: #854d0e; }
|
||||
.score-badge.bad { background: #fee2e2; color: #991b1b; }
|
||||
.score-badge.na { background: var(--bg); color: var(--slate-light); }
|
||||
|
||||
.lowest-detail { padding: 0 16px; background: #fcfdfe; border-bottom: 1px solid #f1f5f9; }
|
||||
.lowest-detail-inner { padding: 14px 0; font-size: 13px; line-height: 1.7; }
|
||||
.detail-field { margin-bottom: 10px; }
|
||||
.detail-label { font-size: 12px; color: var(--slate); font-weight: 600; margin-bottom: 3px; }
|
||||
.detail-context { color: #475569; font-size: 12px; }
|
||||
.detail-context .ctx-item {
|
||||
padding: 4px 0; border-bottom: 1px dashed var(--line);
|
||||
}
|
||||
.detail-gt { color: var(--good); }
|
||||
|
||||
.empty { text-align: center; padding: 60px 20px; color: var(--slate); }
|
||||
.empty p { margin-bottom: 8px; }
|
||||
|
||||
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line);
|
||||
border-top-color: var(--petrol); border-radius: 50%; animation: spin 0.7s linear infinite;
|
||||
vertical-align: middle; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
@media (max-width: 880px) {
|
||||
.report-row { grid-template-columns: 1fr; }
|
||||
.sidebar { width: 64px; }
|
||||
.brand-sub, .nav-item span:not(.nav-ico), .sidebar-foot span:last-child { display: none; }
|
||||
}
|
||||
Reference in New Issue
Block a user