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:
99
start.bat
Normal file
99
start.bat
Normal file
@@ -0,0 +1,99 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo.
|
||||
echo ============================================================
|
||||
echo Siemens RAGAS 评估控制台 启动脚本
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
:: ---- 切换到脚本所在目录(即 siemens_ragas/)-------------------
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: ---- 检查 Python ---------------------------------------------------
|
||||
python --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [错误] 未找到 Python,请确认已安装 Python 3.12+ 并加入 PATH。
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
for /f "tokens=*" %%v in ('python --version 2^>^&1') do set PY_VER=%%v
|
||||
echo [OK] %PY_VER%
|
||||
|
||||
:: ---- 检查 FastAPI / uvicorn ---------------------------------------
|
||||
python -c "import fastapi, uvicorn" >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [提示] 正在安装 FastAPI 和 uvicorn...
|
||||
pip install fastapi uvicorn --quiet
|
||||
if errorlevel 1 (
|
||||
echo [错误] 安装依赖失败,请手动运行: pip install fastapi uvicorn
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [OK] FastAPI / uvicorn 安装完成。
|
||||
) else (
|
||||
echo [OK] FastAPI / uvicorn 已就绪。
|
||||
)
|
||||
|
||||
:: ---- 检查 ragas 版本 ----------------------------------------------
|
||||
python -c "import ragas; assert ragas.__version__ == '0.4.3', ragas.__version__" >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [提示] 正在安装 ragas==0.4.3(评估引擎依赖)...
|
||||
pip install "ragas==0.4.3" --quiet
|
||||
if errorlevel 1 (
|
||||
echo [警告] ragas 安装失败。
|
||||
echo 控制台仍可启动:报告看板可用,触发评估功能将显示错误。
|
||||
echo.
|
||||
) else (
|
||||
echo [OK] ragas 0.4.3 安装完成。
|
||||
)
|
||||
) else (
|
||||
echo [OK] ragas 0.4.3 已就绪。
|
||||
)
|
||||
|
||||
:: ---- 检查是否有示例数据,没有则自动生成 ---------------------------
|
||||
set SAMPLE_META=outputs\kba-knowledge-base-offline-baseline\2026-06-15T08-30-00+00-00\metadata.json
|
||||
if not exist "%SAMPLE_META%" (
|
||||
echo [提示] 未找到示例运行数据,正在生成...
|
||||
python scripts\seed_sample_run.py
|
||||
if errorlevel 1 (
|
||||
echo [警告] 示例数据生成失败,看板可能为空。继续启动...
|
||||
) else (
|
||||
echo [OK] 示例数据已生成。
|
||||
)
|
||||
) else (
|
||||
echo [OK] 已有运行数据,跳过示例生成。
|
||||
)
|
||||
|
||||
:: ---- 检查端口是否已占用 ------------------------------------------
|
||||
set PORT=8800
|
||||
netstat -ano | findstr /r ":%PORT%[^0-9]" | findstr "LISTENING" >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
echo [警告] 端口 %PORT% 已被占用,尝试使用 8801...
|
||||
set PORT=8801
|
||||
netstat -ano | findstr /r ":8801[^0-9]" | findstr "LISTENING" >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
echo [错误] 端口 8800 和 8801 均被占用,请手动指定端口:
|
||||
echo python webmain.py --port ^<端口号^>
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ============================================================
|
||||
echo 启动控制台:http://127.0.0.1:%PORT%
|
||||
echo 按 Ctrl+C 停止服务
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
:: ---- 稍等 1 秒后在默认浏览器打开页面 ----------------------------
|
||||
start /b cmd /c "timeout /t 2 >nul && start http://127.0.0.1:%PORT%"
|
||||
|
||||
:: ---- 启动 uvicorn -------------------------------------------------
|
||||
python webmain.py --host 127.0.0.1 --port %PORT%
|
||||
|
||||
echo.
|
||||
echo 服务已停止。
|
||||
pause
|
||||
Reference in New Issue
Block a user