DEV Community

lalit sonawane
lalit sonawane

Posted on

Build for friend

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

I cook for one person. Their allergies are specific, their week is usually a mess, and a normal meal app is a bad place for both of those facts.
Their Table plans five dinners for that one person. I type their name, what they cannot eat, and a note about this week in their words: exam week, nothing heavy after 9, a guest on Friday. An open-weight model reads that note and picks from a kitchen list. A checker on the laptop throws the plan out if a dish does not clear their card.
The card starts empty. The sample profile in the app is labeled as an example, because their allergy list is not something I want in a blog post. Before I cook, I replace the name with theirs.
Coconut is its own switch. It is not treated as a tree nut.

Demo

There is no hosted demo on purpose. A public URL would put their card on a server, which is the thing this project refuses to do.
Clone it and run it on the laptop you cook from:
git clone https://github.com/sonawanelalit574/Build_for_friend
cd Build_for_friend
python -m http.server 5173
Open buildforfriend.vercel.app. The first plan downloads the weights into that browser. After that, a new week can be planned with the wifi off. Copy for them, or print the grocery list.

Code

https://github.com/sonawanelalit574/Build_for_friend

Their Table

A week of dinners for one person you cook for. An open-weight model runs in the browser and picks the meals. A small checker on the laptop throws the plan out if it is not safe for them.

Their allergies, the note about their week, and the plan stay in this browser. There is no account and no API key. After the weights download once, a new week can be planned with the wifi off.

Put your person in

The example card is not a real roommate. Open the app, replace the name, and write this week the way they would say it. The model is there to read that note. The checker is there so a small model cannot talk you into a dish they cannot eat.

Coconut is its own switch. It is not treated as a tree nut.

Run it

No install. From this folder:

…
Enter fullscreen mode Exit fullscreen mode

How I Built It

The open model is Gemma 3 270M Instruct, the ONNX build at onnx-community/gemma-3-270m-it-ONNX, running in the browser through Transformers.js. WebGPU uses the q4f16 weights. If the GPU build comes back empty, the same prompt runs again on the CPU build. Decoding is greedy. Sampling on this small Gemma build can return nothing.
Qwen 2.5 0.5B Instruct is one click away, under Apache 2.0. The model box also takes any other Transformers.js text-generation id, so the checker does not have to change when the weights do.
The model is not allowed to invent a recipe. The kitchen list lives in src/recipes.js. Before the model speaks, src/guard.js removes anything that fails their diet, allergens, onion and garlic, cook time, or the foods they asked me not to make. The prompt in src/prompts.js only includes what survived. The model has to come back with recipe ids and a short note about their week.
Ingredients on the card are copied from the file, not from the model's words. If an id is invented, repeated, or missing, that reply is discarded and the model is asked again, up to three times. The raw prompt and the raw reply stay on the page under "How this plan was made." A grocery list is added up in code, scaled for how many people are eating.
node --test test/plan.test.mjs covers the filter, the parser, the retry, and the grocery math. It does not download a model.

Why Does Open Innovation Matter?

A closed API would write a smoother note. It would also want their allergy card, and the sentence about why Friday has to be nicer, on someone else's server. That note is the whole point of the plan. It does not need to leave the laptop, and once the weights are cached it costs nothing to make another week.
A closed model is also a sealed box. Here I can read the checker, change the prompt, and swap Gemma for Qwen when I want a different voice. If the model mentions peanuts in the letter, the page says so. The dishes were still checked. I can read the words before I send them.
The small model is worse at prose than a hosted one. That is acceptable, because it is not the source of the ingredients. It only chooses among dishes the checker has already cleared, and I can see when it fails.

Prize Categories

  • Best Use of Gemma

Top comments (0)