AI safety check
Build, push image, and notify Watchtower / build-image (push) Successful in 1m59s
Build, push image, and notify Watchtower / notify (push) Successful in 10s

This commit is contained in:
2026-08-10 16:36:27 +02:00
parent d4cef30b8f
commit ddc136a5ca
3 changed files with 85 additions and 32 deletions
+42
View File
@@ -0,0 +1,42 @@
import json
from APIs.aichat import generate
DISH_SAFETY_SCHEMA = {
"type": "object",
"properties": {
"is_safe": {
"type": "boolean",
"description": "True if no microwave hazards (metal, foil, sealed packaging) are present."
},
"warning_message": {
"type": "string",
"description": "Explanation of any hazard found, or an empty string if safe."
},
"detected_hazards": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of specific hazard items detected."
}
},
"required": ["is_safe", "warning_message", "detected_hazards"]
}
def check_dish_safety(image_path: str) -> dict:
prompt = (
"Analyze this top-down photo of a dish prepared for microwave cooking. "
"Inspect the area for metal utensils, aluminum foil, metallic dish patterns, or unvented plastic wraps."
)
# Pass the schema directly to the generation call
response_raw = generate(
prompt=prompt,
images=[image_path],
output_format=DISH_SAFETY_SCHEMA # Passed as Ollama's `format` parameter
)
if isinstance(response_raw, dict):
return response_raw
return json.loads(response_raw)