Files
site/WESP_REL/install/assistant/download_llama_server.ps1
2026-07-17 12:57:18 +03:00

55 lines
2.6 KiB
PowerShell

# Downloads llama-server.exe (Windows x64 CPU) from latest ggml-org/llama.cpp release
# into <repo>\tools\llama-server.exe
#
# From install folder:
# powershell -ExecutionPolicy Bypass -File assistant\download_llama_server.ps1
$ErrorActionPreference = "Stop"
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
$toolsDir = Join-Path $repoRoot "tools"
New-Item -ItemType Directory -Force -Path $toolsDir | Out-Null
$destExe = Join-Path $toolsDir "llama-server.exe"
if (Test-Path -LiteralPath $destExe) {
Write-Host "Already exists: $destExe" -ForegroundColor Green
Write-Host "Delete the file to re-download."
exit 0
}
Write-Host "Fetching latest llama.cpp release..." -ForegroundColor Cyan
$rel = Invoke-RestMethod -Uri "https://api.github.com/repos/ggml-org/llama.cpp/releases/latest" -Headers @{ "User-Agent" = "Mozilla/5.0 WESP" }
$asset = $rel.assets | Where-Object { $_.name -match '^llama-.+-bin-win-cpu-x64\.zip$' } | Select-Object -First 1
if (-not $asset) {
Write-Error "No llama-*-bin-win-cpu-x64.zip in release $($rel.tag_name). Download manually: https://github.com/ggml-org/llama.cpp/releases"
}
$url = $asset.browser_download_url
$zipName = $asset.name
$tmp = Join-Path $env:TEMP ("wesp-llama-" + [Guid]::NewGuid().ToString())
New-Item -ItemType Directory -Path $tmp -Force | Out-Null
$zipPath = Join-Path $tmp $zipName
try {
$mb = [math]::Round($asset.size / 1048576, 1)
Write-Host "Downloading $zipName size=${mb}MiB ..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing
Write-Host "Extracting..." -ForegroundColor Cyan
Expand-Archive -Path $zipPath -DestinationPath $tmp -Force
$found = Get-ChildItem -Path $tmp -Recurse -Filter "llama-server.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $found) {
Write-Error "llama-server.exe not found inside zip. Check release layout manually."
}
Copy-Item -LiteralPath $found.FullName -Destination $destExe -Force
$exeDir = $found.Directory.FullName
Get-ChildItem -Path $exeDir -Filter "*.dll" -File -ErrorAction SilentlyContinue | ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $toolsDir $_.Name) -Force
Write-Host "Copied: $($_.Name)" -ForegroundColor DarkGray
}
Write-Host "OK: $destExe (+ DLLs in tools\)" -ForegroundColor Green
Write-Host "Run from install folder: .\assistant\run_llama_server.ps1" -ForegroundColor Yellow
Write-Host "Set WESP_ADMIN_LLM_ENABLED=1 and WESP_LLM_BASE_URL=http://127.0.0.1:8080" -ForegroundColor Yellow
}
finally {
Remove-Item -LiteralPath $tmp -Recurse -Force -ErrorAction SilentlyContinue
}