#!/usr/bin/env bash # One-time setup: create the Python 3.12 venv and install LiteLLM + Pillow. # The pre-router itself needs no venv (stdlib only); this is for the backend proxy. set -euo pipefail cd "$(dirname "$0")/.." PY="${PYTHON:-python3.12}" if ! command -v "$PY" >/dev/null 2>&1; then # common macOS Homebrew fallback [ -x /opt/homebrew/opt/python@3.12/bin/python3.12 ] && PY=/opt/homebrew/opt/python@3.12/bin/python3.12 fi command -v "$PY" >/dev/null 2>&1 || { echo "Need Python 3.12. Set \$PYTHON, or:"; \ echo " macOS: brew install python@3.12"; echo " Linux: install python3.12"; exit 1; } echo ">> using $($PY --version) at $(command -v "$PY" 2>/dev/null || echo "$PY")" [ -d .venv ] || "$PY" -m venv .venv .venv/bin/pip install -q --upgrade pip .venv/bin/pip install -q -r requirements.txt .venv/bin/python -c "import litellm, PIL" && echo ">> deps OK (litellm, pillow)" # preflight: Ollama (the model backend) if command -v ollama >/dev/null 2>&1; then echo ">> ollama: $(ollama --version 2>/dev/null | head -1)" if .venv/bin/python -c "import urllib.request; urllib.request.urlopen('${ROUTER_OLLAMA:-http://127.0.0.1:11434}/api/version', timeout=3)" 2>/dev/null; then echo ">> ollama server: reachable ($(ollama list 2>/dev/null | tail -n +2 | grep -c .) models pulled)" else echo "!! ollama installed but not responding — start it: (macOS) open -a Ollama (Linux) ollama serve" fi else echo "!! ollama NOT installed (required backend). Install:" echo " macOS: brew install ollama Linux: curl -fsSL https://ollama.com/install.sh | sh" fi command -v curl >/dev/null 2>&1 || echo "!! curl not found — run.sh uses it for health checks; install curl." echo "" echo "Next:" echo " ./scripts/pull-models.sh # pull a model fleet (edit the list first)" echo " ./run.sh # start LiteLLM + router"