Files
Leonid Pershin 2ab32a8ab5 Refactor LLM configuration to remove llamacpp support
- Removed references to llamacpp from configuration files, scripts, and documentation, streamlining the LLM setup process to focus solely on Ollama.
- Updated environment variables and paths to eliminate llamacpp-related entries, ensuring clarity in the configuration.
- Adjusted CLI commands and help messages to reflect the removal of llamacpp, enhancing user experience and reducing confusion.
- Revised documentation to provide clear guidance on using Ollama exclusively, including updates to setup instructions and runtime options.
2026-08-21 08:51:36 +03:00

137 lines
4.7 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#Requires -Version 5.1
# Windows launcher: venv + pip + python -m gpu_rent. Call via gpu-rent.bat if ExecutionPolicy blocks this file.
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location -LiteralPath $Root
try {
$utf8 = New-Object System.Text.UTF8Encoding $false
[Console]::OutputEncoding = $utf8
$script:OutputEncoding = $utf8
} catch {
}
function Import-GpuRentVars {
param([Parameter(Mandatory = $true)][string]$Path)
if (-not (Test-Path -LiteralPath $Path)) { return }
Get-Content -LiteralPath $Path -Encoding UTF8 | ForEach-Object {
$line = $_.Trim()
if (-not $line -or $line.StartsWith("#")) { return }
if ($line -match '^(?i)export\s+') {
$line = $line.Substring($Matches[0].Length).Trim()
}
$eq = $line.IndexOf("=")
if ($eq -lt 1) { return }
$key = $line.Substring(0, $eq).Trim()
$val = $line.Substring($eq + 1).Trim()
if ($val.Length -ge 2) {
$q = $val[0]
if (($q -eq '"' -or $q -eq "'") -and $val[-1] -eq $q) {
$val = $val.Substring(1, $val.Length - 2)
}
}
if (-not $key) { return }
$existing = [Environment]::GetEnvironmentVariable($key, "Process")
if ([string]::IsNullOrEmpty($existing)) {
Set-Item -Path "Env:$key" -Value $val
}
}
}
function Test-Python311 {
param(
[Parameter(Mandatory = $true)][string]$Exe,
[string[]]$Prefix = @()
)
$cmd = Get-Command $Exe -ErrorAction SilentlyContinue
if (-not $cmd) {
return $false
}
try {
& $Exe @Prefix -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)" 2>$null | Out-Null
return ($LASTEXITCODE -eq 0)
} catch {
return $false
}
}
$PyExe = $null
$PyPrefix = @()
$found = $false
foreach ($row in @(
@{ Exe = "py"; Prefix = @("-3.12") },
@{ Exe = "py"; Prefix = @("-3.11") },
@{ Exe = "py"; Prefix = @("-3") },
@{ Exe = "python3"; Prefix = @() },
@{ Exe = "python"; Prefix = @() }
)) {
if (Test-Python311 -Exe $row.Exe -Prefix $row.Prefix) {
$PyExe = $row.Exe
$PyPrefix = $row.Prefix
$found = $true
break
}
}
if (-not $found) {
Write-Host "gpu-rent: нужен Python 3.11+. Поставь с python.org и включи Add python.exe to PATH."
exit 1
}
$VenvPy = Join-Path $Root ".venv\Scripts\python.exe"
if (-not (Test-Path -LiteralPath $VenvPy)) {
Write-Host "gpu-rent: создаю .venv"
& $PyExe @PyPrefix -m venv (Join-Path $Root ".venv")
}
$Stamp = Join-Path $Root ".venv\.gpu-rent-installed"
$Pyproject = Join-Path $Root "pyproject.toml"
$needInstall = -not (Test-Path -LiteralPath $Stamp)
if (-not $needInstall -and (Test-Path -LiteralPath $Pyproject)) {
$needInstall = (Get-Item -LiteralPath $Pyproject).LastWriteTime -gt (Get-Item -LiteralPath $Stamp).LastWriteTime
}
if ($needInstall) {
Write-Host "gpu-rent: ставлю пакет в .venv"
& $VenvPy -m pip install -U pip
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& $VenvPy -m pip install -e $Root
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Get-Date -Format o | Set-Content -LiteralPath $Stamp -Encoding ascii
}
$EnvFile = Join-Path $Root ".env"
$Example = Join-Path $Root "env.example"
if (-not (Test-Path -LiteralPath $EnvFile)) {
if (Test-Path -LiteralPath $Example) {
Copy-Item -LiteralPath $Example -Destination $EnvFile
Write-Host "gpu-rent: created .env - fill OS_* (docs/setup.md)"
}
}
function Copy-IfMissing {
param([string]$Src, [string]$Dst, [string]$Label)
if ((Test-Path -LiteralPath $Src) -and -not (Test-Path -LiteralPath $Dst)) {
Copy-Item -LiteralPath $Src -Destination $Dst
Write-Host "gpu-rent: created $Label"
}
}
Copy-IfMissing (Join-Path $Root "models.example.yaml") (Join-Path $Root "models.yaml") "models.yaml"
Copy-IfMissing (Join-Path $Root "extensions.example.yaml") (Join-Path $Root "extensions.yaml") "extensions.yaml"
Copy-IfMissing (Join-Path $Root "ollama-models.example.yaml") (Join-Path $Root "ollama-models.yaml") "ollama-models.yaml"
Copy-IfMissing (Join-Path $Root "gpu-rent.vars.example") (Join-Path $Root "gpu-rent.vars") "gpu-rent.vars"
Import-GpuRentVars (Join-Path $Root "gpu-rent.vars")
$InvokeArgs = @($args)
if ($InvokeArgs.Count -eq 0 -and $env:GPU_RENT_DEFAULT_ARGS) {
$InvokeArgs = @($env:GPU_RENT_DEFAULT_ARGS -split '\s+' | Where-Object { $_ })
}
if ($env:GPU_RENT_EXTRA_ARGS) {
$InvokeArgs += @($env:GPU_RENT_EXTRA_ARGS -split '\s+' | Where-Object { $_ })
}
$ErrorActionPreference = "Continue"
& $VenvPy -m gpu_rent @InvokeArgs
exit $LASTEXITCODE