Repository navigation
Connect the chatbot to the conditions check with tool calling - #35
Conversation
Spot directions are stored as degrees so a later conditions check can calculate offshore wind and swell fit. The seven profiles are unverified and their notes are paraphrased from the cited pages. Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add Spot model and baseline Bay of Plenty spot profiles
Cache the yearly standard-port CSV, read its times as Pacific/Auckland civil time, and interpolate height and phase between highs and lows. Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add LINZ tide predictions for Tauranga with tide state at any time
Combine the marine and wind APIs into Pacific/Auckland hours, cache the pair for one hour, and print them from swellsense forecast. Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add Open-Meteo forecast for a spot: swell, wind waves and wind
Pure judgements compare a spot profile with one set of numbers. Thresholds live in one module so they can be tuned without rewriting the rules. Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add conditions classifiers: wind, swell and tide relative to a spot
Score each hour in code from the wind, swell and tide classifiers, then report the best hour and rank spots. The check command prints that report with the forecast and tide attributions. Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add conditions rating, report and best-time/best-spot answers
Equal best-hour scores share a rank. Within a tie, shore access and an easier skill come first. --skill lists spots above that level instead of dropping them. Co-authored-by: Zane <xquantize@users.noreply.github.com>
Make spot ranking honest about ties, skill and access
The model chooses list_spots, check_spot or rank_spots and phrases the JSON. Time windows, scores and rankings stay in code. A window that has already passed, or a best score of 0, is reported as such. Co-authored-by: Zane <xquantize@users.noreply.github.com>
|
@cursor three fixes from a real test: (1) never show tool or parameter names like "this_morning" to the user; speak naturally ("the morning's gone"). (2) When a requested window has passed, automatically check the next sensible window (the rest of today, or tomorrow morning if it's evening) and answer with that, saying the original window had passed. (3) Only add the Open-Meteo / LINZ credit when forecast or tide data was actually used in the answer. Add tests for (2) and (3) with a fake model. |
|
A passed window is now answered from the next real one, in ordinary words, and the data credit only appears when a forecast or tide was actually used.
|
…t was used A request for a part of the day that has finished now checks the rest of today, or tomorrow morning once it is evening, and says so without tool names. The Open-Meteo and LINZ line is added only after a forecast or tide was actually returned. Co-authored-by: Zane <xquantize@users.noreply.github.com>
|
@cursor two fixes from a real test, where the model invented explanations: (1) Tighten the system prompt: explain conditions only with the reasons returned by the tools; never add your own explanations of how wind, tide or period affect waves; if the tide call is conflicting or uncertain, say it was left out of the rating rather than describing its effect; keep answers under about 100 words with no filler sign-offs. (2) In the chat loop, strip emojis from the model's final answer in code, like the data credit. Add a test with a fake model reply containing an emoji. |
|
Conditions answers now have to stay with the reasons the tools already returned, and emoji are removed from the final reply in code.
|
The prompt now forbids invented wind, tide and period explanations, says an uncertain tide was left out of the rating, and keeps replies short. Emoji are removed from the final answer in code. Co-authored-by: Zane <xquantize@users.noreply.github.com>



Part of Stage 3 (#21). Targets
feature/conditions.The chatbot can answer "is this spot worth surfing this morning?" and "where should I go?" from the conditions engine. The model only chooses a tool and phrases the JSON. The window, the score and the ranking are computed in code.
complete_messagereturns the full assistant message so tool calls are visible.chat()still returns text.list_spots,check_spotandrank_spotslive insrc/swellsense/chat/tools.py.whenresolves to a Pacific/Auckland window: now (next 3 hours), this morning 05:00-11:00, this afternoon 12:00-18:00, this evening 17:00-21:00, tomorrow morning, tomorrow afternoon, the next 12 hours, and the next 24 hours.Tests cover a winter clock, the 5 April 2026 fallback, the 27 September 2026 forward change, a passed morning answered as the rest of today, an evening request answered as tomorrow morning, dispatcher routing, a flat score, and a fake model for the fallback wording, the credit, and an emoji in the reply. No new dependencies.