From 9c8332d4442ddd569aacc37f2000fb0afe36111e Mon Sep 17 00:00:00 2001 From: Tyler Hoang Date: Tue, 12 May 2026 03:44:40 -0700 Subject: Pantry-first AI prompts, recipe editing, and grocery copy - Rewrite menu generation to build recipes around existing pantry ingredients (max 4-5 extras per recipe); add in_pantry flag per ingredient for downstream accuracy - Flip grocery list logic to ONLY include items not in the pantry, with explicit cross-check rule instead of include-everything default - Strengthen no-menu grocery prompt to handle empty vs. stocked pantry - Rewrite Commis chat system prompt to treat kitchen context as source of truth with explicit response rules per query type - Align replacement/single-recipe prompts to prefer pantry coverage - Update system_prompt default to reflect pantry-first identity - Add PUT /api/recipes/:id endpoint for recipe editing - Add inline edit mode to recipe detail page (name, type, ingredients, instructions, time, servings) - Add Copy button to grocery list (exports markdown checklist) Co-Authored-By: Claude Sonnet 4.6 --- routers/recipes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'routers/recipes.py') diff --git a/routers/recipes.py b/routers/recipes.py index 000f945..d06c335 100644 --- a/routers/recipes.py +++ b/routers/recipes.py @@ -49,6 +49,19 @@ def get_recipe(id: int, db: Session = Depends(get_db)): return recipe +@router.put("/{id}", response_model=RecipeRead) +def update_recipe(id: int, update: RecipeUpdate, db: Session = Depends(get_db)): + """Update a recipe.""" + recipe = db.query(Recipe).filter(Recipe.id == id).first() + if not recipe: + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Recipe not found") + for field, value in update.model_dump(exclude_unset=True).items(): + setattr(recipe, field, value) + db.commit() + db.refresh(recipe) + return recipe + + @router.delete("/{id}", status_code=status.HTTP_204_NO_CONTENT) def delete_recipe(id: int, db: Session = Depends(get_db)): """Delete a recipe.""" -- cgit v1.3-2-g0d8e