Skip to content

Instantly share code, notes, and snippets.

@shreyner
Created February 8, 2025 07:47
Show Gist options
  • Save shreyner/a6e18de00f5d46c0e6c1f12f3a6afcc9 to your computer and use it in GitHub Desktop.
Save shreyner/a6e18de00f5d46c0e6c1f12f3a6afcc9 to your computer and use it in GitHub Desktop.
# .\ollama-download.ps1 -model deepseek-coder-v2:16b
param (
[string]$model
)
if ([string]::IsNullOrEmpty($model)) {
Write-Host "Ошибка: Не передан аргумент модели. Пожалуйста, укажите модель при запуске скрипта." -ForegroundColor Red
exit 1
}
$attempt = 0
$timeout = 10
while ($true) {
$attempt++
$startTime = Get-Date
Write-Host "Attempting to download model '$model'... Attempt $attempt"
$process = Start-Process -FilePath "ollama" -ArgumentList "pull $model" -PassThru -NoNewWindow
try {
$process | Wait-Process -Timeout $timeout -ErrorAction Stop
if ($null -ne $process -and $process.ExitCode -eq 0) {
Write-Host "Model downloaded successfully!"
break
} else {
Write-Host "Download failed (Exit code: $($process.ExitCode)). Retrying..."
}
} catch {
Write-Host "Timeout occurred, restarting download..."
$process | Stop-Process -Force -ErrorAction SilentlyContinue
}
$endTime = Get-Date
Write-Host "Elapsed time for attempt: $(($endTime - $startTime).TotalSeconds) seconds"
Start-Sleep -Seconds 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment