atlasbot: force hardware_usage_top for class metrics

This commit is contained in:
Brad Stein 2026-02-01 18:41:19 -03:00
parent 164eab56fc
commit 5f433a186b

View File

@ -285,6 +285,21 @@ class AnswerEngine:
if hardware_facts: if hardware_facts:
metric_facts = hardware_facts metric_facts = hardware_facts
key_facts = _merge_fact_lines(metric_facts, key_facts) key_facts = _merge_fact_lines(metric_facts, key_facts)
if classify.get("question_type") in {"metric", "diagnostic"}:
lowered_q = f"{question} {normalized}".lower()
if any(tok in lowered_q for tok in ("hardware", "class", "type", "rpi", "jetson", "amd64", "arm64")) and any(
tok in lowered_q for tok in ("average", "avg", "mean", "ram", "memory", "cpu", "load")
):
hw_top = None
for line in summary_lines:
if "hardware_usage_top:" in line:
parts = [seg.strip() for seg in line.split(" | ") if seg.strip().startswith("hardware_usage_top:")]
if parts:
hw_top = parts[0]
break
if hw_top:
metric_facts = [hw_top]
key_facts = _merge_fact_lines(metric_facts, key_facts)
if hottest_facts and not hardware_facts: if hottest_facts and not hardware_facts:
metric_facts = hottest_facts metric_facts = hottest_facts
key_facts = _merge_fact_lines(metric_facts, key_facts) key_facts = _merge_fact_lines(metric_facts, key_facts)