diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 6db5fd6..19b1636 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -532,6 +532,37 @@ class AnswerEngine: if classify.get("question_type") in {"metric", "diagnostic"}: lowered_q = f"{question} {normalized}".lower() + if any(tok in lowered_q for tok in ("how many", "count", "number of")) and any( + tok in lowered_q for tok in ("jetson", "rpi4", "rpi5", "amd64", "arm64", "rpi") + ): + hw_line = next((line for line in summary_lines if line.startswith("hardware:")), None) + hw_nodes_line = next((line for line in summary_lines if line.startswith("hardware_nodes:")), None) + if hw_line: + def _find_value(key: str, line: str) -> str | None: + match = re.search(rf"{re.escape(key)}=([^;|]+)", line) + return match.group(1).strip() if match else None + + target = None + if "jetson" in lowered_q: + target = "jetson" + elif "rpi5" in lowered_q: + target = "rpi5" + elif "rpi4" in lowered_q: + target = "rpi4" + elif "amd64" in lowered_q: + target = "amd64" + elif "arm64" in lowered_q: + target = "arm64" + elif "rpi" in lowered_q: + target = "rpi" + if target: + count = _find_value(target, hw_line) + nodes = _find_value(target, hw_nodes_line or "") + if count: + if nodes: + reply = f"From the latest snapshot: {target}={count} ({nodes})." + else: + reply = f"From the latest snapshot: {target}={count}." if ("io" in lowered_q or "i/o" in lowered_q) and ("node" in lowered_q or "nodes" in lowered_q): io_facts = _extract_hottest_facts(summary_lines, lowered_q) io_line = next((fact for fact in io_facts if fact.startswith("hottest_io_node")), None)