diff --git a/api/routes/kb_public.py b/api/routes/kb_public.py index 05829c6..f62ecbb 100644 --- a/api/routes/kb_public.py +++ b/api/routes/kb_public.py @@ -145,6 +145,17 @@ async def ask(body: AskRequest, request: Request): user_profile="", available_skills=list_skills(), ) + # Pin the question to the insurance KB context so generic-law answers + # (e.g. "תקנה 37 לתקנות סדר הדין האזרחי") don't hijack the response. + system_prompt += ( + "\n\nContext: The user is asking from the Knowledge Base UI of the " + "Israeli National Insurance firm. Every question should be answered " + "from the KB of חוק/תקנות/חוזרי הביטוח הלאומי. Before answering, " + "call search_insurance_kb to retrieve the relevant sections, and " + "cite them explicitly with section_ref (ס' N, תקנה N, or חוזר N/YYYY). " + "Never answer from generic legal training if the KB has a matching " + "section — if no KB section matches, say so explicitly." + ) messages: list[dict] = [] for m in (body.conversation_history or []):