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:
2026-06-15 15:53:57 +08:00
parent 9cbdc1d95d
commit e89695e490
26 changed files with 2496 additions and 2 deletions

16
webapp/api/scenarios.py Normal file
View File

@@ -0,0 +1,16 @@
"""Route for discovering scenario YAML files that can be evaluated."""
from __future__ import annotations
from fastapi import APIRouter
from webapp.services import scenario_scanner
router = APIRouter(prefix="/api/scenarios", tags=["scenarios"])
@router.get("")
def get_scenarios() -> dict[str, list]:
"""Return every scenario file found under the scenarios/ directory."""
scenarios = scenario_scanner.list_scenarios()
return {"scenarios": [item.model_dump() for item in scenarios]}