Mahdi Naser Moghadasi commited on
Commit ·
ea9aa79
1
Parent(s): d932c24
Fix HF Inference API endpoint - use router.huggingface.co/v1 with Llama-3.1-70B
Browse files
app.py
CHANGED
|
@@ -27,8 +27,8 @@ APP_SECRET_KEY = os.environ.get("appkey", "") # Key iOS app sends
|
|
| 27 |
HF_TOKEN = os.environ.get("HF_TOKEN", "") # Hugging Face API token
|
| 28 |
RATE_LIMIT_PER_MINUTE = int(os.environ.get("RATE_LIMIT_PER_MINUTE", "30"))
|
| 29 |
|
| 30 |
-
# LLM Model
|
| 31 |
-
LLM_MODEL = "
|
| 32 |
|
| 33 |
# ============================================
|
| 34 |
# RATE LIMITING
|
|
@@ -213,8 +213,8 @@ def call_llm(system_prompt: str, user_message: str, max_tokens: int = 2000) -> s
|
|
| 213 |
raise HTTPException(status_code=500, detail="LLM not configured")
|
| 214 |
|
| 215 |
try:
|
| 216 |
-
# Use
|
| 217 |
-
API_URL =
|
| 218 |
|
| 219 |
headers = {
|
| 220 |
"Authorization": f"Bearer {HF_TOKEN}",
|
|
|
|
| 27 |
HF_TOKEN = os.environ.get("HF_TOKEN", "") # Hugging Face API token
|
| 28 |
RATE_LIMIT_PER_MINUTE = int(os.environ.get("RATE_LIMIT_PER_MINUTE", "30"))
|
| 29 |
|
| 30 |
+
# LLM Model - Using a reliable model available on HF Inference API
|
| 31 |
+
LLM_MODEL = "meta-llama/Llama-3.1-70B-Instruct"
|
| 32 |
|
| 33 |
# ============================================
|
| 34 |
# RATE LIMITING
|
|
|
|
| 213 |
raise HTTPException(status_code=500, detail="LLM not configured")
|
| 214 |
|
| 215 |
try:
|
| 216 |
+
# Use HuggingFace Inference API with OpenAI-compatible endpoint
|
| 217 |
+
API_URL = "https://router.huggingface.co/v1/chat/completions"
|
| 218 |
|
| 219 |
headers = {
|
| 220 |
"Authorization": f"Bearer {HF_TOKEN}",
|