Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions floatchat/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def _prompt(question: str, history: list[dict]) -> str:
'{"path": "analytical" | "semantic", "intent": <intent or null>, "filters": {...}, "question": <standalone>}\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"
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <place> in <month>" 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
Loading