2 changed files with 9 additions and 1 deletions

No files matched your search

+3
View File
@@ -56,3 +56,6 @@ SECURITY_REVIEW.md
Thumbs.db
*.sass-cache
coverage/
# Secrets locaux
.github-token.txt
+6 -1
View File
@@ -84,7 +84,12 @@ def list_model_ids() -> list[str]:
"""Modèles accessibles avec la clé en place (GitHub Models : catalogue dédié, /models n'est pas OpenAI-compatible)."""
client = get_client()
if "models.github.ai" in str(client.base_url):
return sorted(m["id"] for m in client.get(GITHUB_CATALOG_URL, cast_to=object))
raw = client.get(GITHUB_CATALOG_URL, cast_to=object)
if isinstance(raw, (str, bytes)): # content-type non-JSON : le SDK rend le texte brut
raw = json.loads(raw)
if isinstance(raw, dict):
raw = next((v for v in raw.values() if isinstance(v, list)), [])
return sorted(m["id"] if isinstance(m, dict) else str(m) for m in raw)
return sorted(m.id for m in client.models.list().data)