Public Access
chore: Serveur 100% stable, ports corrigés, prêt pour le RAG
Build and Push Docker Image / build-and-push (push) Successful in 1m50s
Build and Push Docker Image / build-and-push (push) Successful in 1m50s
This commit is contained in:
1 parent
7125842853
commit
ffe820b00f
20 files changed
+7772
-198
No files matched your search
@@ -1,22 +0,0 @@
|
||||
import os
|
||||
from openai import OpenAI
|
||||
from modules.logger import log_event
|
||||
|
||||
def interroger_huggingface(prompt_securise):
|
||||
api_key = os.getenv("HF_API_KEY")
|
||||
if not api_key: raise Exception("Clé API HuggingFace manquante.")
|
||||
client = OpenAI(base_url="https://api-inference.huggingface.co/v1/", api_key=api_key)
|
||||
modeles = ["meta-llama/Meta-Llama-3-8B-Instruct", "mistralai/Mistral-7B-Instruct-v0.3"]
|
||||
for modele in modeles:
|
||||
try:
|
||||
resp = client.chat.completions.create(
|
||||
model=modele,
|
||||
messages=[{"role": "system", "content": "Réponds en français en Markdown."}, {"role": "user", "content": prompt_securise}],
|
||||
max_tokens=1500
|
||||
)
|
||||
if resp and resp.choices:
|
||||
log_event("INFO", f"HF-{modele}", "Succès.")
|
||||
return resp.choices[0].message.content, "#fbbf24", "HUGGINGFACE", modele
|
||||
except Exception as e:
|
||||
log_event("WARNING", f"HF-{modele}", f"Erreur: {e}")
|
||||
raise Exception("Tous les modèles HuggingFace ont échoué.")
|
||||
Reference in new issue
Block a user