atlasbot: parse hardware usage from composite lines

This commit is contained in:
Brad Stein 2026-02-01 18:24:51 -03:00
parent 80da274eaa
commit 7f4956edf1

View File

@ -1062,10 +1062,12 @@ def _extract_hardware_usage_facts(lines: list[str], question: str) -> list[str]:
avg_line = None
top_line = None
for line in lines:
if line.startswith("hardware_usage_avg:"):
avg_line = line
elif line.startswith("hardware_usage_top:"):
top_line = line
segments = [seg.strip() for seg in line.split(" | ")] if " | " in line else [line]
for seg in segments:
if seg.startswith("hardware_usage_avg:"):
avg_line = seg
elif seg.startswith("hardware_usage_top:"):
top_line = seg
if not avg_line and not top_line:
return []
wants_top = any(term in lowered for term in ("highest", "lowest", "most", "least", "top", "worst", "best"))