Spaces:
Sleeping
Sleeping
Update model_api.py
Browse files- model_api.py +3 -1
model_api.py
CHANGED
|
@@ -2,7 +2,7 @@ import requests
|
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
|
| 5 |
-
API_URL = "https://
|
| 6 |
|
| 7 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 8 |
|
|
@@ -23,9 +23,11 @@ def query_model(prompt):
|
|
| 23 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 24 |
result = response.json()
|
| 25 |
|
|
|
|
| 26 |
if isinstance(result, list):
|
| 27 |
return result[0]["generated_text"]
|
| 28 |
|
|
|
|
| 29 |
if "estimated_time" in result:
|
| 30 |
time.sleep(result["estimated_time"])
|
| 31 |
else:
|
|
|
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
|
| 5 |
+
API_URL = "https://router.huggingface.co/hf-inference/models/mistralai/Mistral-7B-Instruct-v0.2"
|
| 6 |
|
| 7 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 8 |
|
|
|
|
| 23 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 24 |
result = response.json()
|
| 25 |
|
| 26 |
+
# Success response
|
| 27 |
if isinstance(result, list):
|
| 28 |
return result[0]["generated_text"]
|
| 29 |
|
| 30 |
+
# Model loading
|
| 31 |
if "estimated_time" in result:
|
| 32 |
time.sleep(result["estimated_time"])
|
| 33 |
else:
|