Update app.py
Browse files
app.py
CHANGED
|
@@ -1,207 +1,218 @@
|
|
| 1 |
-
import
|
|
|
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
| 3 |
import gdown
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
# Function to calculate BMI and recommend diet for adults
|
| 48 |
-
def bmi_insights(weight, height_cm):
|
| 49 |
-
height_m = height_cm / 100
|
| 50 |
-
bmi = weight / (height_m ** 2)
|
| 51 |
-
|
| 52 |
-
if bmi < 18.5:
|
| 53 |
-
return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial."
|
| 54 |
-
elif 18.5 <= bmi < 24.9:
|
| 55 |
-
return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet."
|
| 56 |
-
elif 25 <= bmi < 29.9:
|
| 57 |
-
return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight."
|
| 58 |
-
else:
|
| 59 |
-
return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods and lean proteins is recommended."
|
| 60 |
-
|
| 61 |
-
# Function to provide general diet recommendation for infants
|
| 62 |
-
def infant_diet_recommendation():
|
| 63 |
-
return (
|
| 64 |
-
"For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
|
| 65 |
-
"Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
|
| 66 |
-
"Consult with your pediatrician for more personalized advice."
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
# Function to provide dietary recommendations based on medical conditions
|
| 70 |
-
def medical_condition_recommendation(condition):
|
| 71 |
-
recommendations = {
|
| 72 |
-
"Diabetes": "A low-carb diet is essential. Focus on fiber-rich vegetables, lean proteins, and healthy fats. Avoid sugary foods.",
|
| 73 |
-
"Celiac Disease": "Avoid gluten-containing foods like wheat, barley, and rye. Focus on gluten-free grains, fruits, vegetables, and lean proteins.",
|
| 74 |
-
"Hypertension": "Limit salt intake. Incorporate potassium-rich foods such as bananas, spinach, and potatoes. A heart-healthy diet with lean proteins is ideal.",
|
| 75 |
-
"Heart Disease": "Consume a heart-healthy diet rich in omega-3 fatty acids, vegetables, and whole grains. Limit saturated fats and processed foods.",
|
| 76 |
-
"Obesity": "Focus on a calorie-restricted diet, prioritizing vegetables, lean meats, and whole grains. Avoid sugary snacks and drinks.",
|
| 77 |
-
"Cholesterol Disorders": "Eat foods rich in fiber, such as oats, fruits, and vegetables. Limit saturated fats and trans fats.",
|
| 78 |
-
"IBS": "Incorporate fiber-rich foods like oats and vegetables. Avoid foods that cause bloating, such as beans, cabbage, and onions.",
|
| 79 |
-
"GERD": "Avoid acidic and spicy foods, caffeine, and alcohol. Focus on bland, easy-to-digest meals like rice, oatmeal, and non-citrus fruits.",
|
| 80 |
-
"Peptic Ulcers": "Avoid spicy, fatty, and acidic foods. Focus on bland foods like rice, oatmeal, and non-citrus fruits.",
|
| 81 |
-
"Gout": "Limit foods high in purines, such as red meat, shellfish, and alcohol. Focus on low-fat dairy, fruits, and vegetables.",
|
| 82 |
-
"Lactose Intolerance": "Avoid dairy products or choose lactose-free alternatives. Incorporate plant-based sources of calcium.",
|
| 83 |
-
"Kidney Disease": "Reduce sodium, potassium, and phosphorus intake. Focus on lean proteins and avoid processed foods.",
|
| 84 |
-
"Hypothyroidism": "Increase iodine-rich foods like seaweed, eggs, and dairy. Focus on vegetables and lean proteins.",
|
| 85 |
-
"Anemia": "Focus on iron-rich foods such as red meat, spinach, and beans. Pair with vitamin C-rich foods for better absorption.",
|
| 86 |
-
"Food Allergies": "Avoid allergenic foods like peanuts, tree nuts, dairy, eggs, shellfish, and others. Focus on a balanced, allergy-free diet.",
|
| 87 |
-
"Acid Reflux": "Avoid acidic and spicy foods. Incorporate alkaline foods like bananas, melons, and oatmeal.",
|
| 88 |
-
"Crohn's Disease": "Focus on low-fiber foods and avoid spicy, fatty, and acidic foods. Prioritize lean meats and easy-to-digest grains.",
|
| 89 |
-
"Osteoporosis": "Ensure adequate calcium and vitamin D intake through dairy or fortified alternatives. Incorporate weight-bearing exercises.",
|
| 90 |
-
"Autoimmune Diseases": "A diet rich in anti-inflammatory foods like leafy greens, berries, nuts, and fatty fish is ideal.",
|
| 91 |
-
"Migraines": "Avoid foods that trigger migraines, such as chocolate, caffeine, and aged cheeses. Focus on magnesium-rich foods.",
|
| 92 |
-
"PCOS": "Focus on a low-glycemic index diet with plenty of fruits, vegetables, and lean proteins. Limit processed sugars.",
|
| 93 |
-
"CFS": "A balanced diet with adequate calories and nutrients is essential. Focus on anti-inflammatory foods and avoid refined sugars.",
|
| 94 |
-
"Mental Health": "Focus on omega-3 fatty acids, whole grains, fruits, and vegetables. Avoid processed foods and sugar."
|
| 95 |
-
}
|
| 96 |
-
return recommendations.get(condition, "No specific recommendations available.")
|
| 97 |
-
|
| 98 |
-
# Main workflow
|
| 99 |
-
def main():
|
| 100 |
-
# Set the background color and text color for the app
|
| 101 |
-
st.markdown("""
|
| 102 |
-
<style>
|
| 103 |
-
body {
|
| 104 |
-
background-color: navy;
|
| 105 |
-
color: white;
|
| 106 |
-
}
|
| 107 |
-
</style>
|
| 108 |
-
""", unsafe_allow_html=True)
|
| 109 |
-
|
| 110 |
-
st.title("Roz Roz Ka Masla..... Aaj Kya Pakayen!!! ")
|
| 111 |
-
st.title("Now generate weekly Menu with BMI Insights")
|
| 112 |
-
|
| 113 |
-
# Add food image at the top right of the app
|
| 114 |
-
image = Image.open("food_image.jpg") # Ensure you have an image in the same folder
|
| 115 |
-
st.sidebar.image(image, use_container_width=True)
|
| 116 |
-
|
| 117 |
-
# User input for BMI insights or Infant's weekly diet
|
| 118 |
-
st.sidebar.header("Select your category:")
|
| 119 |
-
category = st.sidebar.radio("Are you an Adult or Infant?", ["Adult", "Infant"])
|
| 120 |
-
|
| 121 |
-
if category == "Infant":
|
| 122 |
-
st.sidebar.header("Infant Weekly Diet Recommendations")
|
| 123 |
-
diet_recommendation = infant_diet_recommendation()
|
| 124 |
-
st.sidebar.write(diet_recommendation)
|
| 125 |
-
return
|
| 126 |
-
|
| 127 |
-
if category == "Adult":
|
| 128 |
-
# User input for BMI insights (only for Adults)
|
| 129 |
-
st.sidebar.header("Enter your details for BMI insights:")
|
| 130 |
-
weight = st.sidebar.number_input("Enter your weight (kg)", min_value=30, max_value=200, value=70)
|
| 131 |
-
height_cm = st.sidebar.number_input("Enter your height (cm)", min_value=90, max_value=250, value=175)
|
| 132 |
-
|
| 133 |
-
if st.sidebar.button("Get BMI Insights"):
|
| 134 |
-
bmi_message = bmi_insights(weight, height_cm)
|
| 135 |
-
st.sidebar.success(bmi_message)
|
| 136 |
-
|
| 137 |
-
# Dropdown for selecting medical condition(s)
|
| 138 |
-
medical_condition = st.sidebar.selectbox(
|
| 139 |
-
"Select any medical condition", [
|
| 140 |
-
"None", "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
|
| 141 |
-
"Cholesterol Disorders", "IBS", "GERD", "Peptic Ulcers", "Gout", "Lactose Intolerance",
|
| 142 |
-
"Kidney Disease", "Hypothyroidism", "Anemia", "Food Allergies", "Acid Reflux",
|
| 143 |
-
"Crohn's Disease", "Osteoporosis", "Autoimmune Diseases", "Migraines", "PCOS",
|
| 144 |
-
"CFS", "Mental Health"
|
| 145 |
-
]
|
| 146 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
'Sabzi': st.number_input("Number of Sabzi dishes", min_value=0, value=0),
|
| 165 |
-
'Rice': st.number_input("Number of Rice dishes", min_value=0, value=0),
|
| 166 |
-
'Daal': st.number_input("Number of Daal dishes", min_value=0, value=0),
|
| 167 |
-
'Meat': st.number_input("Number of Meat dishes", min_value=0, value=0),
|
| 168 |
-
'Chicken': st.number_input("Number of Chicken dishes", min_value=0, value=0),
|
| 169 |
-
'Fish': st.number_input("Number of Fish dishes", min_value=0, value=0)
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
total_main_courses = sum(sub_category_pref.values()) + outings
|
| 173 |
-
if total_main_courses > 14:
|
| 174 |
-
st.warning("The total number of main courses exceeds 14! Please adjust your preferences.")
|
| 175 |
-
return
|
| 176 |
-
|
| 177 |
-
if st.button("Generate Menu"):
|
| 178 |
-
lunch_menu, dinner_menu, total_cost = generate_menu(data, season, sub_category_pref, outings, budget)
|
| 179 |
-
|
| 180 |
-
if lunch_menu is None or dinner_menu is None:
|
| 181 |
return
|
| 182 |
|
| 183 |
-
|
| 184 |
-
st.subheader("Lunch Menu
|
|
|
|
|
|
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
|
| 190 |
-
st.
|
|
|
|
|
|
|
| 191 |
|
| 192 |
-
st.
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
# Save menu to Excel
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
-
|
|
|
|
| 205 |
|
| 206 |
if __name__ == "__main__":
|
| 207 |
-
main()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import random
|
| 3 |
import pandas as pd
|
| 4 |
+
import streamlit as st
|
| 5 |
+
from groq import Groq
|
| 6 |
import gdown
|
| 7 |
+
|
| 8 |
+
# Function to download the file from Google Drive
|
| 9 |
+
def download_file_from_gdrive(url, output):
|
| 10 |
+
import gdown
|
| 11 |
+
gdown.download(url, output, quiet=False)
|
| 12 |
+
|
| 13 |
+
# Load the menu data from the downloaded file
|
| 14 |
+
def load_data(file_path):
|
| 15 |
+
return pd.read_excel(file_path)
|
| 16 |
+
|
| 17 |
+
# Get user inputs for menu generation
|
| 18 |
+
def get_user_inputs():
|
| 19 |
+
# Get user input via Streamlit widgets
|
| 20 |
+
user_type = st.selectbox("Is this menu for Adult or Infant?", ["Adult", "Infant"])
|
| 21 |
+
|
| 22 |
+
if user_type == "Adult":
|
| 23 |
+
season = st.selectbox("Select the season", ["Summer", "Winter"])
|
| 24 |
+
outings = st.slider("Enter the number of outings for the week:", 0, 7, 0)
|
| 25 |
+
budget = st.number_input("Enter your weekly budget (in Rs):", min_value=0, step=100)
|
| 26 |
+
|
| 27 |
+
sub_category_prefs = {}
|
| 28 |
+
categories = ["Sabzi", "Rice", "Daal", "Meat", "Chicken", "Fish"]
|
| 29 |
+
for category in categories:
|
| 30 |
+
count = st.number_input(f"Enter the number of {category} dishes:", min_value=0)
|
| 31 |
+
sub_category_prefs[category] = count
|
| 32 |
+
|
| 33 |
+
return user_type, season, outings, budget, sub_category_prefs
|
| 34 |
+
|
| 35 |
+
elif user_type == "Infant":
|
| 36 |
+
return user_type, None, None, None, None
|
| 37 |
+
|
| 38 |
+
# Fetch recipe from Groq API for a given dish name
|
| 39 |
+
def get_recipe(dish_name):
|
| 40 |
+
client = Groq(api_key="your-api-key-here") # Replace with your actual API key
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
chat_completion = client.chat.completions.create(
|
| 44 |
+
messages=[{
|
| 45 |
+
"role": "user",
|
| 46 |
+
"content": f"Provide a detailed recipe for {dish_name}.",
|
| 47 |
+
}],
|
| 48 |
+
model="llama-3.3-70b-versatile",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
)
|
| 50 |
+
return chat_completion.choices[0].message.content
|
| 51 |
+
except Exception as e:
|
| 52 |
+
return f"Error fetching recipe: {e}"
|
| 53 |
+
|
| 54 |
+
# Generate menu based on user inputs
|
| 55 |
+
def generate_menu(data, user_type, season=None, outings=None, budget=None, sub_category_prefs=None):
|
| 56 |
+
if user_type == "Adult":
|
| 57 |
+
# Filter data by season
|
| 58 |
+
filtered_data = data[data['Season'].isin([season, 'All Seasons'])]
|
| 59 |
+
main_courses = filtered_data[filtered_data['Course'] == 'Main Course']
|
| 60 |
+
side_dishes = filtered_data[filtered_data['Course'] == 'Side Dish']
|
| 61 |
+
|
| 62 |
+
# Initialize menu
|
| 63 |
+
homemade_dishes_count = 14 - outings
|
| 64 |
+
weekly_menu = []
|
| 65 |
+
|
| 66 |
+
# Add dishes from each sub-category based on user preferences
|
| 67 |
+
for category, count in sub_category_prefs.items():
|
| 68 |
+
category_dishes = main_courses[main_courses['Sub-Category'] == category]
|
| 69 |
+
available_count = len(category_dishes)
|
| 70 |
+
|
| 71 |
+
while count > available_count:
|
| 72 |
+
st.warning(f"You requested {count} {category} dishes, but only {available_count} are available.")
|
| 73 |
+
count = st.number_input(f"Please revise your selection for {category} dishes (Maximum: {available_count}):", min_value=0, max_value=available_count)
|
| 74 |
+
sub_category_prefs[category] = count
|
| 75 |
+
|
| 76 |
+
selected_dishes = category_dishes.sample(n=count).to_dict('records')
|
| 77 |
+
weekly_menu.extend(selected_dishes)
|
| 78 |
+
|
| 79 |
+
# Fill remaining dishes if fewer than 14 are selected
|
| 80 |
+
remaining_count = homemade_dishes_count - len(weekly_menu)
|
| 81 |
+
if remaining_count > 0:
|
| 82 |
+
additional_dishes = main_courses.sample(n=min(remaining_count, len(main_courses))).to_dict('records')
|
| 83 |
+
weekly_menu.extend(additional_dishes)
|
| 84 |
+
|
| 85 |
+
# Randomly select outings
|
| 86 |
+
available_outings = len(main_courses)
|
| 87 |
+
if outings > available_outings:
|
| 88 |
+
st.warning(f"You requested {outings} outings, but only {available_outings} are available.")
|
| 89 |
+
outings = st.number_input(f"Please revise your selection for outings (Maximum: {available_outings}):", min_value=0, max_value=available_outings)
|
| 90 |
+
outing_dishes = main_courses.sample(n=min(outings, len(main_courses))).to_dict('records')
|
| 91 |
+
|
| 92 |
+
# Combine homemade and outing dishes
|
| 93 |
+
weekly_menu = random.sample(weekly_menu, k=homemade_dishes_count) + outing_dishes
|
| 94 |
+
|
| 95 |
+
# Add 2 side dishes
|
| 96 |
+
selected_side_dishes = side_dishes.sample(n=min(len(side_dishes), 2)).to_dict('records')
|
| 97 |
+
|
| 98 |
+
# Ensure budget constraint
|
| 99 |
+
total_expenditure = sum(dish['Cost per 4 persons'] for dish in weekly_menu + selected_side_dishes)
|
| 100 |
+
if total_expenditure > budget:
|
| 101 |
+
st.warning(f"Your budget of Rs. {budget} is too low for the selected preferences.")
|
| 102 |
+
return None, None, None, None
|
| 103 |
+
|
| 104 |
+
# Split menu into lunch and dinner
|
| 105 |
+
lunch_menu = weekly_menu[:7]
|
| 106 |
+
dinner_menu = weekly_menu[7:14]
|
| 107 |
+
|
| 108 |
+
# Assign days of the week
|
| 109 |
+
days_of_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
| 110 |
+
lunch_menu = {days_of_week[i]: dish['Name'] for i, dish in enumerate(lunch_menu)}
|
| 111 |
+
dinner_menu = {days_of_week[i]: dish['Name'] for i, dish in enumerate(dinner_menu)}
|
| 112 |
+
|
| 113 |
+
return lunch_menu, dinner_menu, selected_side_dishes, total_expenditure
|
| 114 |
+
|
| 115 |
+
elif user_type == "Infant":
|
| 116 |
+
baby_dishes_data = data[data['Course'] == 'Baby Dish']
|
| 117 |
+
baby_dishes = baby_dishes_data['Name'].tolist()
|
| 118 |
+
if len(baby_dishes) >= 14:
|
| 119 |
+
infant_menu = random.sample(baby_dishes, k=14)
|
| 120 |
+
else:
|
| 121 |
+
infant_menu = random.choices(baby_dishes, k=14)
|
| 122 |
+
|
| 123 |
+
# Calculate total expenditure for the infant menu
|
| 124 |
+
baby_dishes_cost = {row['Name']: row['Cost per 4 persons'] for _, row in baby_dishes_data.iterrows()}
|
| 125 |
+
total_expenditure = sum(baby_dishes_cost[dish] for dish in infant_menu)
|
| 126 |
+
|
| 127 |
+
return {"Weekly Menu": infant_menu}, total_expenditure
|
| 128 |
+
|
| 129 |
+
# Save the generated menu to an Excel file
|
| 130 |
+
def save_menu_to_excel(lunch_menu=None, dinner_menu=None, side_dishes=None, infant_menu=None):
|
| 131 |
+
with pd.ExcelWriter("Weekly_Menu.xlsx") as writer:
|
| 132 |
+
if infant_menu:
|
| 133 |
+
infant_df = pd.DataFrame(infant_menu["Weekly Menu"], columns=['Dish'])
|
| 134 |
+
infant_df.to_excel(writer, sheet_name='Infant Menu', index=False)
|
| 135 |
+
else:
|
| 136 |
+
lunch_df = pd.DataFrame(list(lunch_menu.items()), columns=['Day', 'Lunch'])
|
| 137 |
+
lunch_df.to_excel(writer, sheet_name='Lunch Menu', index=False)
|
| 138 |
+
|
| 139 |
+
dinner_df = pd.DataFrame(list(dinner_menu.items()), columns=['Day', 'Dinner'])
|
| 140 |
+
dinner_df.to_excel(writer, sheet_name='Dinner Menu', index=False)
|
| 141 |
+
|
| 142 |
+
side_dishes_df = pd.DataFrame(side_dishes)
|
| 143 |
+
side_dishes_df = side_dishes_df[['Name']]
|
| 144 |
+
side_dishes_df.to_excel(writer, sheet_name='Side Dishes', index=False)
|
| 145 |
+
|
| 146 |
+
# Main function to run the app
|
| 147 |
+
def main():
|
| 148 |
+
# File URL and output path
|
| 149 |
+
file_url = "https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo"
|
| 150 |
+
output_file = "menu_data.xlsx"
|
| 151 |
+
|
| 152 |
+
# Download the file
|
| 153 |
+
download_file_from_gdrive(file_url, output_file)
|
| 154 |
+
|
| 155 |
+
# Load data
|
| 156 |
+
data = load_data(output_file)
|
| 157 |
|
| 158 |
+
st.title("Weekly Menu Generator")
|
| 159 |
+
|
| 160 |
+
# Option selection
|
| 161 |
+
choice = st.selectbox("What would you like to do?", ["Generate a Weekly Menu", "Get a Recipe for a Dish", "Exit"])
|
| 162 |
+
|
| 163 |
+
if choice == "Generate a Weekly Menu":
|
| 164 |
+
# Get user inputs
|
| 165 |
+
user_type, season, outings, budget, sub_category_prefs = get_user_inputs()
|
| 166 |
+
|
| 167 |
+
# Generate menu
|
| 168 |
+
if user_type == "Adult":
|
| 169 |
+
lunch_menu, dinner_menu, side_dishes, total_expenditure = generate_menu(
|
| 170 |
+
data, user_type, season, outings, budget, sub_category_prefs
|
| 171 |
+
)
|
| 172 |
+
if lunch_menu is None:
|
| 173 |
+
st.warning("Unable to generate a menu within the given budget and preferences. Please try again.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
return
|
| 175 |
|
| 176 |
+
# Display results
|
| 177 |
+
st.subheader("Lunch Menu")
|
| 178 |
+
for day, dish in lunch_menu.items():
|
| 179 |
+
st.write(f"{day}: {dish}")
|
| 180 |
|
| 181 |
+
st.subheader("Dinner Menu")
|
| 182 |
+
for day, dish in dinner_menu.items():
|
| 183 |
+
st.write(f"{day}: {dish}")
|
| 184 |
|
| 185 |
+
st.subheader("Side Dishes")
|
| 186 |
+
for dish in side_dishes:
|
| 187 |
+
st.write(f"- {dish['Name']}")
|
| 188 |
|
| 189 |
+
st.write(f"Total Weekly Expenditure: Rs. {total_expenditure}")
|
| 190 |
|
| 191 |
+
# Save menu to Excel
|
| 192 |
+
save_menu_to_excel(lunch_menu, dinner_menu, side_dishes)
|
| 193 |
|
| 194 |
+
elif user_type == "Infant":
|
| 195 |
+
infant_menu, total_expenditure = generate_menu(data, user_type)
|
| 196 |
+
|
| 197 |
+
# Display results
|
| 198 |
+
st.subheader("Infant Weekly Menu")
|
| 199 |
+
for dish in infant_menu["Weekly Menu"]:
|
| 200 |
+
st.write(f"- {dish}")
|
| 201 |
+
|
| 202 |
+
st.write(f"Total Weekly Expenditure: Rs. {total_expenditure}")
|
| 203 |
|
| 204 |
# Save menu to Excel
|
| 205 |
+
save_menu_to_excel(infant_menu=infant_menu)
|
| 206 |
+
|
| 207 |
+
elif choice == "Get a Recipe for a Dish":
|
| 208 |
+
dish_name = st.text_input("Enter the name of a dish you want the recipe for:")
|
| 209 |
+
if dish_name:
|
| 210 |
+
recipe = get_recipe(dish_name)
|
| 211 |
+
st.subheader(f"Recipe for {dish_name}")
|
| 212 |
+
st.write(recipe)
|
| 213 |
|
| 214 |
+
elif choice == "Exit":
|
| 215 |
+
st.write("Thank you for using the Weekly Menu Generator!")
|
| 216 |
|
| 217 |
if __name__ == "__main__":
|
| 218 |
+
main()
|