atlasbot: use hardware usage facts for hardware questions
This commit is contained in:
parent
1837fec215
commit
67488a8898
@ -267,11 +267,15 @@ class AnswerEngine:
|
|||||||
selected = _select_chunks(chunks, scored, plan, keyword_tokens)
|
selected = _select_chunks(chunks, scored, plan, keyword_tokens)
|
||||||
key_facts = _key_fact_lines(summary_lines, keyword_tokens)
|
key_facts = _key_fact_lines(summary_lines, keyword_tokens)
|
||||||
hottest_facts = _extract_hottest_facts(summary_lines, f"{question} {normalized}")
|
hottest_facts = _extract_hottest_facts(summary_lines, f"{question} {normalized}")
|
||||||
|
hardware_facts = _extract_hardware_usage_facts(summary_lines, f"{question} {normalized}")
|
||||||
metric_facts = [line for line in key_facts if re.search(r"\d", line)]
|
metric_facts = [line for line in key_facts if re.search(r"\d", line)]
|
||||||
if hottest_facts:
|
if hardware_facts:
|
||||||
|
metric_facts = hardware_facts
|
||||||
|
key_facts = _merge_fact_lines(metric_facts, key_facts)
|
||||||
|
if hottest_facts and not hardware_facts:
|
||||||
metric_facts = hottest_facts
|
metric_facts = hottest_facts
|
||||||
key_facts = _merge_fact_lines(metric_facts, key_facts)
|
key_facts = _merge_fact_lines(metric_facts, key_facts)
|
||||||
if classify.get("question_type") in {"metric", "diagnostic"} and not hottest_facts:
|
if classify.get("question_type") in {"metric", "diagnostic"} and not hottest_facts and not hardware_facts:
|
||||||
metric_candidates = _metric_candidate_lines(summary_lines, keyword_tokens)
|
metric_candidates = _metric_candidate_lines(summary_lines, keyword_tokens)
|
||||||
selected_facts = await _select_metric_facts(call_llm, normalized, metric_candidates, plan)
|
selected_facts = await _select_metric_facts(call_llm, normalized, metric_candidates, plan)
|
||||||
if selected_facts:
|
if selected_facts:
|
||||||
@ -1047,6 +1051,20 @@ def _extract_hottest_facts(lines: list[str], question: str) -> list[str]:
|
|||||||
return [fact for fact in facts if any(label in fact for label in wanted)] or facts
|
return [fact for fact in facts if any(label in fact for label in wanted)] or facts
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_hardware_usage_facts(lines: list[str], question: str) -> list[str]:
|
||||||
|
if not lines:
|
||||||
|
return []
|
||||||
|
lowered = question.lower()
|
||||||
|
if "hardware" not in lowered:
|
||||||
|
return []
|
||||||
|
if not any(term in lowered for term in ("average", "avg", "mean", "load", "cpu", "ram", "memory")):
|
||||||
|
return []
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith("hardware_usage_avg:"):
|
||||||
|
return [line]
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: int = 40) -> list[str]:
|
def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: int = 40) -> list[str]:
|
||||||
if not lines:
|
if not lines:
|
||||||
return []
|
return []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user