Better prompt again ?
Build, push image, and notify Watchtower / build-image (push) Successful in 34s
Build, push image, and notify Watchtower / notify (push) Successful in 15s

This commit is contained in:
2026-08-23 16:51:27 +02:00
parent 7c35b52dbd
commit 1f53e7e6c3
+16 -10
View File
@@ -4,25 +4,31 @@ from APIs.aichat import generate
import shared.config as config import shared.config as config
class DishSafetyResult(BaseModel): class DishSafetyResult(BaseModel):
visible_objects: list[str] = Field(
description="List EVERY distinct item visible in the frame (e.g., ['ceramic bowl', 'rice', 'metal spoon handle', 'stew'])."
)
spoon_or_utensil_present: bool = Field(
description="Set to True if ANY metal, plastic, or wooden spoon, fork, knife, or utensil is present anywhere in or around the container."
)
is_safe: bool = Field( is_safe: bool = Field(
description="Set to True if the dish contains ONLY normal food, rice, stew, and ceramic/glass/plastic bowls. Set to False ONLY if shiny metallic cutlery (spoon/fork/knife) or metallic foil is present." description="Set to False if spoon_or_utensil_present is True, or if aluminum foil or metal is present. Set to True ONLY if pure food/bowl with zero utensils."
) )
detected_hazards: list[str] = Field( detected_hazards: list[str] = Field(
description="List ONLY physical metal objects found (e.g., ['metal spoon']). If is_safe is True, this MUST be an empty list []." description="List ONLY physical hazard items found (e.g., ['metal spoon']). Empty list [] if safe."
) )
warning_message: str = Field( warning_message: str = Field(
description="Clear warning if is_safe is False, otherwise empty string ''." description="Warning statement if unsafe, otherwise empty string ''."
) )
def check_dish_safety(image_path: str) -> dict: def check_dish_safety(image_path: str) -> dict:
prompt = ( prompt = (
"You are a strict microwave safety vision inspector.\n\n" "You are an expert microwave safety quality inspector analyzing a top-down camera frame.\n\n"
"TASK: Inspect the top-down photo of the dish for ANY metal or plastic utensils (spoons, forks, knives, metal handles) or aluminum foil.\n\n" "INSPECTION STEPS:\n"
"CRITICAL RULES:\n" "1. Carefully examine the perimeter, edges, and inner cavity of the bowl/container.\n"
"1. Look closely at the edges and interior of the bowl for utensil handles sticking out, even if they appear dark or shadowed.\n" "2. Identify any utensil handles (spoons, forks, knives) protruding from or resting in the dish, regardless of shadow or reflectivity.\n"
"2. If you see ANY spoon handle, fork, knife, or utensil body—whether shiny silver, grey, or dark metal—mark is_safe = False.\n" "3. List all visible items in `visible_objects` first.\n"
"3. ONLY mark is_safe = True if the bowl contains 100% food and rice with NO protruding utensils or foreign objects.\n" "4. If a utensil or metal object is present anywhere, `spoon_or_utensil_present` MUST be True and `is_safe` MUST be False.\n"
"4. If a spoon or utensil is detected, set detected_hazards = ['metal spoon'] and warning_message = 'Please remove the metal utensil before microwaving.'" "5. `is_safe` is True ONLY if the container holds strictly food with no utensils or metal."
) )
response_raw = generate( response_raw = generate(