atlasbot: improve kb summary and metric phrasing
This commit is contained in:
parent
23e99712a5
commit
4aec30c5c9
@ -2114,6 +2114,23 @@ def _format_direct_metric_line(line: str) -> str:
|
|||||||
if key in {"nodes total", "nodes_total"}:
|
if key in {"nodes total", "nodes_total"}:
|
||||||
return f"Atlas has {value} total nodes."
|
return f"Atlas has {value} total nodes."
|
||||||
return f"{key} is {value}."
|
return f"{key} is {value}."
|
||||||
|
if "=" in line:
|
||||||
|
pairs: list[str] = []
|
||||||
|
for part in line.split(","):
|
||||||
|
if "=" not in part:
|
||||||
|
continue
|
||||||
|
k, v = part.split("=", 1)
|
||||||
|
k = k.strip().replace("_", " ")
|
||||||
|
v = v.strip()
|
||||||
|
if not v:
|
||||||
|
continue
|
||||||
|
if k in {"nodes total", "nodes_total"}:
|
||||||
|
return f"Atlas has {v} total nodes."
|
||||||
|
pairs.append(f"{k} is {v}")
|
||||||
|
if pairs:
|
||||||
|
if len(pairs) == 1:
|
||||||
|
return f"{pairs[0]}."
|
||||||
|
return "; ".join(pairs) + "."
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,10 @@ class KnowledgeBase:
|
|||||||
parts.append(f"Cluster: {cluster}.")
|
parts.append(f"Cluster: {cluster}.")
|
||||||
if services:
|
if services:
|
||||||
parts.append(f"Services indexed: {len(services)}.")
|
parts.append(f"Services indexed: {len(services)}.")
|
||||||
|
if isinstance(self._atlas, dict):
|
||||||
|
keys = [key for key in self._atlas.keys() if key not in {"sources"}]
|
||||||
|
if keys:
|
||||||
|
parts.append(f"Atlas keys: {', '.join(sorted(keys)[:8])}.")
|
||||||
return " ".join(parts)
|
return " ".join(parts)
|
||||||
|
|
||||||
def runbook_titles(self, *, limit: int = 5) -> str:
|
def runbook_titles(self, *, limit: int = 5) -> str:
|
||||||
@ -77,6 +81,9 @@ class KnowledgeBase:
|
|||||||
lines: list[str] = []
|
lines: list[str] = []
|
||||||
if not self._base:
|
if not self._base:
|
||||||
return lines
|
return lines
|
||||||
|
summary = self.summary()
|
||||||
|
if summary:
|
||||||
|
lines.append(f"KB Summary: {summary}")
|
||||||
# Prefer curated catalog JSON if present.
|
# Prefer curated catalog JSON if present.
|
||||||
if self._atlas:
|
if self._atlas:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user