From e09544f18aa78fa8ed44838ab2f5ce7fb59bb87c Mon Sep 17 00:00:00 2001 From: CodexManvik Date: Mon, 9 Nov 2026 10:33:29 +0530 Subject: [PATCH] Route bare "Profiles in in " requests to profile search With room to reason (max_tokens 600), the LLM router sent "Profiles near Indonesia in January 2026" and "Profiles in the Bay of Bengal in September 2026" to custom SQL. The prompt only said statistics go to SQL; it now says a request to see or list profiles is a search even when it names a place or a date, with an example that is not one of the benchmark questions. Co-Authored-By: Claude Opus 5.5 --- floatchat/router.py | 3 +++ tests/unit/test_router.py | 9 +++++++++ 2 files changed, 12 insertions(+) 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