Skip to content
UsecaseBoard
← All use cases
devtoAI Workflows

Load user preferences before generating and checking a meal plan

At a glance

ForkCount's builder repaired an AI meal generator by loading profile settings first, including the diet in the prompt, and checking returned ingredients. This workflow is listed under AI Workflows, Validation, Debugging.

SourceBuilding a tool for these workflows? See weekly rates.

What they did

1) In the React/Vite meal-planning app, identify the signed-in user's Supabase profile and the code that invokes the AI generator. The implementation needs `target_calories` and `dietary_preference`. 2) Await the profile query before generation. If the profile or calorie target is missing, stop with an explicit error rather than silently using 2,000 calories. 3) Insert the loaded diet into the generation prompt and explicitly exclude meat, poultry, and fish for a vegetarian profile. 4) Before displaying the generated plan, iterate over each meal's ingredients. For vegetarian users, compare lowercase ingredients against the reported forbidden terms: turkey, chicken, beef, pork, lamb, and fish. Regenerate any flagged meal. Finish with the checked plan rather than displaying the raw response.

How it went

The author traced the vegetarian failure to an unconstrained prompt and the calorie mismatch to generation starting before profile loading finished.

Worth knowing

The published ingredient check covers six substrings, so its coverage is limited to that list.

Save ideas in this browser. Upvotes count across the board.

Prompt excerpt

No prompt excerpt was provided by the source.

Sponsored

CodeBuddy

Tencent Cloud AI coding assistant for IDE and CLI.

Try CodeBuddy ↗
Explore all →