atlasbot: include global facts
This commit is contained in:
parent
049592afc8
commit
c180f3873c
@ -166,6 +166,7 @@ class AnswerEngine:
|
|||||||
allowed_nodes = _allowed_nodes(summary)
|
allowed_nodes = _allowed_nodes(summary)
|
||||||
allowed_namespaces = _allowed_namespaces(summary)
|
allowed_namespaces = _allowed_namespaces(summary)
|
||||||
summary_lines = _summary_lines(snapshot_used)
|
summary_lines = _summary_lines(snapshot_used)
|
||||||
|
global_facts = _global_facts(summary_lines)
|
||||||
kb_summary = self._kb.summary()
|
kb_summary = self._kb.summary()
|
||||||
runbooks = self._kb.runbook_titles(limit=6)
|
runbooks = self._kb.runbook_titles(limit=6)
|
||||||
runbook_paths = self._kb.runbook_paths(limit=10)
|
runbook_paths = self._kb.runbook_paths(limit=10)
|
||||||
@ -386,8 +387,11 @@ class AnswerEngine:
|
|||||||
)
|
)
|
||||||
facts_used = list(dict.fromkeys(key_facts)) if key_facts else list(dict.fromkeys(metric_facts))
|
facts_used = list(dict.fromkeys(key_facts)) if key_facts else list(dict.fromkeys(metric_facts))
|
||||||
snapshot_context = "ClusterSnapshot:\n" + "\n".join([chunk["text"] for chunk in selected])
|
snapshot_context = "ClusterSnapshot:\n" + "\n".join([chunk["text"] for chunk in selected])
|
||||||
if key_facts:
|
combined_facts = key_facts
|
||||||
snapshot_context = "KeyFacts:\n" + "\n".join(key_facts) + "\n\n" + snapshot_context
|
if global_facts:
|
||||||
|
combined_facts = _merge_fact_lines(global_facts, key_facts)
|
||||||
|
if combined_facts:
|
||||||
|
snapshot_context = "KeyFacts:\n" + "\n".join(combined_facts) + "\n\n" + snapshot_context
|
||||||
|
|
||||||
context = _join_context(
|
context = _join_context(
|
||||||
[kb_summary, _format_runbooks(runbooks), snapshot_context, history_ctx if classify.get("follow_up") else ""]
|
[kb_summary, _format_runbooks(runbooks), snapshot_context, history_ctx if classify.get("follow_up") else ""]
|
||||||
@ -1445,6 +1449,18 @@ def _filter_lines_by_keywords(lines: list[str], keywords: list[str], max_lines:
|
|||||||
return (filtered or lines)[:max_lines]
|
return (filtered or lines)[:max_lines]
|
||||||
|
|
||||||
|
|
||||||
|
def _global_facts(lines: list[str]) -> list[str]:
|
||||||
|
if not lines:
|
||||||
|
return []
|
||||||
|
wanted = ("nodes_total", "nodes_ready", "cluster_name", "cluster", "nodes_not_ready")
|
||||||
|
facts: list[str] = []
|
||||||
|
for line in lines:
|
||||||
|
lower = line.lower()
|
||||||
|
if any(key in lower for key in wanted):
|
||||||
|
facts.append(line)
|
||||||
|
return _dedupe_lines(facts, limit=6)
|
||||||
|
|
||||||
|
|
||||||
def _lexicon_context(summary: dict[str, Any]) -> str: # noqa: C901
|
def _lexicon_context(summary: dict[str, Any]) -> str: # noqa: C901
|
||||||
if not isinstance(summary, dict):
|
if not isinstance(summary, dict):
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user