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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ LLM_BASE_URL=http://localhost:11434/v1
LLM_API_KEY=ollama
LLM_MODEL=qwen3:8b
LLM_REASONING_EFFORT=none
EMBEDDING_MODEL=nomic-embed-text
EMBEDDING_DIMENSIONS=768
EMBEDDING_BATCH_SIZE=32
DATABASE_URL=postgresql://swellsense:swellsense@127.0.0.1:5432/swellsense
HTTP_USER_AGENT=SwellSense/0.1 (learning project; contact: set HTTP_USER_AGENT)
REQUEST_DELAY_S=1.0
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ on:
jobs:
check:
runs-on: ubuntu-latest
env:
DATABASE_URL: postgresql://swellsense:swellsense@127.0.0.1:5432/swellsense
services:
postgres:
image: pgvector/pgvector:pg17
env:
POSTGRES_USER: swellsense
POSTGRES_PASSWORD: swellsense
POSTGRES_DB: swellsense
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U swellsense -d swellsense"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
Expand Down
7 changes: 6 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ code, with short docstrings explaining why.
- `src/swellsense/llm/`: the only code that talks to the LLM API
- `src/swellsense/extraction/`: structured extraction (boards, unit parsing)
- `src/swellsense/ingest/`: source registry, fetchers, raw document storage, ingest runs
- `src/swellsense/processing/`: cleaning, chunking, and the process run
- `src/swellsense/db/`: local Postgres connection and schema
- `src/swellsense/spots/`: spot profiles and the registry that loads them
- `src/swellsense/tides/`: LINZ Tauranga predictions and tide state at a time
- `src/swellsense/forecast/`: Open-Meteo swell and wind for one spot
Expand All @@ -74,15 +76,17 @@ code, with short docstrings explaining why.
- Verify changes: `bash scripts/check.sh` (lint, format check, then tests; stops at the first failure)
- Apply lint and format fixes: `uv run ruff check --fix && uv run ruff format`
- Download sources: `uv run swellsense ingest` (or `--source ID` for one)
- Process raw pages: `uv run swellsense process` (reads `data/raw/`, embeds via the configured provider, upserts into local Postgres)
- Tauranga tides: `uv run swellsense tides` (or `--date YYYY-MM-DD`)
- Spot forecast: `uv run swellsense forecast SPOT` (or `--hours N`, default 12)
- Conditions check: `uv run swellsense check SPOT` (or `--hours N`, default 12); `uv run swellsense check --all` ranks every spot, with ties shown as ties; `--skill LEVEL` lists harder spots separately
- Chat: `uv run python -m swellsense.chatbot` (conditions questions use the spot tools)
- Local Postgres: `docker compose up -d`, then `uv run swellsense db init`

## Roadmap
1. [x] Foundations: provider-agnostic LLM client, structured extraction
2. [x] Knowledge ingestion: source registry, fetching, raw storage
3. [ ] Processing: cleaning, chunking, local embeddings, Postgres + pgvector (in progress)
3. [x] Processing: cleaning, chunking, local embeddings, Postgres + pgvector
4. [ ] Grounded chat: retrieval with citations
5. [ ] Live conditions: forecast, tides, classifiers, an explainable conditions check and a ranking are in. The chatbot answers a spot check or "where should I go" from those tools. Other answers are not grounded in sources yet.
6. [ ] Spots and maps: spot data and profiles, "where to surf" recommendations
Expand Down Expand Up @@ -115,4 +119,5 @@ Work on the current roadmap stage unless asked otherwise. Don't build ahead.
- Use `uv` for Python 3.13 (`.python-version`). The image's system Python may be older; `uv sync --locked` installs the pinned interpreter.
- Checks: `bash scripts/check.sh`. Tests must not call the network or the LLM.
- There is no dev server. `uv run swellsense ingest` downloads every source into `data/raw/` and writes `data/raw/_last_run.json`. `uv run swellsense ingest --source ID` downloads one source. `uv run swellsense tides` prints Tauranga high and low waters for today and caches the LINZ CSV under `data/cache/`. `uv run swellsense forecast SPOT` prints an Open-Meteo swell and wind table and caches it under `data/cache/forecast/` for one hour. `uv run swellsense check SPOT` rates the next 12 hours and `uv run swellsense check --all` ranks every spot (ties share a rank; `--skill LEVEL` lists harder spots as above your level); both use those caches. Loading `data/sources.yaml` with `swellsense.ingest.registry.load_sources` and parsing board dimensions with `swellsense.extraction.units.parse_dimension` exercises the current product path.
- `uv run swellsense process` reads `data/raw/`, embeds via the configured provider, and upserts into local Postgres (same Ollama embeddings endpoint as the LLM). Postgres is not started in Cloud; tests mock the database and embedder.
- `uv run python -m swellsense.chatbot` expects a local OpenAI-compatible server (default `http://localhost:11434/v1`, see `.env.example`). The environment does not start that server. A conditions question also fetches the Open-Meteo forecast and LINZ tides; tests mock both.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Early development. What works today:

