67 lines
1.9 KiB
PowerShell
67 lines
1.9 KiB
PowerShell
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[ValidateSet("Claude", "OpenAI")]
|
|
[string]$Model
|
|
)
|
|
|
|
function Run-PythonScript {
|
|
param($ScriptPath)
|
|
$process = Start-Process -FilePath "python" -ArgumentList $ScriptPath -PassThru -Wait -NoNewWindow
|
|
return $process.ExitCode
|
|
}
|
|
|
|
function Run-Tests {
|
|
$process = Start-Process -FilePath "powershell" -ArgumentList "-File run_tests.ps1" -PassThru -Wait -NoNewWindow
|
|
return $process.ExitCode
|
|
}
|
|
|
|
function Git-Pull {
|
|
git pull
|
|
return $LASTEXITCODE -eq 0
|
|
}
|
|
|
|
if ($Model -eq "Claude") {
|
|
New-Item -ItemType File -Path ".reboot_claude" -Force
|
|
} elseif ($Model -eq "OpenAI") {
|
|
New-Item -ItemType File -Path ".reboot_openai" -Force
|
|
}
|
|
|
|
$waitTime = 30
|
|
while ($true) {
|
|
python -m pip install -r requirements.txt
|
|
|
|
Write-Host "Running tests..."
|
|
$testExitCode = Run-Tests
|
|
if ($testExitCode -ne 0) {
|
|
Write-Host "Tests failed. Attempting git pull and waiting $waitTime seconds before next attempt..."
|
|
Git-Pull
|
|
Start-Sleep -Seconds $waitTime
|
|
continue
|
|
}
|
|
|
|
$scriptPath = ".\chatgpt_telegram_inference_bot.py" # Default to ChatGPT
|
|
Remove-Item -Path ".\.reboot_openai" -Force
|
|
|
|
if (Test-Path -Path ".\.reboot_claude") { # But if both are specified, choose Claude
|
|
$scriptPath = ".\anthropic_telegram_inference_bot.py"
|
|
Remove-Item -Path ".\.reboot_claude" -Force
|
|
}
|
|
|
|
Write-Host "Tests passed. Starting main Python script..."
|
|
$exitCode = Run-PythonScript -ScriptPath $scriptPath
|
|
|
|
if (Test-Path -Path ".\.doreboot") {
|
|
Write-Host "Special filename detected. Attempting git pull..."
|
|
|
|
if (Git-Pull) {
|
|
Write-Host "Git pull successful. Restarting Python script..."
|
|
continue
|
|
} else {
|
|
Write-Host "Git pull failed. Waiting $waitTime seconds before next attempt..."
|
|
}
|
|
} else {
|
|
exit 1
|
|
}
|
|
|
|
Start-Sleep -Seconds $waitTime
|
|
} |