param( [int]$Port = 7863, [string]$ServerName = "127.0.0.1", [string]$VllmUrl = "https://veronicaulises0--virtual-characters-vllm-gemma-serve.modal.run", [string]$TtsUrl = "https://veronicaulises0--virtual-characters-tts-charactertts-tts.modal.run", [switch]$Mock ) $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot $python = Join-Path $repoRoot ".venv\Scripts\python.exe" if (-not (Test-Path $python)) { $python = "python" } $logsDir = Join-Path $repoRoot ".logs" New-Item -ItemType Directory -Force -Path $logsDir | Out-Null $stamp = Get-Date -Format "yyyyMMdd-HHmmss" $stdout = Join-Path $logsDir "gradio-$Port-$stamp.out.log" $stderr = Join-Path $logsDir "gradio-$Port-$stamp.err.log" $env:VC_GRADIO_PORT = "$Port" $env:VC_GRADIO_SERVER_NAME = $ServerName $env:VC_MODAL_VLLM_URL = $VllmUrl if ($TtsUrl) { $env:VC_MODAL_TTS_URL = $TtsUrl } else { Remove-Item Env:\VC_MODAL_TTS_URL -ErrorAction SilentlyContinue } $env:PYTHONIOENCODING = "utf-8" $env:PYTHONUTF8 = "1" $env:PYTHONDONTWRITEBYTECODE = "1" if ($Mock) { $env:VC_USE_MOCK = "1" } elseif ($env:VC_USE_MOCK -ne "1") { Remove-Item Env:\VC_USE_MOCK -ErrorAction SilentlyContinue } Remove-Item Env:\VC_MODAL_LLM_URL -ErrorAction SilentlyContinue $process = Start-Process ` -FilePath $python ` -ArgumentList "-B", "app.py" ` -WorkingDirectory $repoRoot ` -RedirectStandardOutput $stdout ` -RedirectStandardError $stderr ` -WindowStyle Hidden ` -PassThru [ordered]@{ pid = $process.Id url = "http://$ServerName`:$Port" stdout = $stdout stderr = $stderr vllm_url = $VllmUrl tts_url = $TtsUrl mock = [bool]$Mock } | ConvertTo-Json