atlasbot: fix tag detection for workload queries
This commit is contained in:
parent
be82109d4e
commit
8316e5dd15
@ -3154,35 +3154,37 @@ def _open_ended_interpret(
|
||||
|
||||
def _preferred_tags_for_prompt(prompt: str) -> set[str]:
|
||||
q = normalize_query(prompt)
|
||||
tokens = set(_tokens(prompt))
|
||||
tags: set[str] = set()
|
||||
if any(word in q for word in ("cpu", "ram", "memory", "net", "network", "io", "disk", "hottest", "busy", "usage", "utilization", "load")):
|
||||
if tokens & {"cpu", "ram", "memory", "net", "network", "io", "disk", "hottest", "busy", "usage", "utilization", "load"}:
|
||||
tags.add("utilization")
|
||||
if any(word in q for word in ("postgres", "database", "db", "connections")):
|
||||
if tokens & {"postgres", "database", "db", "connections"}:
|
||||
tags.add("database")
|
||||
if any(word in q for word in ("pod", "pods", "deployment", "job", "cronjob")):
|
||||
if tokens & {"pod", "pods", "deployment", "job", "cronjob"}:
|
||||
tags.add("pods")
|
||||
if any(word in q for word in ("workload", "service", "namespace")):
|
||||
if tokens & {"workload", "service", "namespace"}:
|
||||
tags.add("workloads")
|
||||
if any(word in q for word in ("ready", "not ready", "down", "unreachable", "availability")):
|
||||
if tokens & {"ready", "down", "unreachable", "availability"} or "not ready" in q:
|
||||
tags.add("availability")
|
||||
if any(word in q for word in ("node", "nodes", "hardware", "arch", "architecture", "rpi", "jetson", "amd64", "arm64", "worker", "control-plane")):
|
||||
if tokens & {"node", "nodes", "hardware", "arch", "architecture", "rpi", "jetson", "amd64", "arm64", "worker", "control-plane"}:
|
||||
tags.update({"hardware", "inventory", "architecture"})
|
||||
return tags & _ALLOWED_INSIGHT_TAGS
|
||||
|
||||
|
||||
def _primary_tags_for_prompt(prompt: str) -> set[str]:
|
||||
q = normalize_query(prompt)
|
||||
if any(word in q for word in ("cpu", "ram", "memory", "net", "network", "io", "disk", "hottest", "busy", "usage", "utilization", "load")):
|
||||
tokens = set(_tokens(prompt))
|
||||
if tokens & {"cpu", "ram", "memory", "net", "network", "io", "disk", "hottest", "busy", "usage", "utilization", "load"}:
|
||||
return {"utilization"}
|
||||
if any(word in q for word in ("postgres", "database", "db", "connections")):
|
||||
if tokens & {"postgres", "database", "db", "connections"}:
|
||||
return {"database"}
|
||||
if any(word in q for word in ("pod", "pods", "deployment", "job", "cronjob")):
|
||||
if tokens & {"pod", "pods", "deployment", "job", "cronjob"}:
|
||||
return {"pods"}
|
||||
if any(word in q for word in ("workload", "service", "namespace")):
|
||||
if tokens & {"workload", "service", "namespace"}:
|
||||
return {"workloads"}
|
||||
if any(word in q for word in ("ready", "not ready", "down", "unreachable", "availability")):
|
||||
if tokens & {"ready", "down", "unreachable", "availability"} or "not ready" in q:
|
||||
return {"availability"}
|
||||
if any(word in q for word in ("node", "nodes", "hardware", "arch", "architecture", "rpi", "jetson", "amd64", "arm64", "worker", "control-plane")):
|
||||
if tokens & {"node", "nodes", "hardware", "arch", "architecture", "rpi", "jetson", "amd64", "arm64", "worker", "control-plane"}:
|
||||
return {"hardware", "inventory", "architecture"}
|
||||
return set()
|
||||
|
||||
@ -3202,9 +3204,10 @@ def _tags_from_text(text: str) -> set[str]:
|
||||
q = normalize_query(text)
|
||||
if not q:
|
||||
return set()
|
||||
tokens = set(_tokens(text))
|
||||
tags: set[str] = set()
|
||||
for tag, keywords in _TAG_KEYWORDS.items():
|
||||
if any(word in q for word in keywords):
|
||||
if any(word in tokens for word in keywords):
|
||||
tags.add(tag)
|
||||
return tags & _ALLOWED_INSIGHT_TAGS
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user