Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,11 @@ from llama_cpp import Llama
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
import os
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
app = FastAPI()
|
7 |
|
8 |
# === Model Config ===
|
@@ -37,6 +42,37 @@ llm = Llama(
|
|
37 |
def root():
|
38 |
return {"message": "Mistral API is live!"}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
@app.post("/generate")
|
41 |
async def generate(request: Request):
|
42 |
data = await request.json()
|
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
import os
|
5 |
|
6 |
+
import platform
|
7 |
+
import psutil
|
8 |
+
import multiprocessing
|
9 |
+
|
10 |
+
|
11 |
app = FastAPI()
|
12 |
|
13 |
# === Model Config ===
|
|
|
42 |
def root():
|
43 |
return {"message": "Mistral API is live!"}
|
44 |
|
45 |
+
@app.get("/get_sys")
|
46 |
+
def get_sys_specs():
|
47 |
+
cpu_info = {
|
48 |
+
"physical_cores": psutil.cpu_count(logical=False),
|
49 |
+
"logical_cores": psutil.cpu_count(logical=True),
|
50 |
+
"max_frequency_mhz": psutil.cpu_freq().max if psutil.cpu_freq() else None,
|
51 |
+
"cpu_usage_percent": psutil.cpu_percent(interval=1)
|
52 |
+
}
|
53 |
+
|
54 |
+
memory = psutil.virtual_memory()
|
55 |
+
ram_info = {
|
56 |
+
"total_gb": round(memory.total / (1024 ** 3), 2),
|
57 |
+
"available_gb": round(memory.available / (1024 ** 3), 2),
|
58 |
+
"used_percent": memory.percent
|
59 |
+
}
|
60 |
+
|
61 |
+
system_info = {
|
62 |
+
"system": platform.system(),
|
63 |
+
"machine": platform.machine(),
|
64 |
+
"platform": platform.platform(),
|
65 |
+
"processor": platform.processor(),
|
66 |
+
"python_version": platform.python_version(),
|
67 |
+
}
|
68 |
+
|
69 |
+
return {
|
70 |
+
"cpu": cpu_info,
|
71 |
+
"ram": ram_info,
|
72 |
+
"system": system_info,
|
73 |
+
"recommended_threads": min(psutil.cpu_count(logical=False) or 2, 8)
|
74 |
+
}
|
75 |
+
|
76 |
@app.post("/generate")
|
77 |
async def generate(request: Request):
|
78 |
data = await request.json()
|