atlasbot: fix metric detection and role counts

This commit is contained in:
Brad Stein 2026-01-27 13:13:20 -03:00
parent 70feb1ef85
commit 31fbe48ca3

View File

@ -424,9 +424,14 @@ def _detect_operation(q: str) -> str | None:
return None return None
def _detect_metric(q: str) -> str | None: def _detect_metric(q: str) -> str | None:
tokens = set(_tokens(q))
for metric, phrases in METRIC_HINTS.items(): for metric, phrases in METRIC_HINTS.items():
if _has_any(q, phrases): for phrase in phrases:
return metric if " " in phrase:
if phrase in q:
return metric
elif phrase in tokens:
return metric
return None return None
def _detect_hardware_filters(q: str) -> tuple[set[str], set[str]]: def _detect_hardware_filters(q: str) -> tuple[set[str], set[str]]:
@ -1249,7 +1254,7 @@ def structured_answer(
if missing: if missing:
msg += f" Missing: {', '.join(missing)}." msg += f" Missing: {', '.join(missing)}."
return _format_confidence(msg, "high") return _format_confidence(msg, "high")
if not (include_hw or exclude_hw or nodes_in_query or only_workers): if not (include_hw or exclude_hw or nodes_in_query or only_workers or role_filters):
return _format_confidence(f"Atlas has {len(names)} nodes.", "high") return _format_confidence(f"Atlas has {len(names)} nodes.", "high")
return _format_confidence(f"Matching nodes: {len(names)}.", "high") return _format_confidence(f"Matching nodes: {len(names)}.", "high")