Spaces:
Sleeping
Sleeping
Upload api/server.py with huggingface_hub
Browse files- api/server.py +22 -0
api/server.py
CHANGED
|
@@ -62,5 +62,27 @@ def serve_ui():
|
|
| 62 |
return FileResponse(str(ui_file))
|
| 63 |
return HTMLResponse("<h1>UI not found</h1>")
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
if __name__ == "__main__":
|
| 66 |
uvicorn.run("api.server:app", host=API_HOST, port=API_PORT, reload=False)
|
|
|
|
| 62 |
return FileResponse(str(ui_file))
|
| 63 |
return HTMLResponse("<h1>UI not found</h1>")
|
| 64 |
|
| 65 |
+
|
| 66 |
+
@app.get("/test-llm")
|
| 67 |
+
def test_llm():
|
| 68 |
+
import requests, os
|
| 69 |
+
from config.settings import HF_TOKEN
|
| 70 |
+
results = {}
|
| 71 |
+
models = [
|
| 72 |
+
"meta-llama/Llama-3.3-70B-Instruct",
|
| 73 |
+
"Qwen/QwQ-32B",
|
| 74 |
+
"meta-llama/Meta-Llama-3-8B-Instruct",
|
| 75 |
+
"HuggingFaceH4/zephyr-7b-beta",
|
| 76 |
+
"mistralai/Mistral-7B-Instruct-v0.2"
|
| 77 |
+
]
|
| 78 |
+
for model in models:
|
| 79 |
+
try:
|
| 80 |
+
url = f"https://api-inference.huggingface.co/models/{model}"
|
| 81 |
+
r = requests.post(url, headers={"Authorization": f"Bearer {HF_TOKEN}"}, json={"inputs": "say hi", "parameters": {"max_new_tokens": 5}}, timeout=15)
|
| 82 |
+
results[model] = f"{r.status_code}: {r.text[:100]}"
|
| 83 |
+
except Exception as e:
|
| 84 |
+
results[model] = f"ERROR: {str(e)[:100]}"
|
| 85 |
+
return results
|
| 86 |
+
|
| 87 |
if __name__ == "__main__":
|
| 88 |
uvicorn.run("api.server:app", host=API_HOST, port=API_PORT, reload=False)
|