我教會鬧鐘討價還價:由開放權重 Gemma 驅動
I Taught My Alarm Clock to Negotiate (Powered by Open-Weight Gemma)
Sleep Bargain 讓用戶與由 Gemma 驅動的鬧鐘 Meep 討價還價,按出門時間、準備時間及緩衝時間計算可延後的分鐘數。預設使用 Cloudflare Workers AI 上的 Gemma 4;支援 WebGPU 的裝置亦可選用 WebLLM 在本機執行 Gemma 2 2B。談判紀錄會存入 Snooze Ledger,模型負責判斷藉口類型及撰寫回覆,不決定延後時間。
This is a submission for the Hacktoberfest Open-Source AI Challenge: Week 3.
What I Built
I'm a snoozer. A serial, unapologetic snoozer. The trouble is that the snooze button is dumb. It gives me 9 minutes whether I can afford them or not.
So I built Sleep Bargain. When the alarm rings, you don't smash a button. You bargain. "5 more minutes, I was up late." Meep, a tiny sassy alarm creature, checks your morning and answers.
If you can afford it, you get it. If your excuse is "my bed is cozy," Meep counteroffers. If you're already cutting it close, Meep says no, warmly but firmly. Every deal lands in a Snooze Ledger, so you can see how many minutes you won (and lost) this week.
Demo
Try it: https://sleep-bargain.casmazariegos.workers.dev
Code
🐣 Sleep Bargain
Don't hit snooze. Negotiate. Tell the alarm "5 more minutes, I was up late" and Meep, a tiny alarm creature powered by Gemma running entirely in your browser, bargains with you. It grants exactly as many minutes as your morning can afford, teases weak excuses, and makes counteroffers. Every deal goes in the Snooze Ledger.
Built for the DEV Hacktoberfest Open-Source AI Challenge, Week 3 ("Slow and Steady").
Live: https://sleep-bargain.casmazariegos.workers.dev
How it works
-
Two Gemma brains, one rulebook.
-
Default: ☁️ Gemma 4 on Cloudflare Workers AI (
@cf/google/gemma-4-26b-a4b-it, thinking off), viaPOST /api/negotiateinsrc/worker.js. Works on every device, iPhone Safari included. - Optional: 📱 on-device Gemma 2 2B with WebLLM: a toggle that only appears when WebGPU exists (desktop Chrome/Edge). Nothing leaves the device.
- Offline: 📜 line bank if the server can't be reached. The UI always shows which brain answered.
-
Default: ☁️ Gemma 4 on Cloudflare Workers AI (
- Code…
How I Built It
My first version was a pushover. I tested it on my iPhone, said "I'm sleepy" five times, and Meep said yes five times. Rude. So I rebuilt her to fight back.
Gemma, two ways. By default Meep's brain is Gemma 4 on Cloudflare Workers AI, behind a tiny Worker endpoint, so she works on any phone. If your browser has WebGPU, you can flip a toggle and run Gemma 2 on-device with WebLLM, so nothing leaves your laptop. The app always shows you which brain is talking.
The model never picks the number. Plain code does the minutes: time until you leave, minus getting-ready time, minus a buffer. The same tested logic runs on the server and in the browser.
Meep bargains hard. Your first ask almost always gets a lower counteroffer and a side quest. "6 minutes if you drink a full glass of water first." Snooze two gets less. Snooze three is a stern FINAL OFFER. Snooze four? She refuses and rings again, louder. 🚨 Lame excuses get two minutes, then a flat no.
You have to answer. No auto-accepting. You tap Accept deal, Counter, No deal, or Fine, I'm up. She'll meet you halfway once, then she holds the line. Turn her down and those minutes go in the ledger as Lost.
Gemma does the personality. It sorts your excuse (tired, sick, cold, weekend-ish, lame, or creative) as tiny JSON. Then it writes Meep's reply, quoting your excuse and roasting it, with your real leave time in there. A guardrail tosses any reply that mentions a different number of minutes.
Here's real Gemma, live: I typed "I'm sleepy" and Meep said: "'I'm sleepy' is the most unoriginal thing I've ever heard. I'll give you 2 minutes if you promise to drink a full glass of water first." Finally, some backbone.
Why Does Open Innovation Matter?
An alarm lives in your bedroom. It hears your excuses at your sleepiest. That should stay on your device.
Because Gemma is open-weight, the same model family runs in two places: in the cloud on Workers AI for phones, and fully on-device through open-source WebLLM for anyone who'd rather keep their excuses private. Anyone can fork it, change Meep's personality, or swap in a different open model. Open tools let a small, silly idea like this exist without a cloud bill.
The Lazy Payoff
I get to stay in bed and feel productive. I negotiated! I won 7 minutes! And because the math is honest, those 7 minutes are actually free. No guilt, no sprinting to the car.
Slow and steady wins the race. Slow and strategic wins the snooze.
Prize Categories
Best Use of Gemma. Gemma 4 (on Workers AI) and Gemma 2 2B (on-device via WebLLM) classify every excuse and write every one of Meep's negotiation replies.
來源:DEV Community · dev.to








