Wiki Jokes: daily LLM jokes from Wikipedia featured article
- FastAPI + APScheduler + SQLite, single container - Daily generation at 06:00 Europe/Copenhagen + cold-start generation - Retry with backoff (3 attempts/15 min), stale fallback with banner - OpenAI-compatible endpoint via env (OPENAI_BASE_URL/MODEL/API_KEY) - docker-compose with named volume for joke persistence
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# Wiki Jokes
|
||||
|
||||
5 jokes every day, generated by an LLM from Wikipedia's *Today's Featured Article*.
|
||||
|
||||
## How it works
|
||||
|
||||
- A scheduled job (06:00 Europe/Copenhagen, plus immediately on cold start) fetches
|
||||
the day's featured article from the Wikipedia REST feed and asks any
|
||||
OpenAI-compatible endpoint for exactly 5 jokes as JSON.
|
||||
- Jokes are stored in SQLite (`/data/jokes.db`) and served instantly — no LLM call
|
||||
at request time.
|
||||
- On failure: retries every 15 min, up to 3 attempts per day. If still failing,
|
||||
the page keeps showing the latest batch with a "stale" note.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
cp .env.example .env # set OPENAI_BASE_URL / OPENAI_MODEL / OPENAI_API_KEY
|
||||
docker compose up -d --build
|
||||
# open http://localhost:8080
|
||||
```
|
||||
|
||||
## Configuration (env vars)
|
||||
|
||||
| Var | Default | Purpose |
|
||||
|---|---|---|
|
||||
| `OPENAI_BASE_URL` | `https://api.openai.com/v1` | OpenAI-compatible endpoint (e.g. llamaswap) |
|
||||
| `OPENAI_MODEL` | `gpt-4o-mini` | Model name |
|
||||
| `OPENAI_API_KEY` | *(empty)* | Bearer token (optional for llamaswap) |
|
||||
| `GENERATE_HOUR` / `GENERATE_MINUTE` | `6` / `0` | Daily generation time |
|
||||
| `MAX_ATTEMPTS` | `3` | Retry budget per day |
|
||||
| `RETRY_MINUTES` | `15` | Retry interval |
|
||||
| `WIKIPEDIA_LANG` | `en` | Wikipedia language for the feed |
|
||||
| `DB_PATH` | `/data/jokes.db` | SQLite location (volume-mounted) |
|
||||
|
||||
## Endpoints
|
||||
|
||||
- `GET /` — today's 5 jokes + link to the featured article
|
||||
- `GET /health` — JSON: whether today's jokes exist / retries exhausted
|
||||
Reference in New Issue
Block a user