evidence: inject hardware context
This commit is contained in:
parent
1095503454
commit
2c7490288d
@ -477,6 +477,10 @@ class AnswerEngine:
|
||||
runbook_fix = _needs_runbook_fix(reply, runbook_paths)
|
||||
runbook_needed = _needs_runbook_reference(normalized, runbook_paths, reply)
|
||||
needs_evidence = _needs_evidence_fix(reply, classify)
|
||||
hardware_terms = ("rpi", "raspberry", "jetson", "amd64", "arm64", "hardware")
|
||||
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 classify.get("question_type") in {"open_ended", "planning"} and metric_facts:
|
||||
needs_evidence = True
|
||||
resolved_runbook = None
|
||||
@ -507,6 +511,8 @@ class AnswerEngine:
|
||||
extra_bits.append("ResolvedRunbook: " + resolved_runbook)
|
||||
if metric_facts:
|
||||
extra_bits.append("MustUseFacts: " + "; ".join(metric_facts[:4]))
|
||||
if hardware_line:
|
||||
extra_bits.append("HardwareNodes: " + hardware_line)
|
||||
if allowed_nodes:
|
||||
extra_bits.append("AllowedNodes: " + ", ".join(allowed_nodes))
|
||||
if allowed_namespaces:
|
||||
@ -1623,6 +1629,16 @@ def _best_keyword_line(lines: list[str], keywords: list[str]) -> str | None:
|
||||
return best if best_score > 0 else None
|
||||
|
||||
|
||||
def _line_starting_with(lines: list[str], prefix: str) -> str | None:
|
||||
if not lines or not prefix:
|
||||
return None
|
||||
lower_prefix = prefix.lower()
|
||||
for line in lines:
|
||||
if str(line).lower().startswith(lower_prefix):
|
||||
return line
|
||||
return None
|
||||
|
||||
|
||||
def _lexicon_context(summary: dict[str, Any]) -> str: # noqa: C901
|
||||
if not isinstance(summary, dict):
|
||||
return ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user