Better prompt
Build, push image, and notify Watchtower / build-image (push) Successful in 40s
Build, push image, and notify Watchtower / notify (push) Successful in 9s

This commit is contained in:
2026-08-23 12:51:55 +02:00
parent 29c943ca5a
commit 467740ba84
+11 -26
View File
@@ -3,41 +3,26 @@ from pydantic import BaseModel, Field
from APIs.aichat import generate from APIs.aichat import generate
import shared.config as config import shared.config as config
class UtensilMaterialCheck(BaseModel):
object_name: str = Field(
description="Name of utensil or container seen (e.g., spoon, fork, tray)."
)
is_metal: bool = Field(
description="True ONLY if the object is made of metal, stainless steel, or aluminum."
)
class DishSafetyResult(BaseModel): class DishSafetyResult(BaseModel):
utensils_and_containers: list[UtensilMaterialCheck] = Field( is_safe: bool = Field(
description="List each visible non-food object and check if it is made of metal." 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."
)
material_analysis: str = Field(
description="Short description of the materials present."
) )
detected_hazards: list[str] = Field( detected_hazards: list[str] = Field(
description="List objects from utensils_and_containers where is_metal is True." description="List ONLY physical metal objects found (e.g., ['metal spoon']). If is_safe is True, this MUST be an empty list []."
)
is_safe: bool = Field(
description="True if detected_hazards is completely empty []. False if ANY metal is found."
) )
warning_message: str = Field( warning_message: str = Field(
description="If is_safe is False, set to 'REMOVE METAL UTENSIL OR FOIL BEFORE MICROWAVING'. Otherwise empty ''." description="Clear warning if is_safe is False, otherwise empty string ''."
) )
def check_dish_safety(image_path: str) -> dict: def check_dish_safety(image_path: str) -> dict:
prompt = ( prompt = (
"Analyze this microwave dish image strictly for EQUIPMENT DAMAGE HAZARDS (Metal, Steel, Aluminum Foil).\n\n" "You are a microwave safety vision inspector.\n\n"
"GOAL:\n" "TASK: Check if this dish contains any REAL METAL CUTLERY (metal spoons, forks, knives) or ALUMINUM FOIL.\n\n"
"Identify if any metallic item (metal spoon, fork, knife, aluminum foil, wire) is inside the dish.\n\n" "CRITICAL RULES:\n"
"RULES:\n" "1. Rice, curry, stew, potatoes, herbs, dark sauce, and ceramic/plastic/glass bowls are SAFE food items.\n"
"1. Examine all utensils carefully, even in dim lighting or dark spots.\n" "2. Camera image noise, shadows, and food textures are NOT metal objects.\n"
"2. Spoons, forks, and knives are often STAINLESS STEEL / METAL. If a spoon or fork is visible, mark is_metal = True unless it is clearly bright colored plastic.\n" "3. Unless a shiny, metallic silver/gold utensil or foil sheet is clearly visible, mark is_safe = True and detected_hazards = [].\n"
"3. Ignore chemical or health concerns (plastic cancer risks are IRRELEVANT). Focus ONLY on spark/fire hazards (metal, foil).\n" "4. Do NOT invent or guess utensils if none are clearly visible."
"4. If ANY utensil is metal: set is_metal=True, add it to detected_hazards, and set is_safe=False."
) )
response_raw = generate( response_raw = generate(