genaitiwari commited on
Commit
a895c78
Β·
0 Parent(s):

Initial commit

Browse files
Files changed (8) hide show
  1. .gitattributes +2 -0
  2. .gitignore +8 -0
  3. .streamlit/secrets.toml +1 -0
  4. LICENSE +21 -0
  5. README.md +76 -0
  6. app.py +216 -0
  7. requirements.txt +2 -0
  8. screenshots/dashboard.png +0 -0
.gitattributes ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .DS_Store
7
+ .env/
8
+ venv/
.streamlit/secrets.toml ADDED
@@ -0,0 +1 @@
 
 
1
+ GROQ_API_KEY = ''
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sachin Tiwari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HealthAI Advisor 🌿
2
+
3
+ [![Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://your-app-url.streamlit.app/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ An AI-powered health and wellness assistant providing personalized diet plans, workout routines, yoga sequences, and real-time health coaching using Groq's lightning-fast LLMs.
7
+
8
+ ![App Screenshot](screenshots/dashboard.png)
9
+
10
+ ## Features ✨
11
+
12
+ - **AI-Powered Recommendations**
13
+ - 🍎 Personalized meal plans with macros
14
+ - πŸ’ͺ Custom workout routines by fitness level
15
+ - 🧘 Yoga sequences with pose instructions
16
+ - πŸ€– Interactive health coaching chat
17
+
18
+ - **Health Dashboard**
19
+ - πŸ“Š BMI calculator with progress visualization
20
+ - πŸ’§ Daily hydration & activity tracking
21
+ - πŸ“ˆ Weekly progress metrics
22
+
23
+ - **Smart Customization**
24
+ - πŸ₯— Dietary restrictions/allergy support
25
+ - πŸ‹οΈ Equipment-aware workout plans
26
+ - ⏱️ Duration-based exercise routines
27
+
28
+ ## Prerequisites πŸ“‹
29
+
30
+ - Python 3.7+
31
+ - pip package manager
32
+ - [Groq API Key](https://console.groq.com/keys)
33
+
34
+ ## Installation βš™οΈ
35
+
36
+ 1. Clone the repository:
37
+ ```bash
38
+ git clone https://github.com/aitiwari/HealthAIAdvisor.git
39
+ cd healthai-advisor
40
+ ```
41
+
42
+ 2. Install dependencies:
43
+ ```bash
44
+ pip install -r requirements.txt
45
+ ```
46
+ 3. Set up your Groq API key:
47
+ ```bash
48
+ echo "GROQ_API_KEY=your_api_key_here" > .env
49
+ ```
50
+
51
+ ## Usage πŸš€
52
+
53
+ 1. Start the application:
54
+ ```bash
55
+ streamlit run app.py
56
+ ```
57
+ 2. Explore features through the sidebar navigation:
58
+
59
+ 🏠 Dashboard: Track health metrics
60
+
61
+ 🍎 Diet Planner: Generate meal plans
62
+
63
+ πŸ’ͺ Workout Generator: Create exercise routines
64
+
65
+ 🧘 Yoga Advisor: Get customized yoga sequences
66
+
67
+ πŸ€– AI Coach: Chat with health assistant
68
+
69
+ ## Acknowledgments πŸ™
70
+ Powered by Groq LPUs
71
+
72
+ Built with Streamlit
73
+
74
+ Health insights from Mixtral-8x7b AI model
75
+
76
+ Fitness data recommendations from health community knowledge
app.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ from groq import Groq
4
+ import time
5
+
6
+
7
+
8
+ # Page Configuration
9
+ st.set_page_config(
10
+ page_title="HealthAI Advisor",
11
+ page_icon="🌿",
12
+ layout="centered",
13
+ initial_sidebar_state="expanded"
14
+ )
15
+
16
+ # Initialize Groq client
17
+ with st.sidebar:
18
+ # API key input for Groq
19
+ st.session_state["GROQ_API_KEY"] = st.text_input("GROQ API Key", type="password")
20
+ st.sidebar.markdown("πŸ”‘ [Get Groq API Key](https://console.groq.com/keys)")
21
+
22
+ client = Groq(api_key=st.session_state["GROQ_API_KEY"])
23
+
24
+ # Custom CSS
25
+ st.markdown("""
26
+ <style>
27
+ /* Base styles */
28
+ .recommendation-box {
29
+ padding: 1.5rem;
30
+ border-radius: 10px;
31
+ margin-top: 1rem;
32
+ background-color: var(--background-color);
33
+ border: 1px solid var(--secondary-background-color);
34
+ color: var(--text-color);
35
+ }
36
+
37
+ /* Theme-aware text colors */
38
+ .st-emotion-cache-10trblm {
39
+ color: var(--text-color) !important;
40
+ }
41
+
42
+ /* Progress bar styling */
43
+ .st-emotion-cache-1ii7l3v {
44
+ background-color: var(--secondary-background-color) !important;
45
+ }
46
+
47
+ .st-emotion-cache-keje6w {
48
+ background-color: var(--primary-color) !important;
49
+ }
50
+ </style>
51
+ """, unsafe_allow_html=True)
52
+
53
+ # Helper Functions
54
+ def get_groq_response(prompt, model="mixtral-8x7b-32768"):
55
+ try:
56
+ response = client.chat.completions.create(
57
+ messages=[{"role": "user", "content": prompt}],
58
+ model=model,
59
+ temperature=0.3,
60
+ max_tokens=1024
61
+ )
62
+ return response.choices[0].message.content
63
+ except Exception as e:
64
+ return f"Error: {str(e)}"
65
+
66
+ def calculate_bmi(weight, height):
67
+ return weight / ((height / 100) ** 2)
68
+
69
+ # Main App
70
+ def main():
71
+ st.sidebar.title("🌱 Navigation")
72
+ page = st.sidebar.radio("Choose Section",
73
+ ["🏠 Dashboard", "🍎 Diet Planner", "πŸ’ͺ Workout Generator", "🧘 Yoga Advisor", "πŸ€– AI Coach"])
74
+
75
+ # Dashboard
76
+ if page == "🏠 Dashboard":
77
+ st.markdown('<p class="header-text">HealthAI Dashboard</p>', unsafe_allow_html=True)
78
+
79
+ with st.container():
80
+ col1, col2 = st.columns(2)
81
+ with col1:
82
+ st.subheader("Body Metrics")
83
+ weight = st.number_input("Weight (kg)", min_value=30.0, max_value=200.0, value=65.0)
84
+ height = st.number_input("Height (cm)", min_value=100.0, max_value=250.0, value=170.0)
85
+
86
+ if st.button("Calculate BMI"):
87
+ bmi = calculate_bmi(weight, height)
88
+ st.metric("BMI", f"{bmi:.1f}")
89
+
90
+ # Calculate progress value (0-1 scale)
91
+ progress_value = min(max((bmi - 15)/(40 - 15), 0), 1)
92
+
93
+ # Create a layout for the progress bar with label
94
+ col_a, col_b = st.columns([4, 1])
95
+ with col_a:
96
+ st.progress(progress_value)
97
+ with col_b:
98
+ st.caption("15 ⟷ 40")
99
+
100
+
101
+
102
+ with col2:
103
+ st.subheader("Daily Goals")
104
+ st.metric("Water Intake", "2.4L", "+0.6L remaining")
105
+ st.metric("Steps", "8,432", "12k goal")
106
+ st.metric("Active Minutes", "45", "60min target")
107
+
108
+ st.divider()
109
+ st.subheader("Weekly Progress")
110
+ col1, col2, col3 = st.columns(3)
111
+ col1.metric("Calories Burned", "12,430", "1,234 today")
112
+ col2.metric("Exercise Minutes", "324", "45 today")
113
+ col3.metric("Sleep Average", "7.2h", "-0.8h from goal")
114
+
115
+ # Diet Planner
116
+ elif page == "🍎 Diet Planner":
117
+ st.markdown('<p class="header-text">AI Nutritionist</p>', unsafe_allow_html=True)
118
+
119
+ with st.form("diet_form"):
120
+ col1, col2 = st.columns(2)
121
+ with col1:
122
+ diet_goal = st.selectbox("Primary Goal",
123
+ ["Weight Loss", "Muscle Gain", "Maintenance", "Improve Digestion"])
124
+ allergies = st.multiselect("Allergies/Dietary Restrictions",
125
+ ["Dairy", "Gluten", "Nuts", "Eggs", "Vegetarian", "Vegan"])
126
+
127
+ with col2:
128
+ calorie_target = st.slider("Daily Calorie Target", 1200, 3000, 2000)
129
+ preferred_cuisine = st.selectbox("Preferred Cuisine",
130
+ ["Any", "Mediterranean", "Asian", "Mexican", "Continental"])
131
+
132
+ if st.form_submit_button("🍳 Generate Meal Plan"):
133
+ with st.spinner("Cooking up your personalized plan..."):
134
+ prompt = f"""Create a {diet_goal} meal plan for {calorie_target} calories,
135
+ considering {allergies} restrictions and {preferred_cuisine} cuisine preference.
136
+ Include breakfast, lunch, dinner, and snacks with macros with attractive emogies and attractive format"""
137
+ response = get_groq_response(prompt)
138
+ st.subheader("🍽️ Your Personalized Meal Plan")
139
+ st.markdown(f'<div class="recommendation-box">\n\n{response}</div>', unsafe_allow_html=True)
140
+
141
+
142
+ # Workout Generator
143
+ elif page == "πŸ’ͺ Workout Generator":
144
+ st.markdown('<p class="header-text">AI Fitness Coach</p>', unsafe_allow_html=True)
145
+
146
+ with st.form("workout_form"):
147
+ col1, col2 = st.columns(2)
148
+ with col1:
149
+ fitness_level = st.selectbox("Fitness Level",
150
+ ["Beginner", "Intermediate", "Advanced"])
151
+ workout_type = st.selectbox("Workout Type",
152
+ ["Full Body", "Upper Body", "Lower Body", "Cardio", "HIIT"])
153
+
154
+ with col2:
155
+ equipment = st.multiselect("Available Equipment",
156
+ ["Dumbbells", "Resistance Bands", "None", "Barbell", "Kettlebells"])
157
+ duration = st.slider("Duration (minutes)", 15, 120, 45)
158
+
159
+ if st.form_submit_button("πŸ‹οΈ Generate Workout"):
160
+ with st.spinner("Building your workout routine..."):
161
+ prompt = f"""Create a {duration}-minute {workout_type} workout for a {fitness_level}
162
+ using {equipment}. Include warm-up, exercises with sets/reps, and cool-down with attractive emogies and attractive format"""
163
+ response = get_groq_response(prompt)
164
+ st.subheader("πŸ“ Your Custom Workout Plan")
165
+ st.markdown(f'<div class="recommendation-box">\n\n{response}</div>', unsafe_allow_html=True)
166
+
167
+ # Yoga Advisor
168
+ elif page == "🧘 Yoga Advisor":
169
+ st.markdown('<p class="header-text">AI Yoga Guide</p>', unsafe_allow_html=True)
170
+
171
+ with st.form("yoga_form"):
172
+ col1, col2 = st.columns(2)
173
+ with col1:
174
+ yoga_goal = st.selectbox("Session Focus",
175
+ ["Stress Relief", "Flexibility", "Strength", "Balance", "Morning Energy"])
176
+ experience_level = st.selectbox("Experience Level",
177
+ ["Beginner", "Intermediate", "Advanced"])
178
+
179
+ with col2:
180
+ duration = st.slider("Session Duration (minutes)", 10, 90, 30)
181
+ intensity = st.select_slider("Intensity",
182
+ options=["Gentle", "Moderate", "Vigorous"])
183
+
184
+ if st.form_submit_button("🧘 Generate Yoga Routine"):
185
+ with st.spinner("Creating your zen session..."):
186
+ prompt = f"""Create a {duration}-minute {yoga_goal} yoga routine for {experience_level}
187
+ practitioners with {intensity} intensity. Include warm-up, sequence of poses,
188
+ and final relaxation with attractive emogies and attractive format"""
189
+ response = get_groq_response(prompt)
190
+ st.subheader("🌸 Your Yoga Sequence")
191
+ st.markdown(f'<div class="recommendation-box">\n\n{response}</div>', unsafe_allow_html=True)
192
+
193
+ # AI Coach
194
+ elif page == "πŸ€– AI Coach":
195
+ st.markdown('<p class="header-text">AI Wellness Coach</p>', unsafe_allow_html=True)
196
+
197
+ if "messages" not in st.session_state:
198
+ st.session_state.messages = []
199
+
200
+ for message in st.session_state.messages:
201
+ with st.chat_message(message["role"]):
202
+ st.markdown(message["content"])
203
+
204
+ if prompt := st.chat_input("Ask about health, nutrition, or fitness..."):
205
+ st.session_state.messages.append({"role": "user", "content": prompt})
206
+ with st.chat_message("user"):
207
+ st.markdown(prompt)
208
+
209
+ with st.chat_message("assistant"):
210
+ with st.spinner("Analyzing..."):
211
+ response = get_groq_response(prompt)
212
+ st.markdown(response)
213
+ st.session_state.messages.append({"role": "assistant", "content": response})
214
+
215
+ if __name__ == "__main__":
216
+ main()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ groq
screenshots/dashboard.png ADDED