diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index c829ef9..3316a3c 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -483,8 +483,17 @@ class AnswerEngine: plan: ModePlan, call_llm: Callable[..., Any], ) -> str: + style_hint = _style_hint(classify) if not subanswers: - prompt = prompts.SYNTHESIZE_PROMPT + "\nQuestion: " + question + prompt = ( + prompts.SYNTHESIZE_PROMPT + + "\nQuestion: " + + question + + "\nStyle: " + + style_hint + + "\nQuestionType: " + + (classify.get("question_type") or "unknown") + ) return await call_llm(prompts.SYNTHESIZE_SYSTEM, prompt, context=context, model=plan.model, tag="synth") draft_prompts = [] for idx in range(plan.drafts): @@ -492,6 +501,10 @@ class AnswerEngine: prompts.SYNTHESIZE_PROMPT + "\nQuestion: " + question + + "\nStyle: " + + style_hint + + "\nQuestionType: " + + (classify.get("question_type") or "unknown") + "\nSubanswers:\n" + "\n".join([f"- {item}" for item in subanswers]) + f"\nDraftIndex: {idx + 1}" @@ -982,6 +995,14 @@ def _default_scores() -> AnswerScores: return AnswerScores(confidence=60, relevance=60, satisfaction=60, hallucination_risk="medium") +def _style_hint(classify: dict[str, Any]) -> str: + style = (classify.get("answer_style") or "").strip().lower() + qtype = (classify.get("question_type") or "").strip().lower() + if style == "insightful" or qtype in {"open_ended", "planning"}: + return "insightful" + return "direct" + + def _needs_evidence_fix(reply: str, classify: dict[str, Any]) -> bool: if not reply: return False diff --git a/atlasbot/llm/prompts.py b/atlasbot/llm/prompts.py index 0869dab..f95d991 100644 --- a/atlasbot/llm/prompts.py +++ b/atlasbot/llm/prompts.py @@ -81,12 +81,15 @@ SUBANSWER_PROMPT = ( SYNTHESIZE_SYSTEM = ( CLUSTER_SYSTEM + " Synthesize a final answer from sub-answers. " - + "Keep it conversational and grounded." + + "Keep it conversational and grounded. " + + "Do not say 'based on the snapshot' or 'based on the context'." ) SYNTHESIZE_PROMPT = ( "Write a final response to the user. " - "Use sub-answers as evidence, avoid raw metric dumps unless asked." + "Use sub-answers as evidence, avoid raw metric dumps unless asked. " + "If Style is insightful or the question is open-ended, choose 1-2 salient points and explain why they stand out. " + "If Style is direct, answer concisely with the specific value requested." ) EVIDENCE_FIX_SYSTEM = ( @@ -188,7 +191,8 @@ FOLLOWUP_SYSTEM = ( ) FOLLOWUP_PROMPT = ( - "Answer the follow-up using provided evidence. Be conversational and concise." + "Answer the follow-up using provided evidence. " + "Be conversational and concise, and avoid restating all metrics." ) SELECT_CLAIMS_PROMPT = (