Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5679940fa7 | ||
|
|
51d91b91c4 |
@@ -8,6 +8,7 @@ Supporte Mistral AI (par défaut) et tout fournisseur compatible OpenAI.
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import httpx
|
||||||
from openai import OpenAI, BadRequestError
|
from openai import OpenAI, BadRequestError
|
||||||
from legal_framework import LEGAL_FILTER_PROMPT, SYNTHESIS_PROMPT, LAW_CHECK_PROMPT, build_filter_prompt
|
from legal_framework import LEGAL_FILTER_PROMPT, SYNTHESIS_PROMPT, LAW_CHECK_PROMPT, build_filter_prompt
|
||||||
from legifrance_client import get_legifrance_client
|
from legifrance_client import get_legifrance_client
|
||||||
@@ -84,9 +85,18 @@ 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)."""
|
"""Modèles accessibles avec la clé en place (GitHub Models : catalogue dédié, /models n'est pas OpenAI-compatible)."""
|
||||||
client = get_client()
|
client = get_client()
|
||||||
if "models.github.ai" in str(client.base_url):
|
if "models.github.ai" in str(client.base_url):
|
||||||
raw = client.get(GITHUB_CATALOG_URL, cast_to=object)
|
r = httpx.get(
|
||||||
if isinstance(raw, (str, bytes)): # content-type non-JSON : le SDK rend le texte brut
|
GITHUB_CATALOG_URL,
|
||||||
raw = json.loads(raw)
|
headers={
|
||||||
|
"Authorization": f"Bearer {client.api_key}",
|
||||||
|
"Accept": "application/vnd.github+json",
|
||||||
|
"X-GitHub-Api-Version": "2022-11-28",
|
||||||
|
},
|
||||||
|
timeout=10,
|
||||||
|
)
|
||||||
|
if r.status_code != 200 or not r.content:
|
||||||
|
raise RuntimeError(f"catalogue GitHub HTTP {r.status_code} : {r.text[:120]!r}")
|
||||||
|
raw = r.json()
|
||||||
if isinstance(raw, dict):
|
if isinstance(raw, dict):
|
||||||
raw = next((v for v in raw.values() if isinstance(v, list)), [])
|
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"] if isinstance(m, dict) else str(m) for m in raw)
|
||||||
|
|||||||
Reference in new issue
Block a user