:(
This commit is contained in:
+10
-10
@@ -4,26 +4,26 @@ from APIs.aichat import generate
|
||||
import shared.config as config
|
||||
|
||||
class DishSafetyResult(BaseModel):
|
||||
image_description: str = Field(
|
||||
description="Describe the food and container in 1 simple sentence."
|
||||
utensil_or_foreign_object_detected: bool = Field(
|
||||
description="Set to True if ANY spoon, fork, knife, handle, or foil is inside or touching the bowl. Set to False ONLY if the bowl contains ONLY 100% food."
|
||||
)
|
||||
is_safe: bool = Field(
|
||||
description="Set to True if safe. Set to False ONLY if a physical metallic utensil or aluminum foil is clearly visible."
|
||||
description="MUST be False if utensil_or_foreign_object_detected is True. Set to True ONLY if pure food/bowl with ZERO utensils."
|
||||
)
|
||||
detected_hazards: list[str] = Field(
|
||||
description="List any metallic objects found (e.g. ['metal utensil']). If is_safe is True, this MUST be empty []."
|
||||
description="List any items found (e.g., ['spoon']). Empty list [] if safe."
|
||||
)
|
||||
warning_message: str = Field(
|
||||
description="Short warning if unsafe, otherwise empty string ''."
|
||||
description="Warning statement if unsafe, otherwise empty string ''."
|
||||
)
|
||||
|
||||
def check_dish_safety(image_path: str) -> dict:
|
||||
prompt = (
|
||||
"Analyze this top-down photo inside a microwave.\n\n"
|
||||
"TASK:\n"
|
||||
"1. Describe what is visible in `image_description`.\n"
|
||||
"2. If the container holds strictly food with no physical metal objects, set `is_safe` to True and `detected_hazards` to [].\n"
|
||||
"3. Mark `is_safe` as False ONLY if an actual metal object or metallic handle is present in the container."
|
||||
"Inspect this top-down photo of a food dish inside a microwave.\n\n"
|
||||
"STRICT MICROWAVE RULES:\n"
|
||||
"1. Check if ANY utensil (spoon, fork, knife, or handle) is present in or on the bowl.\n"
|
||||
"2. If ANY spoon or utensil is present (metal, plastic, or ceramic), you MUST set `utensil_or_foreign_object_detected = True` and `is_safe = False`.\n"
|
||||
"3. `is_safe` can ONLY be True if the dish contains strictly food and nothing else."
|
||||
)
|
||||
|
||||
response_raw = generate(
|
||||
|
||||
Reference in New Issue
Block a user