Multi-instance terminal UI dashboard for monitoring all ServeAI processes
simultaneously. Uses MQTT heartbeats for live instance tracking alongside the
existing dual-rate local Ollama and DB polls.
AiTUI combines three data sources:
axion/+/heartbeat/ai/+ for per-instanceTuiConstants.HEARTBEAT_STALE_SECS (45 s).TuiConstants.AI_POLL_FAST_SECS, default 2 s) — checks localcurl http://localhost:11434/ and queries hourlytrack_mcp.TuiConstants.AI_POLL_SLOW_SECS, default 10 s) — runsollama list to enumerate installed models and fetches recent requests fromtrack_mcp.Status colour thresholds:
| Metric | OK | Warn | Fail |
|---|---|---|---|
| HTTP status | < HTTP_SUCCESS_BOUNDARY (300) |
< HTTP_ERROR_BOUNDARY (500) |
≥ 500 |
| Latency | < LATENCY_OK_SECS (1 s) |
< LATENCY_WARN_SECS (5 s) |
≥ 5 s |
__init__(self)Initialises theme, console, layout, and internal state. No port parameter —
instance data arrives via MQTT.
start(self) / stop(self)start() calls _start_mqtt(), renders the initial layout, and launches the
background update thread. stop() disconnects the MQTT client and tears down
the Live context.
_start_mqtt(self) (internal)Connects a paho MQTT client, subscribes to the heartbeat wildcard, and updates
self.instances[instance_id] on each message.
_poll_fast(self) (internal)Runs every AI_POLL_FAST_SECS. Checks Ollama via subprocess curl and queries
aggregate stats (COUNT, AVG(Latency), error count) from track_mcp.
_poll_slow(self) (internal)Runs every AI_POLL_SLOW_SECS. Enumerates Ollama models via ollama list
and fetches the most recent requests from track_mcp.
| Panel | Content |
|---|---|
| Header | Heartbeat, Ollama status, Instances: N/M, clock, uptime |
| Sidebar | Active/total counts, requests/hr, avg latency, errors, DB/Ollama status, model count |
| Instances | Table of all known instances — instance ID, package, uptime, PID, status |
| Models | Table of installed Ollama models and sizes |
| Recent Requests | Table of last N requests — endpoint, model, status code, latency |
| Log | Scrolling log |
| Footer | Last fast-poll timestamp |
python ServeAI.py tui
Press Ctrl+C to exit.