Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,6 +91,42 @@ with gr.Blocks(title="Eroha v6.4.4 Dashboard") as demo:
|
|
| 91 |
|
| 92 |
demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
# βββββββββββββββββββββββββββββββ
|
| 96 |
# 5οΈβ£ Mount Gradio to FastAPI (single port)
|
|
|
|
| 91 |
|
| 92 |
demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
|
| 93 |
|
| 94 |
+
import httpx
|
| 95 |
+
|
| 96 |
+
# 4οΈβ£b Health Status Checker
|
| 97 |
+
async def check_health():
|
| 98 |
+
"""ΠΡΠΎΠ²Π΅ΡΠΊΠ° ΡΠΎΡΡΠΎΡΠ½ΠΈΡ API."""
|
| 99 |
+
try:
|
| 100 |
+
async with httpx.AsyncClient(timeout=2) as client:
|
| 101 |
+
resp = await client.get("http://localhost:7860/health")
|
| 102 |
+
if resp.status_code == 200 and resp.json().get("status") == "ok":
|
| 103 |
+
return "π’ ONLINE"
|
| 104 |
+
except Exception:
|
| 105 |
+
pass
|
| 106 |
+
return "π΄ OFFLINE"
|
| 107 |
+
|
| 108 |
+
# ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π² ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ Gradio
|
| 109 |
+
with gr.Blocks(title="Eroha v6.4.5 Dashboard") as demo:
|
| 110 |
+
gr.Markdown("## βοΈ Eroha v6.4.5 β Stable Health Edition")
|
| 111 |
+
|
| 112 |
+
with gr.Row():
|
| 113 |
+
with gr.Column():
|
| 114 |
+
inp = gr.Textbox(label="Prompt")
|
| 115 |
+
btn = gr.Button("Send")
|
| 116 |
+
out = gr.Textbox(label="Response")
|
| 117 |
+
|
| 118 |
+
btn.click(fn=lambda x: f"Echo: {x[:200]}", inputs=inp, outputs=out)
|
| 119 |
+
|
| 120 |
+
gr.Markdown("### π©Ί System Health Monitor")
|
| 121 |
+
health_box = gr.Textbox(label="API Status", interactive=False)
|
| 122 |
+
|
| 123 |
+
gr.Markdown("### π Live Metrics (5s refresh)")
|
| 124 |
+
cpu_box = gr.Number(label="CPU %")
|
| 125 |
+
ram_box = gr.Number(label="RAM %")
|
| 126 |
+
|
| 127 |
+
# Auto-updates
|
| 128 |
+
demo.load(check_health, outputs=[health_box], every=5)
|
| 129 |
+
demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
|
| 130 |
|
| 131 |
# βββββββββββββββββββββββββββββββ
|
| 132 |
# 5οΈβ£ Mount Gradio to FastAPI (single port)
|