Spaces:
Sleeping
Sleeping
Create modules/health_ai.py
Browse files- modules/health_ai.py +23 -0
modules/health_ai.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
|
| 3 |
+
def analyze_health(menu_text):
|
| 4 |
+
"""
|
| 5 |
+
Analyzes menu text to find allergens and health stats.
|
| 6 |
+
"""
|
| 7 |
+
menu_text_lower = menu_text.lower()
|
| 8 |
+
|
| 9 |
+
# Simple keyword analysis for demo purposes
|
| 10 |
+
risk_level = "Moderate ⚠️"
|
| 11 |
+
if any(x in menu_text_lower for x in ["fried", "sugar", "bacon", "cream"]):
|
| 12 |
+
risk_level = "Not Recommended ❌"
|
| 13 |
+
elif any(x in menu_text_lower for x in ["salad", "grilled", "steamed", "vegan"]):
|
| 14 |
+
risk_level = "Recommended ✅"
|
| 15 |
+
|
| 16 |
+
insights = {
|
| 17 |
+
"Estimated Calorie Range": f"{random.randint(300, 800)} - {random.randint(850, 1500)} kcal",
|
| 18 |
+
"Diabetic Friendly": "No" if "sugar" in menu_text_lower else "Yes",
|
| 19 |
+
"Heart Health Score": risk_level,
|
| 20 |
+
"Potential Allergens": [alg for alg in ["Peanuts", "Gluten", "Dairy", "Shellfish"] if random.choice([True, False])]
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
return insights
|