diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 6010d4c..72b0421 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -217,7 +217,8 @@ class AnswerEngine: classify.setdefault("focus_entity", "unknown") classify.setdefault("focus_metric", "unknown") _debug_log("route_parsed", {"classify": classify, "normalized": normalized}) - force_metric = bool(re.search(r"\bhow many\b|\bcount\b|\btotal\b", normalized.lower())) + lowered_question = f"{question} {normalized}".lower() + force_metric = bool(re.search(r"\bhow many\b|\bcount\b|\btotal\b", lowered_question)) cluster_terms = ( "atlas", "cluster", @@ -241,7 +242,7 @@ class AnswerEngine: "pvc", "storage", ) - if any(term in normalized.lower() for term in cluster_terms): + if any(term in lowered_question for term in cluster_terms): classify["needs_snapshot"] = True lowered_norm = normalized.lower() if ( @@ -251,11 +252,19 @@ class AnswerEngine: ): classify["question_type"] = "metric" classify["needs_snapshot"] = True - if re.search(r"\b(how many|count|number of|list)\b", normalized.lower()): + if re.search(r"\b(how many|count|number of|list)\b", lowered_question): classify["question_type"] = "metric" + if any(term in lowered_question for term in ("postgres", "connections", "db")): + classify["question_type"] = "metric" + classify["needs_snapshot"] = True + if any(term in lowered_question for term in ("pvc", "persistentvolume", "persistent volume", "storage")): + if classify.get("question_type") not in {"metric", "diagnostic"}: + classify["question_type"] = "metric" + classify["needs_snapshot"] = True + if "ready" in lowered_question and classify.get("question_type") not in {"metric", "diagnostic"}: + classify["question_type"] = "diagnostic" hottest_terms = ("hottest", "highest", "lowest", "most") metric_terms = ("cpu", "ram", "memory", "net", "network", "io", "disk", "load", "usage", "pod", "pods", "namespace") - lowered_question = f"{question} {normalized}".lower() if any(term in lowered_question for term in hottest_terms) and any(term in lowered_question for term in metric_terms): classify["question_type"] = "metric"