Created
February 8, 2025 07:47
-
-
Save shreyner/a6e18de00f5d46c0e6c1f12f3a6afcc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .\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