# start.ps1 — Siemens RAGAS Console launcher for Windows PowerShell # Usage: Right-click -> "Run with PowerShell", or: powershell -ExecutionPolicy Bypass -File start.ps1 $ErrorActionPreference = "Stop" Set-Location $PSScriptRoot Write-Host "" Write-Host "============================================================" -ForegroundColor Cyan Write-Host " Siemens RAGAS Console - Starting..." -ForegroundColor Cyan Write-Host "============================================================" -ForegroundColor Cyan Write-Host "" Write-Host "Working directory: $PSScriptRoot" Write-Host "" # ---------------------------------------------------------------- # 1. Check Python # ---------------------------------------------------------------- try { $pyver = & python --version 2>&1 Write-Host "[OK] $pyver" -ForegroundColor Green } catch { Write-Host "[ERROR] Python not found. Please install Python 3.12+ and add to PATH." -ForegroundColor Red Read-Host "Press Enter to exit" exit 1 } # ---------------------------------------------------------------- # 2. Check FastAPI / uvicorn # ---------------------------------------------------------------- $check = & python -c "import fastapi, uvicorn" 2>&1 if ($LASTEXITCODE -ne 0) { Write-Host "[INFO] Installing fastapi and uvicorn..." -ForegroundColor Yellow & pip install fastapi uvicorn --quiet if ($LASTEXITCODE -ne 0) { Write-Host "[ERROR] Failed to install fastapi/uvicorn. Run: pip install fastapi uvicorn" -ForegroundColor Red Read-Host "Press Enter to exit" exit 1 } Write-Host "[OK] fastapi / uvicorn installed." -ForegroundColor Green } else { Write-Host "[OK] fastapi / uvicorn ready." -ForegroundColor Green } # ---------------------------------------------------------------- # 3. Check ragas version # ---------------------------------------------------------------- $check = & python -c "import ragas; assert ragas.__version__ == '0.4.3', ragas.__version__" 2>&1 if ($LASTEXITCODE -ne 0) { Write-Host "[INFO] Installing ragas==0.4.3 (evaluation engine)..." -ForegroundColor Yellow & pip install "ragas==0.4.3" --quiet if ($LASTEXITCODE -ne 0) { Write-Host "[WARN] ragas install failed. Dashboard works; evaluation trigger will show error." -ForegroundColor Yellow } else { Write-Host "[OK] ragas 0.4.3 installed." -ForegroundColor Green } } else { Write-Host "[OK] ragas 0.4.3 ready." -ForegroundColor Green } # ---------------------------------------------------------------- # 4. Seed demo data if missing # ---------------------------------------------------------------- if (-not (Test-Path "outputs\kba-knowledge-base-offline-baseline")) { Write-Host "[INFO] No run data found. Generating demo data..." -ForegroundColor Yellow & python scripts\seed_sample_run.py if ($LASTEXITCODE -ne 0) { Write-Host "[WARN] Demo data generation failed. Dashboard may be empty." -ForegroundColor Yellow } else { Write-Host "[OK] Demo data generated." -ForegroundColor Green } } else { Write-Host "[OK] Run data found, skipping demo generation." -ForegroundColor Green } # ---------------------------------------------------------------- # 5. Pick an available port # ---------------------------------------------------------------- $PORT = 8800 $inUse = netstat -ano 2>$null | Select-String ":$PORT\s" | Select-String "LISTENING" if ($inUse) { Write-Host "[WARN] Port $PORT in use, trying 8801..." -ForegroundColor Yellow $PORT = 8801 $inUse = netstat -ano 2>$null | Select-String ":$PORT\s" | Select-String "LISTENING" if ($inUse) { Write-Host "[ERROR] Ports 8800 and 8801 are both in use." -ForegroundColor Red Write-Host " Run manually: python webmain.py --port 8802" Read-Host "Press Enter to exit" exit 1 } } Write-Host "" Write-Host "============================================================" -ForegroundColor Cyan Write-Host " Console URL : http://127.0.0.1:$PORT" -ForegroundColor Green Write-Host " Press Ctrl+C to stop the server" -ForegroundColor Cyan Write-Host "============================================================" -ForegroundColor Cyan Write-Host "" # Open browser after 2-second delay Start-Job -ScriptBlock { param($port) Start-Sleep 2 Start-Process "http://127.0.0.1:$port" } -ArgumentList $PORT | Out-Null # Launch uvicorn (blocking) & python webmain.py --host 127.0.0.1 --port $PORT Write-Host "" Write-Host "Server stopped." Read-Host "Press Enter to exit"