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

47 lines
2.2 KiB
PowerShell

# Re-download latest llama.cpp win-cpu-x64 zip and copy llama-server.exe + all DLLs into <repo>\tools\
# Use when llama-server fails with exit -1073741515 (missing DLL) or after upgrading llama.cpp.
#
# powershell -ExecutionPolicy Bypass -File install\assistant\sync_llama_tools.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"
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). See 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 (${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."
}
Copy-Item -LiteralPath $found.FullName -Destination $destExe -Force
$exeDir = $found.Directory.FullName
$n = 0
Get-ChildItem -Path $exeDir -Filter "*.dll" -File -ErrorAction SilentlyContinue | ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $toolsDir $_.Name) -Force
$n++
}
Write-Host "OK: $destExe and $n DLL file(s) in tools\" -ForegroundColor Green
}
finally {
Remove-Item -LiteralPath $tmp -Recurse -Force -ErrorAction SilentlyContinue
}