跳到正文
DEV Community· Jeffrey Turov·· 2 小時前AI 評分53

Sloth Digest 以本地 Gemma 3 4B IT 分流 Gmail 未讀電郵

Sloth Digest 🦥 — a local Gemma 3 agent that does my inbox triage so I don't have to

AI 導讀

Sloth Digest 是一款本地 AI 智能體,使用 Gemma 3 4B IT(QAT)和 llama.cpp 將 Gmail 未讀電郵分成三類,生成按緊急程度分組的晨間摘要。

正文

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built

Sloth Digest is a local AI agent that reads my unread Gmail overnight and hands me a morning digest, so I never have to open a cold inbox again.

Every email gets triaged by an open-weight model running entirely on my own machine (Gemma 3 4B IT, QAT-quantized, served by llama.cpp on plain CPU) into three buckets:

  • ⚡ Needs you — reply, pay, confirm, decide — each with a suggested one-line action
  • 👀 Worth 10 seconds — FYI, no action needed
  • 😴 Skip safely — promos, newsletters, notification noise

Who gets to be lazier? Me, every single morning. Instead of 15–30 minutes of scanning subject lines and context-switching, I read one short markdown page and only touch the 3–4 emails that actually need a human.

Here's real output from the bundled sample inbox:

# 🦥 Sloth Digest — morning triage

## ⚡ Needs you (4)
- **Energia Lux** — Your October invoice — €84.12 due Oct 27
  Electricity bill of €84.12 is due soon.
  → Pay the invoice before October 27th.
- **Marco Silva** — Re: Thursday moved to 15:00?
  Plumber availability needs confirmation for Thursday.
  → Confirm 15:00 or propose an alternative time.
...

## 😴 Skip safely (1)
- **ShopMega** — 🔥 70% OFF ends tonight — don't miss out!
  Promotional email about a limited-time sale.

6 emails triaged locally in 14s (~12 min of manual triage saved).
Nothing left this machine.

Demo

Live demo: https://friend-crops-sharp-episode.trycloudflare.com

It shows the sample inbox (6 fake emails — bills, a friend asking for a confirmation, a flash sale, a delivery notice, a medical appointment reminder) and runs the triage live on the local Gemma model when you hit the button. ~14 seconds on CPU, no cloud API involved anywhere.

You can reproduce the whole thing offline:

./llama-server -m gemma-3-4b-it-qat-Q4_0.gguf --port 8801
python sloth_digest.py --demo   # sample inbox, zero credentials needed

Code

GitHub logo jeffreyturov-dev / sloth-digest

Local AI agent that triages your Gmail overnight into a morning digest — Gemma 3 4B, 100% offline, privacy-first

🦥 Sloth Digest

A local AI agent that reads your unread Gmail overnight and hands you a morning digest — so you don't have to.

Every email is triaged into three buckets by an open-weight model running entirely on your own machine (Gemma 3 4B IT QAT via llama.cpp):

  • ⚡ Needs you — reply, pay, confirm, decide (with a suggested action)
  • 👀 Worth 10 seconds — FYI, no action
  • 😴 Skip safely — promos, newsletters, notification noise

No email content ever leaves your computer. Works offline. Costs nothing per run — set it up once and forget it.

Why local?

Your inbox is the most private dataset you own. A closed API means sending every message — invoices, medical appointments, personal threads — to someone else's servers. Sloth Digest runs the whole pipeline against a local OpenAI-compatible endpoint, so the "open" piece is the product:

  • Privacy: nothing leaves the…

The agent is ~200 lines of Python stdlib. The only dependencies are llama.cpp (for inference) and, for the optional web UI, FastAPI.

How I Built It

The architecture is deliberately boring — a sloth would approve:

unread Gmail ──► fetch (Gmail API, strictly read-only)
                   │
                   ▼
        ┌─────────────────────┐
        │ Gemma 3 4B IT (QAT) │  per email: CATEGORY / SUMMARY / ACTION
        │ llama.cpp, CPU      │  strict 3-line verdict, temperature 0
        └─────────────────────┘
                   │
                   ▼
        morning digest (markdown, grouped by urgency)

Three design choices make a small 4B model reliable enough to trust with triage:

  1. Rigid output contract. The model must answer with exactly three lines (CATEGORY / SUMMARY / ACTION) at temperature 0. No essays, no JSON to break.
  2. Graceful degradation. Anything unparseable lands in "check manually" instead of being silently misfiled. A triage tool that hides emails is worse than no tool.
  3. Read-only by construction. The agent fetches unread mail and prints a digest. It never marks, archives, or deletes anything — the worst it can do is be wrong on a page you skim anyway.

Local inference is not a gimmick here, it's the point: the whole pipeline — fetch, classify, summarize — runs against llama.cpp's OpenAI-compatible endpoint on 127.0.0.1. Pull the network cable and it still works.

Why Does Open Innovation Matter?

Your inbox is probably the most private dataset you own: invoices, medical appointments, family threads, business negotiations. Triage means reading all of it — and with a closed API, "reading" means shipping every message to someone else's servers, on someone else's terms, under a privacy policy that can change.

Because Gemma's weights are open and llama.cpp is open source, the equation flips:

  • Privacy by architecture, not by promise. Nothing leaves the machine, so there's nothing to leak, log, or train on.
  • Works offline. Plane, cabin, outage — the digest still runs.
  • Free forever. No per-token bill. I set it up once and it costs me exactly zero per run, forever. That's the sloth economics a closed API can never offer.

The Lazy Payoff

I ran it on my real unread inbox this morning: 8 emails triaged in ~20 seconds, and the digest correctly separated two things I genuinely needed to act on from the newsletter noise. Manual triage averages ~2 minutes per email once you include the context-switching — so the agent saves me roughly 15 minutes a day, ~90 hours a year, for a one-time setup cost and €0 in API fees.

The cron job runs at 7am. I wake up, read one page, and go back to being lazy. The sloth wins. 🦥

Prize Categories

  • Best Use of Gemma — Gemma 3 4B IT (QAT) is the entire brain of the agent, running locally via llama.cpp.

來源:DEV Community · dev.to