Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,14 @@ def call_mistral_api(prompt, hf_token=HF_TOKEN):
|
|
15 |
API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2"
|
16 |
headers = {"Authorization": f"Bearer {hf_token}"}
|
17 |
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 300}}
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
# Chargement du modèle de sentiment
|
|
|
15 |
API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2"
|
16 |
headers = {"Authorization": f"Bearer {hf_token}"}
|
17 |
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 300}}
|
18 |
+
|
19 |
+
try:
|
20 |
+
response = requests.post(API_URL, headers=headers, json=payload, timeout=60)
|
21 |
+
response.raise_for_status()
|
22 |
+
return response.json()[0]["generated_text"]
|
23 |
+
except Exception as e:
|
24 |
+
return f"[ERREUR_API]: {e}"
|
25 |
+
|
26 |
|
27 |
|
28 |
# Chargement du modèle de sentiment
|