atlasbot: fallback hardware facts for class queries

This commit is contained in:
Brad Stein 2026-02-01 18:32:55 -03:00
parent 7f4956edf1
commit e31cb74e14

View File

@ -268,6 +268,19 @@ class AnswerEngine:
key_facts = _key_fact_lines(summary_lines, keyword_tokens)
hottest_facts = _extract_hottest_facts(summary_lines, f"{question} {normalized}")
hardware_facts = _extract_hardware_usage_facts(summary_lines, f"{question} {normalized}")
if not hardware_facts:
hardware_tokens = ("hardware", "class", "type", "rpi", "jetson", "amd64", "arm64")
lowered_q = f"{question} {normalized}".lower()
if any(tok in lowered_q for tok in hardware_tokens):
for line in summary_lines:
if "hardware_usage_top:" in line:
hardware_facts = [seg.strip() for seg in line.split(" | ") if seg.strip().startswith("hardware_usage_top:")]
break
if not hardware_facts:
for line in summary_lines:
if "hardware_usage_avg:" in line:
hardware_facts = [seg.strip() for seg in line.split(" | ") if seg.strip().startswith("hardware_usage_avg:")]
break
metric_facts = [line for line in key_facts if re.search(r"\d", line)]
if hardware_facts:
metric_facts = hardware_facts