atlasbot: refine node and postgres query handling
This commit is contained in:
parent
12fa7d02aa
commit
8842662239
@ -16,7 +16,7 @@ spec:
|
||||
labels:
|
||||
app: atlasbot
|
||||
annotations:
|
||||
checksum/atlasbot-configmap: manual-atlasbot-65
|
||||
checksum/atlasbot-configmap: manual-atlasbot-66
|
||||
vault.hashicorp.com/agent-inject: "true"
|
||||
vault.hashicorp.com/role: "comms"
|
||||
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"
|
||||
|
||||
@ -538,7 +538,17 @@ def _detect_metric(q: str) -> str | None:
|
||||
def _detect_hardware_filters(q: str) -> tuple[set[str], set[str]]:
|
||||
include: set[str] = set()
|
||||
exclude: set[str] = set()
|
||||
rpi_specific = "rpi4" in q or "rpi5" in q
|
||||
rpi_specific = any(
|
||||
phrase in q
|
||||
for phrase in (
|
||||
"rpi4",
|
||||
"rpi5",
|
||||
"raspberry pi 4",
|
||||
"raspberry pi 5",
|
||||
"raspberry pi-4",
|
||||
"raspberry pi-5",
|
||||
)
|
||||
)
|
||||
for hardware, phrases in HARDWARE_HINTS.items():
|
||||
if hardware == "rpi" and rpi_specific:
|
||||
continue
|
||||
@ -1226,6 +1236,10 @@ def snapshot_metric_answer(
|
||||
hottest = postgres.get("hottest_db") if isinstance(postgres.get("hottest_db"), dict) else {}
|
||||
parts: list[str] = []
|
||||
if used is not None and max_conn is not None:
|
||||
free = max_conn - used
|
||||
if any(word in q for word in ("free", "available", "remaining")):
|
||||
parts.append(f"Postgres connections: {used:.0f} used / {max_conn:.0f} max ({free:.0f} free).")
|
||||
else:
|
||||
parts.append(f"Postgres connections: {used:.0f} used / {max_conn:.0f} max.")
|
||||
if hottest.get("label"):
|
||||
hot_val = hottest.get("value")
|
||||
@ -1303,6 +1317,11 @@ def structured_answer(
|
||||
if not op and entity == "node":
|
||||
op = "list" if (include_hw or exclude_hw or nodes_in_query) else "count"
|
||||
|
||||
if entity == "node" and "total" in q and "ready" in q:
|
||||
summary = _nodes_summary_line(inventory, snapshot)
|
||||
if summary:
|
||||
return _format_confidence(summary, "high")
|
||||
|
||||
if entity == "node" and ("hardware mix" in q or "architecture" in q):
|
||||
hw_line = _hardware_mix_line(inventory)
|
||||
if hw_line:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user