fix(mellea): restore vLLM probe with auth header + non-5xx check
Browse files381 unmodified lines382383384385386387381 unmodified lines_first_token_timeout = int(os.environ.get("RIPRAP_FIRST_TOKEN_TIMEOUT_S", "400"))_inter_token_timeout = int(os.environ.get("RIPRAP_TOKEN_TIMEOUT_S", "45"))for attempt_idx in range(loop_budget):attempts = attempt_idx + 1# On reroll, append a tight feedback message naming what failed AND381 unmodified lines382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419381 unmodified lines_first_token_timeout = int(os.environ.get("RIPRAP_FIRST_TOKEN_TIMEOUT_S", "400"))_inter_token_timeout = int(os.environ.get("RIPRAP_TOKEN_TIMEOUT_S", "45"))# When PRIMARY=vllm, RunPod cold-starts take ~250-360s (container boot +# model load). The pod starts when the warmup request hits the proxy, but# the proxy returns 503 immediately. LiteLLM would fall back to Ollama and# fail before RunPod is ready. Poll /v1/models here (after specialists, but# before generation) and wait — keepalives keep the SSE connection alive._vllm_base = os.environ.get("RIPRAP_LLM_BASE_URL", "").rstrip("/")if os.environ.get("RIPRAP_LLM_PRIMARY", "ollama") == "vllm" and _vllm_base:try:import httpx as _httpx_probe_url = f"{_vllm_base}/models"_probe_key = os.environ.get("RIPRAP_LLM_API_KEY", "") or "EMPTY"_probe_headers = {"Authorization": f"Bearer {_probe_key}"}_probe_deadline = t0 + _first_token_timeoutlog.info("mellea: polling vLLM readiness at %s", _probe_url)while time.time() < _probe_deadline:try:_r = _httpx.get(_probe_url, headers=_probe_headers, timeout=5.0)# Any non-503/502/504 means the service is UP (200 = ready,# 401 = auth-gated but alive, 404 = wrong path but alive).if _r.status_code not in (502, 503, 504):log.info("mellea: vLLM ready (status=%d, %.1fs elapsed)",_r.status_code, time.time() - t0)breakexcept Exception as _pe:log.debug("mellea: vLLM probe: %r", _pe)time.sleep(10)else:log.warning("mellea: vLLM not ready after %.1fs, proceeding anyway",time.time() - t0)except ImportError:log.warning("mellea: httpx not available, skipping vLLM probe")for attempt_idx in range(loop_budget):attempts = attempt_idx + 1# On reroll, append a tight feedback message naming what failed AND
app/mellea_validator.py+32