atlasbot: enforce metric facts in answers
This commit is contained in:
parent
bb4b5f030a
commit
2aa088a8cf
@ -481,6 +481,9 @@ class AnswerEngine:
|
||||
hardware_line = _line_starting_with(summary_lines, "hardware_nodes:")
|
||||
if any(term in lowered_question for term in hardware_terms) and hardware_line:
|
||||
needs_evidence = True
|
||||
if metric_facts and (classify.get("question_type") in {"metric", "diagnostic"} or force_metric):
|
||||
if not _reply_matches_metric_facts(reply, metric_facts):
|
||||
needs_evidence = True
|
||||
if classify.get("question_type") in {"open_ended", "planning"} and metric_facts:
|
||||
needs_evidence = True
|
||||
resolved_runbook = None
|
||||
@ -1769,6 +1772,18 @@ def _needs_evidence_fix(reply: str, classify: dict[str, Any]) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _reply_matches_metric_facts(reply: str, metric_facts: list[str]) -> bool:
|
||||
if not reply or not metric_facts:
|
||||
return True
|
||||
reply_numbers = set(re.findall(r"\d+(?:\\.\d+)?", reply))
|
||||
if not reply_numbers:
|
||||
return False
|
||||
fact_numbers = set(re.findall(r"\d+(?:\\.\d+)?", " ".join(metric_facts)))
|
||||
if not fact_numbers:
|
||||
return True
|
||||
return bool(reply_numbers & fact_numbers)
|
||||
|
||||
|
||||
def _needs_dedup(reply: str) -> bool:
|
||||
if not reply:
|
||||
return False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user