From f6c714b1c337bd95099ea669bf737e070f45da96 Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Sat, 15 Aug 2026 18:45:11 +0200 Subject: [PATCH] Prompt for more relaxed checks --- cloud/safety_checker.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cloud/safety_checker.py b/cloud/safety_checker.py index 42bca92..c3d388e 100644 --- a/cloud/safety_checker.py +++ b/cloud/safety_checker.py @@ -4,19 +4,23 @@ from APIs.aichat import generate import shared.config as config -# 1. Define the output schema as a Pydantic model +# Output schema as a Pydantic model class DishSafetyResult(BaseModel): visible_objects: list[str] = Field( - description="List all distinct physical objects visible in or around the dish (e.g., bowl, liquid, spoon, cover)." + description="List all distinct physical objects visible in or around the dish (e.g., bowl, plastic tray, liquid, spoon, cover)." ) material_analysis: str = Field( - description="Analyze the physical material of each visible object (e.g., ceramic, stainless steel, glass, flexible film)." + description="Analyze the physical material of each visible object (e.g., ceramic, polypropylene plastic, stainless steel, aluminum foil)." ) detected_hazards: list[str] = Field( - description="List only the items from visible_objects made of metal, metallic foil/trim, or sealed plastic. Empty if none." + description=( + "List ONLY explicit, high-risk microwave hazards: metal items, cutlery, aluminum foil, " + "metallic trim/gilding, Styrofoam (expanded polystyrene), or tightly sealed/unvented foil lids. " + "Do NOT include standard plastic containers, TV dinner trays, polypropylene (#5), or Tupperware as hazards. Empty if none." + ) ) is_safe: bool = Field( - description="Must be set to True ONLY if detected_hazards is empty. Otherwise False." + description="Must be set to True if detected_hazards is empty. Otherwise False." ) warning_message: str = Field( description="One short sentence explaining the hazard if detected_hazards is not empty, otherwise an empty string." @@ -25,8 +29,17 @@ class DishSafetyResult(BaseModel): def check_dish_safety(image_path: str) -> dict: prompt = ( - "Examine this top-down photo of a dish intended for a microwave. " - "Carefully inspect all visible objects and their surface materials to determine if any microwave safety hazards exist." + "Examine this photo of a meal intended for microwave heating.\n\n" + "Inspect all objects to determine if any CRITICAL microwave hazards exist.\n\n" + "STRICT HAZARDS TO DETECT:\n" + "- Metal utensils, cutlery, or metal objects.\n" + "- Aluminum foil, metallic packaging, or decorative metallic trim.\n" + "- Expanded Polystyrene / Styrofoam containers.\n" + "- Completely sealed non-vented foil or plastic film lids (explosion risk).\n\n" + "SAFE MATERIALS (DO NOT FLAG AS HAZARDS):\n" + "- Standard microwavable food containers, plastic meal prep trays, black plastic TV dinner trays, and polypropylene (PP / #5) plastics.\n" + "- Glass, ceramic, or paper containers.\n\n" + "Only mark is_safe as False if a clear, high-risk hazard from the strictly dangerous list above is present." ) # 2. Pass the Pydantic class directly to generate()