124 lines
4.0 KiB
Batchfile
124 lines
4.0 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
echo.
|
|
echo ============================================================
|
|
echo Siemens RAGAS Console - Starting...
|
|
echo ============================================================
|
|
echo.
|
|
|
|
:: Change to the directory where this script lives (siemens_ragas/)
|
|
cd /d "%~dp0"
|
|
echo Working directory: %CD%
|
|
echo.
|
|
|
|
:: ----------------------------------------------------------------
|
|
:: 1. Check Python
|
|
:: ----------------------------------------------------------------
|
|
python --version >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [ERROR] Python not found. Please install Python 3.12+ and add it to PATH.
|
|
goto :error
|
|
)
|
|
for /f "tokens=*" %%v in ('python --version 2^>^&1') do echo [OK] %%v
|
|
|
|
:: ----------------------------------------------------------------
|
|
:: 2. Check FastAPI / uvicorn
|
|
:: ----------------------------------------------------------------
|
|
python -c "import fastapi, uvicorn" >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [INFO] Installing fastapi and uvicorn...
|
|
pip install fastapi uvicorn --quiet
|
|
if errorlevel 1 (
|
|
echo [ERROR] Failed to install fastapi/uvicorn.
|
|
echo Run manually: pip install fastapi uvicorn
|
|
goto :error
|
|
)
|
|
echo [OK] fastapi and uvicorn installed.
|
|
) else (
|
|
echo [OK] fastapi / uvicorn ready.
|
|
)
|
|
|
|
:: ----------------------------------------------------------------
|
|
:: 3. Check ragas version
|
|
:: ----------------------------------------------------------------
|
|
python -c "import ragas; assert ragas.__version__ == '0.4.3', ragas.__version__" >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [INFO] Installing ragas==0.4.3 ...
|
|
pip install "ragas==0.4.3" --quiet
|
|
if errorlevel 1 (
|
|
echo [WARN] ragas install failed. Dashboard still works; evaluation trigger will show an error.
|
|
) else (
|
|
echo [OK] ragas 0.4.3 installed.
|
|
)
|
|
) else (
|
|
echo [OK] ragas 0.4.3 ready.
|
|
)
|
|
|
|
:: ----------------------------------------------------------------
|
|
:: 4. Ensure configs/ directory exists for LLM profile storage
|
|
:: ----------------------------------------------------------------
|
|
if not exist "configs" (
|
|
mkdir configs
|
|
echo [OK] Created configs/ directory for LLM profile storage.
|
|
) else (
|
|
echo [OK] configs/ directory ready.
|
|
)
|
|
|
|
:: ----------------------------------------------------------------
|
|
:: 5. Seed demo data if no runs exist yet
|
|
:: ----------------------------------------------------------------
|
|
if not exist "outputs\kba-knowledge-base-offline-baseline" (
|
|
echo [INFO] No run data found. Generating demo data...
|
|
python scripts\seed_sample_run.py
|
|
if errorlevel 1 (
|
|
echo [WARN] Demo data generation failed. Dashboard may be empty.
|
|
) else (
|
|
echo [OK] Demo data generated.
|
|
)
|
|
) else (
|
|
echo [OK] Run data found, skipping demo generation.
|
|
)
|
|
|
|
:: ----------------------------------------------------------------
|
|
:: 6. Pick an available port
|
|
:: ----------------------------------------------------------------
|
|
set PORT=8800
|
|
netstat -ano 2>nul | findstr ":8800" | findstr "LISTENING" >nul 2>&1
|
|
if not errorlevel 1 (
|
|
echo [WARN] Port 8800 in use, trying 8801...
|
|
set PORT=8801
|
|
netstat -ano 2>nul | findstr ":8801" | findstr "LISTENING" >nul 2>&1
|
|
if not errorlevel 1 (
|
|
echo [ERROR] Ports 8800 and 8801 are both in use.
|
|
echo Run manually: python webmain.py --port 8802
|
|
goto :error
|
|
)
|
|
)
|
|
|
|
echo.
|
|
echo ============================================================
|
|
echo Console URL : http://127.0.0.1:%PORT%
|
|
echo Press Ctrl+C to stop the server
|
|
echo ============================================================
|
|
echo.
|
|
|
|
:: Open browser after 2-second delay (non-blocking)
|
|
start /b cmd /c "timeout /t 2 >nul && start http://127.0.0.1:%PORT%"
|
|
|
|
:: Launch uvicorn (blocking — window stays open while server runs)
|
|
python webmain.py --host 127.0.0.1 --port %PORT%
|
|
|
|
echo.
|
|
echo Server stopped.
|
|
pause
|
|
exit /b 0
|
|
|
|
:error
|
|
echo.
|
|
echo ============================================================
|
|
echo Startup failed. See error above.
|
|
echo ============================================================
|
|
pause
|
|
exit /b 1
|