# Setup script for mini-OpenClaw backend Write-Host "=== 阶段一:搭建后端环境 ===" -ForegroundColor Green # 1. Create virtual environment Write-Host "`n[1/3] Creating Python virtual environment..." -ForegroundColor Yellow if (-not (Test-Path venv)) { python -m venv venv if ($LASTEXITCODE -eq 0) { Write-Host "✓ Virtual environment created" -ForegroundColor Green } else { Write-Host "✗ Failed to create venv" -ForegroundColor Red exit 1 } } else { Write-Host "✓ Virtual environment already exists" -ForegroundColor Green } # 2. Activate and install dependencies Write-Host "`n[2/3] Installing dependencies..." -ForegroundColor Yellow Write-Host "Using Tsinghua mirror for faster downloads..." -ForegroundColor Cyan & .\venv\Scripts\Activate.ps1 if ($LASTEXITCODE -ne 0) { Write-Host "✗ Failed to activate venv" -ForegroundColor Red exit 1 } pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple if ($LASTEXITCODE -eq 0) { Write-Host "✓ Dependencies installed successfully" -ForegroundColor Green } else { Write-Host "✗ Failed to install dependencies" -ForegroundColor Red exit 1 } # 3. Verify installation Write-Host "`n[3/3] Verifying installation..." -ForegroundColor Yellow python -c "import fastapi; import langchain; import llama_index; print('✓ All core packages imported successfully')" Write-Host "`n=== Setup Complete ===" -ForegroundColor Green Write-Host "To start the backend, run:" -ForegroundColor Cyan Write-Host " .\venv\Scripts\Activate.ps1" -ForegroundColor White Write-Host " uvicorn app:app --host 0.0.0.0 --port 8002" -ForegroundColor White