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"}:
|
||||
return f"Atlas has {value} total nodes."
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -41,6 +41,10 @@ class KnowledgeBase:
|
||||
parts.append(f"Cluster: {cluster}.")
|
||||
if 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)
|
||||
|
||||
def runbook_titles(self, *, limit: int = 5) -> str:
|
||||
@ -77,6 +81,9 @@ class KnowledgeBase:
|
||||
lines: list[str] = []
|
||||
if not self._base:
|
||||
return lines
|
||||
summary = self.summary()
|
||||
if summary:
|
||||
lines.append(f"KB Summary: {summary}")
|
||||
# Prefer curated catalog JSON if present.
|
||||
if self._atlas:
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user