$ErrorActionPreference = "Stop"

$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
$Venv = Join-Path $Root ".venv"
$Python = Join-Path $Venv "Scripts\python.exe"

if (!(Test-Path $Python)) {
    py -3 -m venv $Venv
}

& $Python -m pip install -r (Join-Path $Root "requirements.txt")
$env:PYTHONPATH = Join-Path $Root "backend"
& $Python -m uvicorn agent4.main:app --host 127.0.0.1 --port 7200 --reload
