Better prompt ?
Build, push image, and notify Watchtower / build-image (push) Successful in 46s
Build, push image, and notify Watchtower / notify (push) Successful in 18s

This commit is contained in:
2026-08-15 18:50:54 +02:00
parent 07ce941950
commit 36abfc8234
+12 -21
View File
@@ -4,42 +4,33 @@ from APIs.aichat import generate
import shared.config as config import shared.config as config
# 1. Output schema with strict anti-hallucination descriptions
class DishSafetyResult(BaseModel): class DishSafetyResult(BaseModel):
visible_objects: list[str] = Field( visible_objects: list[str] = Field(
description="Objective list of physical items visible (e.g., 'black plastic tray', 'stew', 'plastic fork'). Do NOT categorize them as safe or hazards here." description="List physical container items and utensils visible in the image."
) )
material_analysis: str = Field( material_analysis: str = Field(
description="Describe physical materials based strictly on visual cues. Note: Smooth, rigid black plastic meal trays are Polypropylene/CPET plastic (safe), NOT foam/styrofoam." description="Brief description of container material (e.g., standard plastic tray, glass bowl)."
) )
detected_hazards: list[str] = Field( detected_hazards: list[str] = Field(
description=( description="List of visually confirmed metal or foil hazards. MUST be empty [] if no metal or foil is present."
"List ONLY explicit physical hazards: metal utensils/cutlery, aluminum foil/wrappers, "
"metallic foil trim, spongy white foam/styrofoam containers, or airtight unvented plastic wrap. "
"Rigid black or clear plastic meal trays are NOT hazards. Empty if none."
)
) )
is_safe: bool = Field( is_safe: bool = Field(
description="Set to True if detected_hazards is completely empty. Otherwise set to False." description="Set to True if detected_hazards is empty. Set to False ONLY if metal or aluminum foil is present."
) )
warning_message: str = Field( warning_message: str = Field(
description="One brief sentence warning if detected_hazards is non-empty, otherwise an empty string." description="Short warning if is_safe is False, otherwise an empty string."
) )
def check_dish_safety(image_path: str) -> dict: def check_dish_safety(image_path: str) -> dict:
prompt = ( prompt = (
"Analyze this food image for critical microwave safety hazards.\n\n" "Analyze this food image for microwave safety.\n\n"
"MATERIAL IDENTIFICATION RULES:\n" "DEFAULT ASSUMPTION:\n"
"- Black plastic meal trays / TV dinner containers = Smooth, rigid Polypropylene (PP) or CPET plastic. These are STANDARD MICROWAVE MEAL TRAYS and are SAFE.\n" "- Assume the dish is SAFE (is_safe = True, detected_hazards = []).\n"
"- Styrofoam / EPS = White or light-colored spongy, cellular foam. (Do NOT misclassify smooth black plastic as styrofoam!).\n\n" "- Standard food (meat, vegetables, potatoes) and standard containers (black plastic meal trays, plastic bowls, ceramic, glass) are 100% SAFE for microwaves.\n\n"
"STRICT HAZARDS TO LOOK FOR:\n" "STRICT HAZARD RULE:\n"
"1. Metal objects (metal forks, spoons, knives, metal bowls).\n" "- Flag as UNSAFE ONLY if you can literally see actual metal cutlery (metal spoon/fork/knife), aluminum foil packaging, or metal foil trim in the image.\n"
"2. Aluminum foil or foil packaging.\n" "- Do NOT invent or hallucinate hazards. If you do not see shiny metal or aluminum foil, detected_hazards MUST be an empty list []."
"3. Metallic gold/silver decorative trim on ceramic dishes.\n"
"4. White spongy foam / Styrofoam packaging.\n"
"5. Tightly sealed, unvented plastic film or foil lids.\n\n"
"If the meal is simply inside a standard black plastic tray or ceramic/glass dish without any metal/foil/foam present, flag it as SAFE (is_safe = True)."
) )
response_raw = generate( response_raw = generate(