Filter audio models out of chat-facing /v1/models (visible to API users only)
This commit is contained in:
1 parent
c7ed245939
commit
54fa4d3fc2
1 file changed
+18
+18
@@ -1188,6 +1188,24 @@ async def list_models(request: Request):
|
|||||||
)
|
)
|
||||||
|
|
||||||
payload = r.json()
|
payload = r.json()
|
||||||
|
|
||||||
|
# Chat-list filter: exclude audio-only models (STT/TTS). They are
|
||||||
|
# registered and callable via /v1/audio/* for API users, but they are
|
||||||
|
# not chat models — listing them in Open WebUI would just confuse
|
||||||
|
# members. The gateway's model_info carries `mode` for audio models;
|
||||||
|
# fall back to a name check for safety.
|
||||||
|
audio_modes = {"audio_transcription", "audio_speech"}
|
||||||
|
audio_name_hints = ("whisper", "voxtral", "tts")
|
||||||
|
|
||||||
|
def is_audio_model(m) -> bool:
|
||||||
|
mode = ((m.get("info") or {}).get("meta") or {}).get("mode") or ""
|
||||||
|
if mode in audio_modes:
|
||||||
|
return True
|
||||||
|
mid = (m.get("id") or "").lower()
|
||||||
|
return any(h in mid for h in audio_name_hints)
|
||||||
|
|
||||||
|
payload["data"] = [m for m in payload.get("data", []) if not is_audio_model(m)]
|
||||||
|
|
||||||
for model in payload.get("data", []):
|
for model in payload.get("data", []):
|
||||||
model.setdefault("info", {}).setdefault("meta", {})
|
model.setdefault("info", {}).setdefault("meta", {})
|
||||||
model["info"]["meta"].setdefault("capabilities", {})["web_search"] = True
|
model["info"]["meta"].setdefault("capabilities", {})["web_search"] = True
|
||||||
|
|||||||
Reference in new issue
Block a user