diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 29efcb2..50673c0 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -405,7 +405,7 @@ class AnswerEngine: model=plan.model, tag="focus_fix", ) - if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts and not re.search(r"\\d", reply): + if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts: best_line = None lowered_keywords = [kw.lower() for kw in keyword_tokens if kw] for line in metric_facts: @@ -414,7 +414,10 @@ class AnswerEngine: best_line = line break best_line = best_line or metric_facts[0] - reply = f"From the latest snapshot: {best_line}." + reply_numbers = set(re.findall(r"\\d+(?:\\.\\d+)?", reply)) + fact_numbers = set(re.findall(r"\\d+(?:\\.\\d+)?", " ".join(metric_facts))) + if not reply_numbers or (fact_numbers and not (reply_numbers & fact_numbers)): + reply = f"From the latest snapshot: {best_line}." if plan.use_critic: if observer: