| title | Bridge Game Postmortem Chatbot |
|---|---|
| emoji | 🥸 |
| colorFrom | indigo |
| colorTo | yellow |
| sdk | streamlit |
| sdk_version | 1.26.0 |
| app_file | app.py |
| pinned | false |
| license | mit |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Project to provide high-level postmortem game information using a chat interface. User can either use vetted prompts, such as via the Summarize button, or custom prompts. Games are limited to ACBL club pair matchpoint games which used a Mitchell movement and not shuffled.
Try it live at: https://huggingface.co/spaces/bsalita/Bridge_Game_Postmortem_Chatbot
For a list of related projects and documents see: https://github.com/BSalita/BridgeStats
The sidebar options are mirrored into the URL query string so any view is shareable / bookmarkable. Supported parameters:
| Param | Maps to sidebar option | Example value |
|---|---|---|
player_id |
ACBL player number | 2663279 |
session_id |
Club game or tournament session | 6534522 |
show_sql_query |
Developer Settings → Show SQL | 1 / 0 |
sd_samples |
Single Dummy Samples Count | 10 |
Example: https://acbl.postmortem.chat/?player_id=2663279&session_id=6534522
loads that exact game directly.
acbl_postmortem_generator.py drives the live app in a headless browser,
captures the generated PDF, and emails it. Combined with the included
PowerShell helper this becomes a daily "did the player play today? if so,
mail me the report" job.
One-time setup:
pip install -r requirements.txt
playwright install chromiumThen put SMTP credentials in a .env file next to app.py. Gmail with an
App Password is the path that's tested and working:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=you@gmail.com
SMTP_PASSWORD=xxxxxxxxxxxxxxxx # 16-char Google app password, no spaces
SMTP_FROM=you@gmail.comImportant Gmail gotchas:
SMTP_USERandSMTP_FROMmust match the Google account that owns the app password. You cannot use a Yahoo (or other) address as the sender on a Gmail-authenticated connection -- Gmail will reject the message.- 2-Step Verification must be enabled on that Google account; otherwise the
"App passwords" page won't be available and any password you paste will
fail with
535-5.7.8 Username and Password not accepted. - The app password is 16 characters with no spaces (Google shows it with
spaces just for readability -- strip them when saving to
.env).
Email the player's most recent game right now (uses .env):
python acbl_postmortem_generator.py `
--url "https://acbl.postmortem.chat/?player_id=2663279" `
--email coach@example.comForce a re-send even if the cache says it already went out, and print the full SMTP conversation if something looks wrong:
python acbl_postmortem_generator.py `
--url "https://acbl.postmortem.chat/?player_id=2663279" `
--email coach@example.com `
--force-email `
--smtp-debugGenerate the PDF locally without sending email (handy for testing the browser side in isolation):
python acbl_postmortem_generator.py `
--url "https://acbl.postmortem.chat/?player_id=2663279" `
--email me@example.com `
--output report.pdf `
--no-emailPass SMTP settings on the command line instead of via .env:
python acbl_postmortem_generator.py `
--url "https://acbl.postmortem.chat/?player_id=2663279" `
--email coach@example.com `
--from-email you@gmail.com `
--smtp-host smtp.gmail.com `
--smtp-port 587 `
--smtp-user you@gmail.com `
--smtp-password "xxxxxxxxxxxxxxxx"Register a daily 6 PM scheduled task:
.\schedule_daily_report.ps1 `
-Url "https://acbl.postmortem.chat/?player_id=2663279" `
-Email coach@example.com `
-Time 18:00What the scheduled run does each evening:
- Purges any cached PDFs in
report_cache\whose mtime is older than the TTL (default 168 h / 1 week). The TTL is a sliding window: every cache hit refreshes the file's mtime, so an entry survives indefinitely as long as the player hasn't played a newer game. - Opens the URL in headless Chromium and waits for the report metadata.
- Always loads the player's most recent game (no date filter).
- Skips silently if
report_cache\{player_id}_{game_date}.pdfalready exists -- the cache assumes the report was already emailed for that game. - Otherwise downloads the PDF, stores it in the cache, and emails it.
Net effect: each game produces exactly one email, no matter how often the scheduler runs in between, and no matter how many days pass between games.
Remove the scheduled task:
.\schedule_daily_report.ps1 -UnregisterIf a real run fails at the email step, run test_smtp.py to bisect whether
the problem is in the browser/PDF side or in SMTP itself. By default it
reads SMTP_* from your .env:
# Just connect, EHLO/STARTTLS, and authenticate -- don't actually send:
python test_smtp.py --no-send
# Send a tiny test message to yourself:
python test_smtp.py"# Bridge_Game_Postmortem_Chatbot"