Public Access
Contournement de la panne DNS Hugging Face via le nouveau routeur
Build and Push Docker Image / build-and-push (push) Successful in 38s
Build and Push Docker Image / build-and-push (push) Successful in 38s
This commit is contained in:
1 parent
909a4efb11
commit
aa0190d218
1 file changed
+3
-3
+3
-3
@@ -54,7 +54,7 @@ def generer_image_huggingface(prompt: str) -> tuple:
|
|||||||
api_key = os.getenv("HUGGINGFACE_API_KEY")
|
api_key = os.getenv("HUGGINGFACE_API_KEY")
|
||||||
if not api_key: return None, "Clé API manquante"
|
if not api_key: return None, "Clé API manquante"
|
||||||
|
|
||||||
url = "https://router.huggingface.co/hf-inference/models/stabilityai/stable-diffusion-xl-base-1.0"
|
url = "https://router.huggingface.co/hf-inference/models/black-forest-labs/FLUX.1-schnell"
|
||||||
headers = {"Authorization": f"Bearer {api_key}"}
|
headers = {"Authorization": f"Bearer {api_key}"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -119,14 +119,14 @@ def generer_les_images(prompt: str, fichiers: list, premium: bool) -> tuple:
|
|||||||
if img_hf:
|
if img_hf:
|
||||||
nom_hf = f"img_hf_{int(time.time())}.png"
|
nom_hf = f"img_hf_{int(time.time())}.png"
|
||||||
with open(os.path.join(dossier_media, nom_hf), 'wb') as f: f.write(img_hf)
|
with open(os.path.join(dossier_media, nom_hf), 'wb') as f: f.write(img_hf)
|
||||||
reponse_md += f"### 🤗 HuggingFace (SDXL)\n\n"
|
reponse_md += f"### 🤗 HuggingFace (FLUX.1)\n\n"
|
||||||
reponse_md += f"**[📥 Télécharger l'image HF](/Media/{nom_hf})**\n\n"
|
reponse_md += f"**[📥 Télécharger l'image HF](/Media/{nom_hf})**\n\n"
|
||||||
fournisseurs_actifs.append("HuggingFace")
|
fournisseurs_actifs.append("HuggingFace")
|
||||||
trace.append("🟢 HF : Succès")
|
trace.append("🟢 HF : Succès")
|
||||||
else:
|
else:
|
||||||
erreur_courte = str(msg_hf)[:50] + "..." if len(str(msg_hf)) > 50 else str(msg_hf)
|
erreur_courte = str(msg_hf)[:50] + "..." if len(str(msg_hf)) > 50 else str(msg_hf)
|
||||||
trace.append(f"🔴 HF : Échec ({erreur_courte})")
|
trace.append(f"🔴 HF : Échec ({erreur_courte})")
|
||||||
reponse_md += f"### 🤗 HuggingFace (SDXL)\n*⚠️ Échec de la génération : {msg_hf}*\n\n"
|
reponse_md += f"### 🤗 HuggingFace (FLUX.1)\n*⚠️ Échec de la génération : {msg_hf}*\n\n"
|
||||||
|
|
||||||
if not img_or and not img_cf and not img_hf:
|
if not img_or and not img_cf and not img_hf:
|
||||||
return "*Échec critique : Aucune API n'a pu générer d'image.*", "#ff4444", "Système", "Erreur", trace
|
return "*Échec critique : Aucune API n'a pu générer d'image.*", "#ff4444", "Système", "Erreur", trace
|
||||||
|
|||||||
Reference in new issue
Block a user