diff --git a/floatchat/router.py b/floatchat/router.py index 6dcf8db..226ffa6 100644 --- a/floatchat/router.py +++ b/floatchat/router.py @@ -64,6 +64,9 @@ def _prompt(question: str, history: list[dict]) -> str: '{"path": "analytical" | "semantic", "intent": , "filters": {...}, "question": }\n\n' "path=analytical for statistics (averages, comparisons, counts, trends) answered with SQL; " "path=semantic for finding or describing particular profiles or floats.\n" + "A request to see, find or list profiles is semantic even when it names a place or a date " + "(e.g. 'Profiles off Sri Lanka in June 2026'). Use analytical only when the question asks for a number, " + "a comparison, a trend or a summary table.\n" f"Intents (analytical only):\n{intents}\n" f"Filter keys: {', '.join(FILTER_KEYS)}. region is one of: {', '.join(sorted(REGION_NAMES))}. " "month_num is 1-12; has_* filters are true when the question is about that sensor.\n" diff --git a/tests/unit/test_router.py b/tests/unit/test_router.py index d664a43..96053a1 100644 --- a/tests/unit/test_router.py +++ b/tests/unit/test_router.py @@ -78,3 +78,12 @@ def test_llm_prompt_includes_history(): chat = fake_llm({"path": "analytical", "intent": "avg_by_depth", "filters": {}, "question": "q"}) llm_route("now only the Arabian Sea", [PREVIOUS_SQL], chat) assert "What is the average temperature at different depths?" in chat.calls[0][0] + + +def test_llm_prompt_sends_requests_for_profiles_to_search(): + # A bare "Profiles in in " asks to see profiles, not for a statistic + chat = fake_llm({"path": "semantic", "intent": None, "filters": {}, "question": "q"}) + llm_route("Profiles near Indonesia in January 2026", [], chat) + prompt = chat.calls[0][0] + assert "even when it names a place or a date" in prompt + assert "Profiles off Sri Lanka in June 2026" in prompt