diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1576078 --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +# Copy to `.env` (gitignored) for host-specific overrides. run.sh / run.ps1 load it. +# Only set what you need — every value has a sane default in router.py. + +# ComfyUI image generation — point at wherever ComfyUI runs (another box is fine): +ROUTER_COMFYUI=http://comfyui-host.example:8188 +ROUTER_COMFY_CHECKPOINT=your_model.safetensors + +# Bind / networking (defaults shown): +# ROUTER_HOST=0.0.0.0 +# ROUTER_OLLAMA=http://127.0.0.1:11434 + +# Audio model for /v1/audio/* (must have 'audio' capability): +# ROUTER_AUDIO_MODEL=gemma4:e4b diff --git a/.gitignore b/.gitignore index d22d32f..8a343dc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ .apikey .uncensored_key +# local host-specific config +.env + # python / venv .venv/ __pycache__/ diff --git a/docs/IMAGES.md b/docs/IMAGES.md index e6b21b9..5e10d5f 100644 --- a/docs/IMAGES.md +++ b/docs/IMAGES.md @@ -13,6 +13,10 @@ in OpenAI's image-response shape — so any OpenAI image client works. | `ROUTER_COMFY_CHECKPOINT` | *(unset)* | your checkpoint filename, e.g. `sd_xl_base_1.0.safetensors` | | `ROUTER_COMFY_WORKFLOW` | `comfyui-workflow.json` | the workflow template (see below) | +Set these in a **`.env`** file (gitignored; copy `.env.example`) — `run.sh` / +`run.ps1` load it on start. **ComfyUI can run on another machine** — just point at +it, e.g. `ROUTER_COMFYUI=http://valhalla:8188`. + At minimum, **set `ROUTER_COMFY_CHECKPOINT`** to a model that exists in your ComfyUI (`ComfyUI/models/checkpoints/`), or hardcode it into the template's `ckpt_name`. Then restart the router. diff --git a/run.ps1 b/run.ps1 index 657404b..0f58e4d 100644 --- a/run.ps1 +++ b/run.ps1 @@ -3,6 +3,14 @@ $ErrorActionPreference = "Stop" Set-Location $PSScriptRoot +# optional local config (host-specific env vars, kept out of git — see .env.example) +if (Test-Path ".env") { + Get-Content ".env" | Where-Object { $_ -match '^\s*[^#=]+=' } | ForEach-Object { + $k, $v = $_ -split '=', 2 + [Environment]::SetEnvironmentVariable($k.Trim(), $v.Trim(), 'Process') + } +} + # load keys from files into env (kept out of git) if (Test-Path ".apikey") { $env:ROUTER_API_KEY = (Get-Content ".apikey" -Raw).Trim() } if (Test-Path ".uncensored_key") { $env:ROUTER_UNCENSORED_KEY = (Get-Content ".uncensored_key" -Raw).Trim() } diff --git a/run.sh b/run.sh index 4cfa6aa..cc98006 100755 --- a/run.sh +++ b/run.sh @@ -5,6 +5,9 @@ set -uo pipefail cd "$(dirname "$0")" export PATH="/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH:-}" +# optional local config (host-specific env vars, kept out of git — see .env.example) +[ -f .env ] && { set -a; . ./.env; set +a; } + # clear any stale instances via recorded PIDs (never pattern-match — that can # match unrelated processes, including a shell that merely mentions "router.py") for pf in .litellm.pid .router.pid; do