- **Terminal chat** with a local model through Ollama. Conditions questions ("is it worth surfing?", "where should I go?") are answered from the conditions check. The model chooses the tool and phrases the result; the score is computed in code. Other answers are not grounded in sources yet, so treat those with caution.
- **Knowledge ingestion**: downloads surf knowledge from Wikipedia into local storage, keeping the source URL, license and attribution on every document.
- **Processing**: cleans and chunks ingested pages, embeds new or changed chunks via the configured provider, and stores them in local Postgres for retrieval.
- **Tauranga tides**: prints LINZ high and low waters for a day, with the required acknowledgement.
- **Spot forecast**: hourly swell, wind waves and wind for a Bay of Plenty spot, from Open-Meteo.
- **Conditions check**: rates the next few hours at a spot from that forecast, the tide and the spot profile, or ranks every spot by its best hour. Tied scores share a rank, and a skill level leaves harder spots on a separate list.
Expand Down Expand Up @@ -43,9 +44,11 @@ Requires macOS or Linux, [uv](https://docs.astral.sh/uv/) and [Ollama](https://o
ollama pull qwen3:8b
uv sync
cp .env.example .env
docker compose up -d
uv run swellsense db init
```

In `.env`, set `HTTP_USER_AGENT` to identify the project to source sites, for example `SwellSense/0.1 (https://github.com/<you>/swellsense)`.
In `.env`, set `HTTP_USER_AGENT` to identify the project to source sites, for example `SwellSense/0.1 (https://github.com/<you>/swellsense)`. Postgres runs locally via Docker Compose; `DATABASE_URL` in `.env.example` matches the compose service.

## Commands

Expand All @@ -54,13 +57,16 @@ In `.env`, set `HTTP_USER_AGENT` to identify the project to source sites, for ex
| `uv run python -m swellsense.chatbot` | Chat in the terminal (needs Ollama). Conditions questions use the live check |
| `uv run swellsense ingest` | Download all sources into `data/raw/` |
| `uv run swellsense ingest --source wikipedia` | Download a single source |
| `uv run swellsense process` | Clean, chunk and embed `data/raw/` into Postgres |
| `uv run swellsense tides` | Print today's Tauranga highs and lows |
| `uv run swellsense tides --date 2026-01-15` | Print one day's Tauranga tides |
| `uv run swellsense forecast mount-main-beach` | Print 12 hours of swell and wind for a spot |
| `uv run swellsense forecast mount-main-beach --hours 48` | Print a longer forecast |
| `uv run swellsense check mount-main-beach` | Rate the next 12 hours at a spot |
| `uv run swellsense check --all` | Rank every spot by its best hour, showing ties as ties |
| `uv run swellsense check --all --skill beginner` | Rank spots at a skill level, and list the harder ones |
| `docker compose up -d` | Start local Postgres with pgvector (localhost only) |
| `uv run swellsense db init` | Create the documents and chunks schema |
| `bash scripts/check.sh` | Lint, format check and tests |

## Data and licensing
Expand All @@ -80,6 +86,8 @@ src/swellsense/
llm/ the only code that talks to the LLM
extraction/ structured extraction (board specs, unit parsing)
ingest/ source registry, fetchers, storage, ingest runs
processing/ cleaning, chunking, and the process run
db/ local Postgres connection and schema
spots/ spot profiles
tides/ LINZ tide predictions and tide state
forecast/ Open-Meteo swell and wind for one spot
Expand All @@ -96,7 +104,7 @@ scripts/check.sh the single check command

- [x] Foundations: provider-agnostic LLM client, structured extraction
- [x] Knowledge ingestion: source registry, fetching, raw storage
- [ ] Processing: cleaning, chunking, embeddings, Postgres with pgvector
- [x] Processing: cleaning, chunking, embeddings, Postgres with pgvector
- [ ] Grounded chat: retrieval with citations
- [ ] Live conditions: forecast, tides, classifiers, an explainable conditions check and a ranking are in. The chatbot answers a spot check or "where should I go" from those tools. Other answers are not grounded in sources yet.
- [ ] Spots and maps: spot profiles and "where to surf" recommendations
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
postgres:
image: pgvector/pgvector:pg17
ports:
- "127.0.0.1:5432:5432"
environment:
POSTGRES_USER: swellsense
POSTGRES_PASSWORD: swellsense
POSTGRES_DB: swellsense
volumes:
- swellsense_pgdata:/var/lib/postgresql/data

volumes:
swellsense_pgdata:
Loading
Loading