Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d192e3c434 | ||
|
|
6c3a594a14 | ||
|
|
0d07146162 |
No files matched your search
+4
-50
@@ -65,8 +65,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
}
|
||||
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
|
||||
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
|
||||
$null = cmd /c "docker info >NUL 2>&1"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
if (-not (cmd /c "docker info >NUL 2>&1")) {
|
||||
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
|
||||
exit 1
|
||||
}
|
||||
@@ -80,9 +79,6 @@ if ($TotalRamGb -lt 3.5) {
|
||||
}
|
||||
Ok "RAM: $TotalRamGb GB"
|
||||
|
||||
# --- Tumbar deploy previo (antes de detectar puertos) -----------------------
|
||||
cmd /c docker rm -f d0a1-hermes-ollama '>' NUL '2>&1'
|
||||
|
||||
# --- Auto-detect Ollama port ------------------------------------------------
|
||||
$OllamaPort = Find-FreePort 11434
|
||||
|
||||
@@ -91,7 +87,7 @@ if ($Mode -eq 'vps') {
|
||||
Write-Host ''
|
||||
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/vultr/${NC} - Vultr"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
|
||||
Write-Host ''
|
||||
}
|
||||
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
|
||||
@@ -124,50 +120,8 @@ while ($true) {
|
||||
}
|
||||
}
|
||||
Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
|
||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||
$ProxyEnv = @()
|
||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||
$HfUrls = @(
|
||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||
)
|
||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||
foreach ($Url in $HfUrls) {
|
||||
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||
}
|
||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||
Info 'Importando modelo en Ollama...'
|
||||
docker cp "$Gguf" d0a1-hermes-ollama:/root/.ollama/import.gguf
|
||||
docker exec d0a1-hermes-ollama sh -c 'printf "FROM /root/.ollama/import.gguf\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
$CreateOk = ($LASTEXITCODE -eq 0)
|
||||
docker exec d0a1-hermes-ollama rm -f /root/.ollama/import.gguf | Out-Null
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
$PullOk = $CreateOk
|
||||
if (-not $CreateOk) { Err 'Fallo al importar el modelo desde el GGUF.' }
|
||||
} else {
|
||||
# Ultimo recurso: pull directo (1 intento, ya sin esperar 3 rondas)
|
||||
Warn 'HuggingFace no accesible. Probando el registry de Ollama (ultimo recurso)...'
|
||||
docker exec @ProxyEnv d0a1-hermes-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$PullOk = $true
|
||||
# Contexto ampliado (el default 4096 da 400 en Open WebUI con prompts largos)
|
||||
docker exec d0a1-hermes-ollama sh -c 'printf "FROM llama3.2:3b\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
}
|
||||
}
|
||||
if (-not $PullOk) {
|
||||
Err 'No se pudo descargar el modelo (ni HuggingFace ni registry).'
|
||||
if (-not $env:HTTPS_PROXY) {
|
||||
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
|
||||
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
|
||||
Write-Host ' .\deploy.ps1 vps'
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
docker exec d0a1-hermes-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
|
||||
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
||||
|
||||
# --- 2. Instalar Hermes Agent ------------------------------------------------
|
||||
|
||||
+4
-50
@@ -65,8 +65,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
}
|
||||
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
|
||||
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
|
||||
$null = cmd /c "docker info >NUL 2>&1"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
if (-not (cmd /c "docker info >NUL 2>&1")) {
|
||||
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
|
||||
exit 1
|
||||
}
|
||||
@@ -80,9 +79,6 @@ if ($TotalRamGb -lt 3.5) {
|
||||
}
|
||||
Ok "RAM: $TotalRamGb GB"
|
||||
|
||||
# --- Tumbar deploy previo (antes de detectar puertos) -----------------------
|
||||
cmd /c docker rm -f d0a1-openclaw-ollama '>' NUL '2>&1'
|
||||
|
||||
# --- Auto-detect Ollama port ------------------------------------------------
|
||||
$OllamaPort = Find-FreePort 11434
|
||||
|
||||
@@ -91,7 +87,7 @@ if ($Mode -eq 'vps') {
|
||||
Write-Host ''
|
||||
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/vultr/${NC} - Vultr"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
|
||||
Write-Host ''
|
||||
}
|
||||
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
|
||||
@@ -124,50 +120,8 @@ while ($true) {
|
||||
}
|
||||
}
|
||||
Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
|
||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||
$ProxyEnv = @()
|
||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||
$HfUrls = @(
|
||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||
)
|
||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||
foreach ($Url in $HfUrls) {
|
||||
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||
}
|
||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||
Info 'Importando modelo en Ollama...'
|
||||
docker cp "$Gguf" d0a1-openclaw-ollama:/root/.ollama/import.gguf
|
||||
docker exec d0a1-openclaw-ollama sh -c 'printf "FROM /root/.ollama/import.gguf\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
$CreateOk = ($LASTEXITCODE -eq 0)
|
||||
docker exec d0a1-openclaw-ollama rm -f /root/.ollama/import.gguf | Out-Null
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
$PullOk = $CreateOk
|
||||
if (-not $CreateOk) { Err 'Fallo al importar el modelo desde el GGUF.' }
|
||||
} else {
|
||||
# Ultimo recurso: pull directo (1 intento, ya sin esperar 3 rondas)
|
||||
Warn 'HuggingFace no accesible. Probando el registry de Ollama (ultimo recurso)...'
|
||||
docker exec @ProxyEnv d0a1-openclaw-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$PullOk = $true
|
||||
# Contexto ampliado (el default 4096 da 400 en Open WebUI con prompts largos)
|
||||
docker exec d0a1-openclaw-ollama sh -c 'printf "FROM llama3.2:3b\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
}
|
||||
}
|
||||
if (-not $PullOk) {
|
||||
Err 'No se pudo descargar el modelo (ni HuggingFace ni registry).'
|
||||
if (-not $env:HTTPS_PROXY) {
|
||||
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
|
||||
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
|
||||
Write-Host ' .\deploy.ps1 vps'
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
docker exec d0a1-openclaw-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
|
||||
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
||||
|
||||
# --- 2. Instalar OpenClaw -----------------------------------------------------
|
||||
|
||||
+5
-57
@@ -63,8 +63,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
}
|
||||
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
|
||||
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
|
||||
$null = cmd /c "docker info >NUL 2>&1"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
if (-not (cmd /c "docker info >NUL 2>&1")) {
|
||||
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
|
||||
exit 1
|
||||
}
|
||||
@@ -86,11 +85,6 @@ if ($TotalRamGb -lt 3.5) {
|
||||
}
|
||||
Ok "RAM: $TotalRamGb GB"
|
||||
|
||||
# --- Tumbar deploy previo (antes de detectar puertos) ----------------------
|
||||
# Mantiene los volumenes (el modelo ya descargado no se re-descarga) y libera
|
||||
# los puertos para que Find-FreePort vea el estado REAL tras el down.
|
||||
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
||||
|
||||
# --- Auto-detect ports ----------------------------------------------------
|
||||
$OllamaPort = Find-FreePort 11434
|
||||
$WebUiPort = Find-FreePort 3000
|
||||
@@ -101,19 +95,15 @@ if ($Mode -eq 'local') {
|
||||
Write-Host " URL: ${Cyan}http://localhost:${WebUiPort}${NC}"
|
||||
} else {
|
||||
Warn 'Modo: VPS (accesible desde fuera)'
|
||||
# IP real de LAN: la de la interfaz con la ruta por defecto (evita vEthernet
|
||||
# WSL/Hyper-V, Docker, VPN — que son 172.16-31.*, 10.x internos, etc.)
|
||||
$GwIf = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue |
|
||||
Sort-Object RouteMetric | Select-Object -First 1).ifIndex
|
||||
$Ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.ifIndex -eq $GwIf -and $_.IPAddress -notlike '127.*' } |
|
||||
Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' } |
|
||||
Select-Object -First 1).IPAddress
|
||||
if (-not $Ip) { $Ip = 'TU_IP' }
|
||||
Write-Host " URL: ${Cyan}http://${Ip}:${WebUiPort}${NC}"
|
||||
Write-Host ''
|
||||
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/vultr/${NC} - Vultr"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
|
||||
}
|
||||
|
||||
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
|
||||
@@ -141,50 +131,8 @@ while ($true) {
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||
$ProxyEnv = @()
|
||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||
$HfUrls = @(
|
||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||
)
|
||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||
foreach ($Url in $HfUrls) {
|
||||
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||
}
|
||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||
Info 'Importando modelo en Ollama...'
|
||||
docker cp "$Gguf" d0a1-ollama:/root/.ollama/import.gguf
|
||||
docker exec d0a1-ollama sh -c 'printf "FROM /root/.ollama/import.gguf\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
$CreateOk = ($LASTEXITCODE -eq 0)
|
||||
docker exec d0a1-ollama rm -f /root/.ollama/import.gguf | Out-Null
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
$PullOk = $CreateOk
|
||||
if (-not $CreateOk) { Err 'Fallo al importar el modelo desde el GGUF.' }
|
||||
} else {
|
||||
# Ultimo recurso: pull directo (1 intento, ya sin esperar 3 rondas)
|
||||
Warn 'HuggingFace no accesible. Probando el registry de Ollama (ultimo recurso)...'
|
||||
docker exec @ProxyEnv d0a1-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$PullOk = $true
|
||||
# Contexto ampliado (el default 4096 da 400 en Open WebUI con prompts largos)
|
||||
docker exec d0a1-ollama sh -c 'printf "FROM llama3.2:3b\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
}
|
||||
}
|
||||
if (-not $PullOk) {
|
||||
Err 'No se pudo descargar el modelo (ni HuggingFace ni registry).'
|
||||
if (-not $env:HTTPS_PROXY) {
|
||||
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
|
||||
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
|
||||
Write-Host ' .\deploy.ps1 vps'
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
docker exec d0a1-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
|
||||
|
||||
# --- Done -------------------------------------------------------------------
|
||||
Write-Host ''
|
||||
|
||||
+5
-56
@@ -63,8 +63,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
}
|
||||
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
|
||||
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
|
||||
$null = cmd /c "docker info >NUL 2>&1"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
if (-not (cmd /c "docker info >NUL 2>&1")) {
|
||||
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
|
||||
exit 1
|
||||
}
|
||||
@@ -120,9 +119,6 @@ if (-not (Test-Path $EnvFile)) {
|
||||
}
|
||||
|
||||
# --- Auto-detect ports ----------------------------------------------------
|
||||
# --- Tumbar deploy previo (antes de detectar puertos) ----------------------
|
||||
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
||||
|
||||
$OllamaPort = Find-FreePort 11434
|
||||
$WpPort = Find-FreePort 8080
|
||||
$WebUiPort = Find-FreePort 3000
|
||||
@@ -134,12 +130,8 @@ if ($Mode -eq 'local') {
|
||||
Write-Host " IA (chat): ${Cyan}http://localhost:${WebUiPort}${NC}"
|
||||
} else {
|
||||
Warn 'Modo: VPS (accesible desde fuera)'
|
||||
# IP real de LAN: la de la interfaz con la ruta por defecto (evita
|
||||
# vEthernet WSL/Hyper-V, Docker, VPN)
|
||||
$GwIf = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue |
|
||||
Sort-Object RouteMetric | Select-Object -First 1).ifIndex
|
||||
$Ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.ifIndex -eq $GwIf -and $_.IPAddress -notlike '127.*' } |
|
||||
Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' } |
|
||||
Select-Object -First 1).IPAddress
|
||||
if (-not $Ip) { $Ip = 'TU_IP' }
|
||||
Write-Host " WordPress: ${Cyan}http://${Ip}:${WpPort}${NC}"
|
||||
@@ -147,7 +139,7 @@ if ($Mode -eq 'local') {
|
||||
Write-Host ''
|
||||
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/vultr/${NC} - Vultr"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
|
||||
}
|
||||
|
||||
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
|
||||
@@ -157,7 +149,6 @@ Write-Host ''
|
||||
|
||||
# --- Deploy ----------------------------------------------------------------
|
||||
Warn 'Descargando contenedores (3-5 min la primera vez)...'
|
||||
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
||||
$env:OLLAMA_PORT = "$OllamaPort"
|
||||
$env:WP_PORT = "$WpPort"
|
||||
$env:WEBUI_PORT = "$WebUiPort"
|
||||
@@ -178,50 +169,8 @@ while ($true) {
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||
$ProxyEnv = @()
|
||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||
$HfUrls = @(
|
||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||
)
|
||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||
foreach ($Url in $HfUrls) {
|
||||
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||
}
|
||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||
Info 'Importando modelo en Ollama...'
|
||||
docker cp "$Gguf" d0a1-wp-ollama:/root/.ollama/import.gguf
|
||||
docker exec d0a1-wp-ollama sh -c 'printf "FROM /root/.ollama/import.gguf\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
$CreateOk = ($LASTEXITCODE -eq 0)
|
||||
docker exec d0a1-wp-ollama rm -f /root/.ollama/import.gguf | Out-Null
|
||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||
$PullOk = $CreateOk
|
||||
if (-not $CreateOk) { Err 'Fallo al importar el modelo desde el GGUF.' }
|
||||
} else {
|
||||
# Ultimo recurso: pull directo (1 intento, ya sin esperar 3 rondas)
|
||||
Warn 'HuggingFace no accesible. Probando el registry de Ollama (ultimo recurso)...'
|
||||
docker exec @ProxyEnv d0a1-wp-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$PullOk = $true
|
||||
# Contexto ampliado (el default 4096 da 400 en Open WebUI con prompts largos)
|
||||
docker exec d0a1-wp-ollama sh -c 'printf "FROM llama3.2:3b\\nPARAMETER num_ctx 16384\\n" > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
|
||||
}
|
||||
}
|
||||
if (-not $PullOk) {
|
||||
Err 'No se pudo descargar el modelo (ni HuggingFace ni registry).'
|
||||
if (-not $env:HTTPS_PROXY) {
|
||||
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
|
||||
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
|
||||
Write-Host ' .\deploy.ps1 vps'
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
docker exec d0a1-wp-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
|
||||
|
||||
# --- Done -------------------------------------------------------------------
|
||||
Write-Host ''
|
||||
|
||||
Reference in new issue
Block a user