import streamlit as st from dotenv import load_dotenv from langchain_groq import ChatGroq import os import importlib.util # Set page configuration st.set_page_config( page_title="Wellness Planner", page_icon="🌿", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS for better styling st.markdown(""" """, unsafe_allow_html=True) # Check if team_info module exists and import it try: import team_info has_team_info = True except ImportError: has_team_info = False # Load environment variables load_dotenv() # Initialize the model model = ChatGroq(model="llama3-8b-8192") # Function to calculate daily calorie requirements def calculate_calorie_requirements(age, gender, weight, height, fitness_goal): if gender == "Male": bmr = 10 * weight + 6.25 * height - 5 * age + 5 else: bmr = 10 * weight + 6.25 * height - 5 * age - 161 if fitness_goal == "Weight Loss": return bmr * 1.2 elif fitness_goal == "Weight Gain": return bmr * 1.5 else: return bmr * 1.375 # Function to generate the plan def generate_plan_with_prompt(metrics, prompt_template): prompt = prompt_template.format(**metrics) response = model.invoke(prompt) return response # Function to format the response neatly def format_plan(response): try: content = response.content sections = content.split("\n\n") formatted = "" for section in sections: formatted += f"{section.strip()}\n\n" return formatted except Exception as e: return f"Error formatting plan: {e}" # Ayurvedic prompt template ayurveda_prompt_template = """ You are a health expert specialized in both modern medicine and Ayurveda. Generate a personalized weekly diet and exercise plan for {name}, a {age}-year-old {gender} with a BMI of {bmi} ({health_status}). Fitness Goal: {fitness_goal}. Daily Calorie Requirement: {daily_calories} kcal. Dietary Preference: {dietary_preference}. Food Allergies: {food_allergies}. Local Cuisine: {local_cuisine}. Month: {month}. Ayurvedic Consideration: True Plan should include: 1. A daily diet plan with meal timings, calorie details, and meal alternatives. 2. Exercise routines based on goals, incorporating cardio, strength, and flexibility. 3. Dynamic plan adjustments based on month and local cuisine preferences. 4. Wearable integration for tracking steps, heart rate, and calorie burn. 5. Progress monitoring for daily calorie burn and weight tracking. 6. **Food Delivery Integration**: - Meal suggestions based on diet plans. - Integration with food delivery platforms (Uber Eats, DoorDash). - Searching menu items that fit calorie and dietary preferences. - Multi-restaurant meal aggregation for complete diet fulfillment. - Location-based meal recommendations. - Customizable meal delivery schedules. 7. **Ayurvedic Elements**: - Dosha assessment based on provided metrics. - Ayurvedic dietary recommendations aligned with your dosha type. - Seasonal herbs and spices for balance. - Daily routines (Dinacharya) for optimal health. - Natural remedies complementing modern medicine. Provide a detailed plan for each weekday: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. Return output as: Day: {{weekday}} - Breakfast: Time, Description, Calories, Ayurvedic Properties - Lunch: Time, Description, Calories, Ayurvedic Properties - Snacks: Time, Description, Calories, Ayurvedic Properties - Dinner: Time, Description, Calories, Ayurvedic Properties - Exercise: Description, Duration, Dosha Benefits - Wearable Tracking: Steps, Heart Rate, Calories Burned - Progress Monitoring: Daily calorie intake vs. burn. - Food Delivery: Suggested meal items and delivery options. - Ayurvedic Tips: Daily wellness practices based on dosha. """ # Regular prompt template regular_prompt_template = """ You are a health expert. Generate a personalized weekly diet and exercise plan for {name}, a {age}-year-old {gender} with a BMI of {bmi} ({health_status}). Fitness Goal: {fitness_goal}. Daily Calorie Requirement: {daily_calories} kcal. Dietary Preference: {dietary_preference}. Food Allergies: {food_allergies}. Local Cuisine: {local_cuisine}. Month: {month}. Plan should include: 1. A daily diet plan with meal timings, calorie details, and meal alternatives. 2. Exercise routines based on goals, incorporating cardio, strength, and flexibility. 3. Dynamic plan adjustments based on month and local cuisine preferences. 4. Wearable integration for tracking steps, heart rate, and calorie burn. 5. Progress monitoring for daily calorie burn and weight tracking. 6. **Food Delivery Integration**: - Meal suggestions based on diet plans. - Integration with food delivery platforms (Uber Eats, DoorDash). - Searching menu items that fit calorie and dietary preferences. - Multi-restaurant meal aggregation for complete diet fulfillment. - Location-based meal recommendations. - Customizable meal delivery schedules. Provide a detailed plan for each weekday: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. Return output as: Day: {{weekday}} - Breakfast: Time, Description, Calories - Lunch: Time, Description, Calories - Snacks: Time, Description, Calories - Dinner: Time, Description, Calories - Exercise: Description, Duration - Wearable Tracking: Steps, Heart Rate, Calories Burned - Progress Monitoring: Daily calorie intake vs. burn. - Food Delivery: Suggested meal items and delivery options. """ # Main App Layout def main(): # App Header col1, col2 = st.columns([1, 3]) with col1: st.image("https://img.icons8.com/color/96/000000/yoga.png", width=80) with col2: st.title("AI-Based Wellness Planner") st.subheader("Personalized Diet & Exercise Plan with Ayurvedic Insights") st.markdown("---") # Sidebar content with st.sidebar: st.image("https://img.icons8.com/color/96/000000/natural-food.png", width=50) st.header("About this Project") st.markdown("""
Your BMI is {bmi}
Status: {health_status}
Daily requirements: {daily_calories} kcal
Goal: {fitness_goal}
Ayurveda is a traditional Indian system of medicine that dates back over 5,000 years. The term Ayurveda is derived from the Sanskrit words "ayur" (life) and "veda" (knowledge).
Ayurveda believes that each person has a unique mix of three energies or doshas:
Ayurveda takes a holistic approach to health that includes:
Our wellness planner integrates these ancient principles with modern health science to provide you with a truly holistic approach to health and wellness.