跳到正文
DEV Community· Academic·· 3 小時前AI 評分43

Aaj Kya Banau?:我不再決定晚餐,交給樹懶代勞

I Stopped Deciding Dinner — a Sloth Does It Now (आज क्या बनाऊँ?)

AI 導讀

Aaj Kya Banau? 是一款協助決定晚餐的印度家常菜推薦工具,以確定性配對器從 40 道食譜中選出最多 3 道,按缺少食材、所需心力及烹調時間排序。工具提供 52 種常見食材選項,Gemma 負責撰寫菜式介紹、提示及解析自由輸入的食材,不會選擇菜式或新增食材。應用程式可在 mock mode 完全離線運作,毋須 API key 或網絡連線。

正文

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

What I Built

The question that ruins 6 PM every day is not "can I cook?" — it is "आज क्या बनाऊँ?" (what should I cook today?). Standing in front of an open fridge, recalculating the same inventory for the thousandth time, while hungry. That is decision fatigue, and it costs more energy than the cooking.

आज क्या बनाऊँ? (Aaj Kya Banau?) ends the ritual:

  • Tick your kitchen once. 52 common Indian-kitchen ingredients as checkboxes in four groups — atta, chawal, dals, sabzis, dahi, masale. The browser remembers it (Gradio BrowserState) — no account, no server-side storage, nothing leaves your device.
  • Say how lazy you feel — कम मेहनत caps suggestions at effort 2 out of 5.
  • Press one button. The first card is tonight's dinner. A deterministic matcher picks the top 3 from a 40-recipe open database, ranked by fewest missing items, then least effort, then least time.
  • "एक चीज़ ले आओ" (bring just one thing) — nothing perfect in the kitchen? Instead of pretending, it shows what is one ingredient away: बस टमाटर ले आओ, और सैंडविच बन जाएगा.
  • Gemma only writes the mood. A short Hinglish verdict, a one-line pitch and chef tip per dish, and it parses your genuinely messy free text ("thoda basi chawal hai, aadha gobhi bhi") onto the ingredient vocabulary. It never chooses recipes and never invents ingredients — every id in its JSON output is clamped to the database shipped in the repo.
  • Model down does not mean dinner down. No API key, no network, rate-limited? The matcher still decides; pitches and tips fall back to the recipe database itself. The app works fully offline in mock mode.

Demo

Live app: https://aaj-kya-banau-rcaf.onrender.com/ (free tier — first load may take a minute to wake)

Tick your kitchen — the browser remembers it

Free text + how lazy are you today

Gemma writing the verdict

Tonight's verdict and top 3 cards

The one-away shortlist and the shopping list

A real session from testing: with chawal, dahi, aloo, pyaz, tamatar and basics ticked, plus "thoda basi chawal hai, aadha gobhi bhi" typed in the free-text box, the app picked दही-चावल (5 minutes, zero shopping) as tonight's dinner, put मसाला मैगी second — and, because "basi chawal" was parsed onto the vocabulary, बासी चावल भुना (fried rice from yesterday's rice) appeared as card 3. The whole round trip, including Gemma's verdict and pitches, took 88 seconds on the free tier.

Code

Everything is on GitHub (MIT, recipes included): https://github.com/Yuser00123/aaj-kya-banau

File Role
kitchen.py 52-ingredient vocabulary + the matcher (all decisions happen here)
recipes.py the 40-recipe open database — plain, editable Python
prompts.py Gemma's narrow job: the prompt, the clamp, the offline fallback
llm.py provider adapter (any OpenAI-compatible endpoint, Ollama, or mock)
app.py Gradio 6 UI, BrowserState persistence, /health, PWA

Adding your family's recipe is deliberately boring — no JSON, no schema, eight-ish lines of Python:

R("gobhi_paratha", "गोभी पराठा", "🫓", ["atta", "phool_gobhi"],
  ["pyaz", "adrak", "lasun", "namak", "tel"], 3, 40, True,
  ["Gobhi kaddukas karke namak laga ke 10 minute chhod do.",
   "Atta gundh ke parathe banao, bhigote bhar lo.",
   "Tawe par ghee ke saath sunhare ho tak seko."],
  "Sunday-feeling dinner, aaj hi bana lo.",
  "Kaddukas geela lage to kapde mein kas ke nikaal do — paratha phulega.")

verify() runs on import and refuses to start the app with a bad ingredient id — a PR that breaks the kitchen breaks the tests. The test suite is 45 offline checks (matcher rules, veg filter, effort caps, free-text parsing, prompt clamping, the /health endpoint) that need no API key and no network.

How I Built It

Before writing code I read the week's entries first — when I checked, the field was full of file sorters, inbox tidiers and chat digesters. Recipe deciders existed but generic, so the opening was: an Indian-kitchen ground truth (a fixed, realistic ingredient vocabulary) and an open recipe database anyone can extend. That is what the sloth sits on.

The central design decision: decisions in code, mood in the model.

  • The matcher is ~40 lines of pure Python: missing <= 0 means perfect, missing == 1 lands the dish in the one-away list, and a sort key of (missing, fits-sloth-level, effort, minutes) ranks everything else. If nothing fits today's laziness cap, it relaxes the bar and says so loudly instead of quietly returning nothing.
  • Free text gets a deterministic first pass — Hindi labels and Roman aliases, longest match first, with matched text consumed so "basi chawal" does not also fire "chawal" — and Gemma handles the truly messy rest.
  • Gemma makes one JSON call (verdict, per-recipe pitch/tip, parsed_extras, shopping_line) through Gemini's OpenAI-compatible endpoint. The response is then clamped: invented recipe ids are dropped, unknown ingredients are dropped, empty fields are filled from the database. The model can flavor the dinner; it cannot change what's for dinner.

An AI coding agent did most of the typing on this one — the ingredient vocabulary, the matcher rules, the recipe database format and the clamp logic were designed in conversation and I reviewed and tested everything (including catching that my first draft pointed आलू-गोभी at cabbage instead of cauliflower — in most Indian kitchens that dish is फूलगोभी).

Deployment is a Render Blueprint from the repo (render.yaml): free web service, health check on /health, the Gemini key as the only secret.

Why Does Open Innovation Matter?

Because the interesting part of this app is not the model — it is the database. Forty everyday recipes in a plain Python file, MIT licensed, eight lines to add your mother's version, with a verifier that keeps contributions honest. A hundred families forking it and adding their own recipes is worth more than any prompt engineering I could do.

And because a small open-weight model, clamped to ids from an open repository, gives AI-flavored writing without AI-authored facts. Swap the endpoint to a local Ollama with one environment variable and the app never talks to a cloud at all — the sloth keeps deciding dinner either way.

Prize Categories

  • Render — deployed as a Blueprint (render.yaml), free web service, /health health check, sleeps and wakes like a proper sloth.
  • Gemma — Gemma writes the verdict, pitch and tips and parses messy kitchen notes; JSON mode, single call, output clamped to the open recipe database.

來源:DEV Community · dev.to