Bild-Weiche v2: stummen Fallback-except durch Logging ersetzen (Diagnose :9010)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-07-15 15:22:46 +02:00
parent 0eb2b37abc
commit 202e97333a
+6
View File
@@ -1,3 +1,4 @@
import logging
import os
from fastapi import APIRouter, Request
@@ -8,6 +9,8 @@ from services.gateway_stream import record_stream_chunk, record_usage, warn_trun
from services.router_logic import IMAGE_PART_TYPES, VISION_CAPABLE, choose_for_lane, has_image
from services.routing_policy import load_policy
log = logging.getLogger(__name__)
router = APIRouter(prefix="/v1")
# Antwortsprache für IDE-/Lane-Traffic: die Coding-Modelle antworten sonst englisch
@@ -65,8 +68,11 @@ async def _bilder_fuer_coder_beschreiben(body: dict, client, vision_alias: str)
if r.status_code == 200:
text = ((r.json().get("choices") or [{}])[0].get("message") or {}).get("content") or ""
if not text.strip():
log.warning("Bild-Weiche v2: Beschreibung leer/fehlgeschlagen (HTTP %s) — Fallback Umleitung. Body: %.200s",
r.status_code, r.text)
return False
except Exception:
log.warning("Bild-Weiche v2: Vision-Aufruf scheiterte — Fallback Umleitung", exc_info=True)
return False
msg["content"][idx] = {"type": "text", "text": (
f"[Bild {nr}: dem Request lag ein Bild bei — {vision_alias} beschreibt es so:\n"