Repository navigation
Expand file tree
/
Copy pathsetup.ps1
More file actions
96 lines (85 loc) · 3.22 KB
/
Copy pathsetup.ps1
File metadata and controls
96 lines (85 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# setup.ps1 — Agent Patterns Demo Pack setup script (Windows PowerShell)
# Creates a virtual environment, installs dependencies, and prepares .env config.
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition
Write-Host ""
Write-Host "===== Agent Patterns Demo Pack — Setup =====" -ForegroundColor Cyan
Write-Host ""
# --- Python check ---
$pythonCmd = $null
foreach ($candidate in @("python", "python3")) {
try {
$ver = & $candidate --version 2>&1
if ($ver -match "Python 3\.(\d+)") {
$minor = [int]$Matches[1]
if ($minor -ge 10) {
$pythonCmd = $candidate
Write-Host "[OK] Found $ver" -ForegroundColor Green
break
}
}
} catch { }
}
if (-not $pythonCmd) {
Write-Host "[ERROR] Python 3.10+ is required but was not found." -ForegroundColor Red
Write-Host " Install from https://www.python.org/downloads/"
exit 1
}
# --- Virtual environment ---
$venvPath = Join-Path $ProjectRoot ".venv"
if (-not (Test-Path $venvPath)) {
Write-Host ""
Write-Host "Creating virtual environment..." -ForegroundColor Yellow
& $pythonCmd -m venv $venvPath
Write-Host "[OK] Virtual environment created at .venv" -ForegroundColor Green
} else {
Write-Host "[OK] Virtual environment already exists at .venv" -ForegroundColor Green
}
# --- Activate venv ---
$activateScript = Join-Path $venvPath "Scripts\Activate.ps1"
. $activateScript
# --- Install dependencies ---
Write-Host ""
Write-Host "Installing dependencies..." -ForegroundColor Yellow
pip install --upgrade pip | Out-Null
pip install -r (Join-Path $ProjectRoot "requirements.txt") --pre
Write-Host "[OK] Dependencies installed" -ForegroundColor Green
# --- .env file ---
$envFile = Join-Path $ProjectRoot ".env"
$envExample = Join-Path $ProjectRoot ".env.example"
if (-not (Test-Path $envFile)) {
if (Test-Path $envExample) {
Copy-Item $envExample $envFile
Write-Host "[OK] Created .env from .env.example" -ForegroundColor Green
} else {
Write-Host "[WARN] No .env.example found — skipping .env creation" -ForegroundColor Yellow
}
} else {
Write-Host "[OK] .env already exists" -ForegroundColor Green
}
# --- Foundry Local check ---
Write-Host ""
$foundryInstalled = $false
try {
$foundryVer = & foundry --version 2>&1
if ($LASTEXITCODE -eq 0) {
$foundryInstalled = $true
Write-Host "[OK] Foundry Local is installed ($foundryVer)" -ForegroundColor Green
}
} catch { }
if (-not $foundryInstalled) {
Write-Host "[INFO] Foundry Local is not installed." -ForegroundColor Yellow
Write-Host " Install it with: winget install Microsoft.FoundryLocal"
Write-Host " Or visit: https://foundrylocal.ai"
}
# --- Done ---
Write-Host ""
Write-Host "===== Setup complete! =====" -ForegroundColor Cyan
Write-Host ""
Write-Host "Next steps:" -ForegroundColor White
Write-Host " 1. Activate the venv: .venv\Scripts\Activate.ps1"
Write-Host " 2. Start a model: foundry model run qwen2.5-1.5b"
Write-Host " 3. Launch the app: python app.py"
Write-Host " 4. Open browser: http://localhost:8765"
Write-Host ""