atlasbot: tighten metric candidates
This commit is contained in:
parent
bb51321404
commit
97fa07ed98
@ -982,16 +982,35 @@ def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit:
|
||||
if not lines:
|
||||
return []
|
||||
lowered = [kw.lower() for kw in (keywords or []) if kw]
|
||||
metric_tokens = {
|
||||
"cpu",
|
||||
"ram",
|
||||
"memory",
|
||||
"net",
|
||||
"network",
|
||||
"io",
|
||||
"disk",
|
||||
"load",
|
||||
"usage",
|
||||
"utilization",
|
||||
"hottest",
|
||||
"p95",
|
||||
"percent",
|
||||
"pressure",
|
||||
}
|
||||
candidates: list[str] = []
|
||||
for line in lines:
|
||||
line_lower = line.lower()
|
||||
if "hottest:" in line_lower:
|
||||
candidates.append(line)
|
||||
continue
|
||||
if lowered and any(kw in line_lower for kw in lowered):
|
||||
candidates.append(line)
|
||||
elif re.search(r"\d", line):
|
||||
continue
|
||||
if any(token in line_lower for token in metric_tokens) and re.search(r"\d", line_lower):
|
||||
candidates.append(line)
|
||||
if len(candidates) >= limit:
|
||||
break
|
||||
return candidates
|
||||
continue
|
||||
return candidates[:limit]
|
||||
|
||||
|
||||
async def _select_metric_facts(
|
||||
|
||||
@ -215,6 +215,7 @@ FACT_SELECT_SYSTEM = (
|
||||
|
||||
FACT_SELECT_PROMPT = (
|
||||
"Pick up to {max_lines} lines from Candidates that best answer the question. "
|
||||
"If the question asks for highest/hottest and Candidates include a line starting with 'hottest:', prefer that line. "
|
||||
"Return JSON with field: lines (list of strings). If none apply, return {\"lines\": []}."
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user