From 1670f573770600cb66963d98a4dd6d8b726ca0e8 Mon Sep 17 00:00:00 2001 From: Folzo Date: Mon, 20 Jul 2026 12:07:08 +0200 Subject: [PATCH] fix: restore get_ollama_models() function body The function was accidentally truncated when adding get_jean_context_lengths(). This caused TypeError: 'NoneType' object is not iterable in list_models(). --- jean-router/app.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jean-router/app.py b/jean-router/app.py index 928a30b..3586e1c 100644 --- a/jean-router/app.py +++ b/jean-router/app.py @@ -74,6 +74,19 @@ def get_ollama_models(force_refresh=False): if not force_refresh and ollama_cache["data"] and (now - ollama_cache["timestamp"]) < CACHE_TTL: return ollama_cache["data"] + try: + url = f"http://{OLLAMA_PROXY_HOST}:{OLLAMA_PROXY_PORT}/api/tags" + r = requests.get(url, timeout=3) + if r.ok: + data = r.json().get("models", []) + ollama_cache["data"] = data + ollama_cache["timestamp"] = now + return data + except Exception as e: + log.warning(f"[Ollama] Erreur récupération: {e}") + + return ollama_cache["data"] + def get_jean_context_lengths(): """Récupère les context_length depuis Jean /v1/models (avec cache)"""