atlasbot: prefer fact fallback for quantitative prompts

This commit is contained in:
Brad Stein 2026-01-28 03:32:17 -03:00
parent 19b52ac5e3
commit a9d74a066f

View File

@ -3854,6 +3854,18 @@ def _fallback_fact_answer(prompt: str, context: str) -> str:
return sentence return sentence
def _is_quantitative_prompt(prompt: str) -> bool:
q = normalize_query(prompt)
if not q:
return False
tokens = set(_tokens(prompt))
if "how many" in q or "count" in tokens or "total" in tokens:
return True
if tokens & {"highest", "lowest", "hottest", "most", "least"}:
return True
return False
def _open_ended_fast_single( def _open_ended_fast_single(
prompt: str, prompt: str,
*, *,
@ -3880,10 +3892,9 @@ def _open_ended_fast_single(
system_override=_open_ended_system(), system_override=_open_ended_system(),
model=model, model=model,
) )
if not _has_body_lines(reply): fallback = _fallback_fact_answer(prompt, context)
fallback = _fallback_fact_answer(prompt, context) if fallback and (_is_quantitative_prompt(prompt) or not _has_body_lines(reply)):
if fallback: reply = fallback
reply = fallback
if state: if state:
state.update("done", step=_open_ended_total_steps("fast")) state.update("done", step=_open_ended_total_steps("fast"))
return _ensure_scores(reply) return _ensure_scores(reply)