deleted the unnecessary folder
This commit is contained in:
parent
1452394de8
commit
9b7ce85bcc
4 changed files with 0 additions and 426 deletions
|
|
@ -1,65 +0,0 @@
|
|||
# AI Health & Fitness Planner 🏋️♂️
|
||||
|
||||
The **AI Health & Fitness Planner** is a personalized health and fitness app powered by Phidata's AI Agent framework. This app generates tailored dietary and fitness plans based on user inputs such as age, weight, height, activity level, dietary preferences, and fitness goals.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Health Agent and Fitness Agent**
|
||||
- The app has two phidata agents that are specialists in giving Diet advice and Fitness/workout advice respectively.
|
||||
|
||||
- **Personalized Dietary Plans**:
|
||||
- Generates detailed meal plans (breakfast, lunch, dinner, and snacks).
|
||||
- Includes important considerations like hydration, electrolytes, and fiber intake.
|
||||
- Supports various dietary preferences like Keto, Vegetarian, Low Carb, etc.
|
||||
|
||||
- **Personalized Fitness Plans**:
|
||||
- Provides customized exercise routines based on fitness goals.
|
||||
- Covers warm-ups, main workouts, and cool-downs.
|
||||
- Includes actionable fitness tips and progress tracking advice.
|
||||
|
||||
- **Interactive Q&A**:
|
||||
- Allows users to ask follow-up questions about their plans.
|
||||
- Provides AI-generated responses for personalized guidance.
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
The application requires the following Python libraries:
|
||||
|
||||
- `phidata`
|
||||
- `google-generativeai`
|
||||
- `anthropic`
|
||||
- `streamlit`
|
||||
|
||||
Ensure these dependencies are installed via the `requirements.txt` file.
|
||||
|
||||
---
|
||||
|
||||
## How to Run
|
||||
|
||||
Follow the steps below to set up and run the application:
|
||||
|
||||
Before anything else, Please get a free Gemini API Key provided by Google AI here: https://aistudio.google.com/apikey
|
||||
|
||||
1. **Clone the Repository**:
|
||||
```bash
|
||||
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
|
||||
cd ai_agent_tutorials
|
||||
2. **Install the dependencies**
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
3. **Run the Streamlit App(s)**
|
||||
If you want to learn and take a look at the basic implementation:
|
||||
```bash
|
||||
streamlit run ai_health-fitness_agent/health_agent.py
|
||||
```
|
||||
If you want to use the actual app (better UI):
|
||||
```bash
|
||||
streamlit run ai_health-fitness_agent/dub.py
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,221 +0,0 @@
|
|||
import streamlit as st
|
||||
from phi.agent import Agent
|
||||
from phi.model.anthropic import Claude
|
||||
from phi.model.google import Gemini
|
||||
|
||||
st.set_page_config(
|
||||
page_title="AI Health & Fitness Planner",
|
||||
page_icon="🏋️♂️",
|
||||
layout="wide",
|
||||
initial_sidebar_state="expanded"
|
||||
)
|
||||
|
||||
st.markdown("""
|
||||
<style>
|
||||
.main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.stButton>button {
|
||||
width: 100%;
|
||||
border-radius: 5px;
|
||||
height: 3em;
|
||||
}
|
||||
.success-box {
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
background-color: #f0fff4;
|
||||
border: 1px solid #9ae6b4;
|
||||
}
|
||||
.warning-box {
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
background-color: #fffaf0;
|
||||
border: 1px solid #fbd38d;
|
||||
}
|
||||
div[data-testid="stExpander"] div[role="button"] p {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
""", unsafe_allow_html=True)
|
||||
|
||||
def display_dietary_plan(plan_content):
|
||||
with st.expander("📋 Your Personalized Dietary Plan", expanded=True):
|
||||
col1, col2 = st.columns([2, 1])
|
||||
|
||||
with col1:
|
||||
st.markdown("### 🎯 Why this plan works")
|
||||
st.info(plan_content["why_this_plan_works"])
|
||||
|
||||
st.markdown("### 🍽️ Meal Plan")
|
||||
st.write(plan_content["meal_plan"])
|
||||
|
||||
with col2:
|
||||
st.markdown("### ⚠️ Important Considerations")
|
||||
for consideration in plan_content["important_considerations"].split('\n'):
|
||||
if consideration.strip():
|
||||
st.warning(consideration)
|
||||
|
||||
def display_fitness_plan(plan_content):
|
||||
with st.expander("💪 Your Personalized Fitness Plan", expanded=True):
|
||||
col1, col2 = st.columns([2, 1])
|
||||
|
||||
with col1:
|
||||
st.markdown("### 🎯 Goals")
|
||||
st.success(plan_content["goals"])
|
||||
|
||||
st.markdown("### 🏋️♂️ Exercise Routine")
|
||||
st.write(plan_content["routine"])
|
||||
|
||||
with col2:
|
||||
st.markdown("### 💡 Pro Tips")
|
||||
for tip in plan_content["tips"].split('\n'):
|
||||
if tip.strip():
|
||||
st.info(tip)
|
||||
|
||||
# Main App Layout
|
||||
def main():
|
||||
# Header Section
|
||||
st.title("🏋️♂️ AI Health & Fitness Planner")
|
||||
st.markdown("""
|
||||
<div style='background-color: #f8f9fa; padding: 1rem; border-radius: 0.5rem; margin-bottom: 2rem;'>
|
||||
Get personalized dietary and fitness plans tailored to your goals and preferences.
|
||||
Our AI-powered system considers your unique profile to create the perfect plan for you.
|
||||
</div>
|
||||
""", unsafe_allow_html=True)
|
||||
|
||||
# Sidebar Configuration
|
||||
with st.sidebar:
|
||||
st.header("🔑 API Configuration")
|
||||
gemini_api_key = st.text_input(
|
||||
"Gemini API Key",
|
||||
type="password",
|
||||
help="Enter your Gemini API key to access the service"
|
||||
)
|
||||
|
||||
if not gemini_api_key:
|
||||
st.warning("⚠️ Please enter your Gemini API Key to proceed")
|
||||
st.markdown("[Get your API key here](https://aistudio.google.com/apikey)")
|
||||
return
|
||||
|
||||
st.success(" API Key accepted!")
|
||||
|
||||
if gemini_api_key:
|
||||
# Initialize Gemini model
|
||||
try:
|
||||
gemini_model = Gemini(id="gemini-1.5-flash", api_key=gemini_api_key)
|
||||
except Exception as e:
|
||||
st.error(f"❌ Error initializing Gemini model: {e}")
|
||||
return
|
||||
|
||||
# User Profile Section
|
||||
st.header("👤 Your Profile")
|
||||
|
||||
col1, col2 = st.columns(2)
|
||||
|
||||
with col1:
|
||||
age = st.number_input("Age", min_value=10, max_value=100, step=1, help="Enter your age")
|
||||
height = st.number_input("Height (cm)", min_value=100.0, max_value=250.0, step=0.1)
|
||||
activity_level = st.selectbox(
|
||||
"Activity Level",
|
||||
options=["Sedentary", "Lightly Active", "Moderately Active", "Very Active", "Extremely Active"],
|
||||
help="Choose your typical activity level"
|
||||
)
|
||||
dietary_preferences = st.selectbox(
|
||||
"Dietary Preferences",
|
||||
options=["Vegetarian", "Keto", "Gluten Free", "Low Carb", "Dairy Free"],
|
||||
help="Select your dietary preference"
|
||||
)
|
||||
|
||||
with col2:
|
||||
weight = st.number_input("Weight (kg)", min_value=20.0, max_value=300.0, step=0.1)
|
||||
sex = st.selectbox("Sex", options=["Male", "Female", "Other"])
|
||||
fitness_goals = st.selectbox(
|
||||
"Fitness Goals",
|
||||
options=["Lose Weight", "Gain Muscle", "Endurance", "Stay Fit", "Strength Training"],
|
||||
help="What do you want to achieve?"
|
||||
)
|
||||
|
||||
# Generate Plan Button
|
||||
if st.button("🎯 Generate My Personalized Plan", use_container_width=True):
|
||||
with st.spinner(" Creating your perfect health and fitness routine..."):
|
||||
try:
|
||||
# Define Agents
|
||||
dietary_agent = Agent(
|
||||
name="Dietary Expert",
|
||||
role="Provides personalized dietary recommendations",
|
||||
model=gemini_model,
|
||||
instructions=[
|
||||
"Consider the user's input, including dietary restrictions and preferences.",
|
||||
"Suggest a detailed meal plan for the day, including breakfast, lunch, dinner, and snacks.",
|
||||
"Provide a brief explanation of why the plan is suited to the user's goals.",
|
||||
"Focus on clarity, coherence, and quality of the recommendations.",
|
||||
]
|
||||
)
|
||||
|
||||
fitness_agent = Agent(
|
||||
name="Fitness Expert",
|
||||
role="Provides personalized fitness recommendations",
|
||||
model=gemini_model,
|
||||
instructions=[
|
||||
"Provide exercises tailored to the user's goals.",
|
||||
"Include warm-up, main workout, and cool-down exercises.",
|
||||
"Explain the benefits of each recommended exercise.",
|
||||
"Ensure the plan is actionable and detailed.",
|
||||
]
|
||||
)
|
||||
|
||||
user_profile = f"""
|
||||
Age: {age}
|
||||
Weight: {weight}kg
|
||||
Height: {height}cm
|
||||
Sex: {sex}
|
||||
Activity Level: {activity_level}
|
||||
Dietary Preferences: {dietary_preferences}
|
||||
Fitness Goals: {fitness_goals}
|
||||
"""
|
||||
|
||||
# Generate plans
|
||||
dietary_plan_response = dietary_agent.run(user_profile)
|
||||
dietary_plan = {
|
||||
"why_this_plan_works": "High Protein, Healthy Fats, Moderate Carbohydrates, and Caloric Balance",
|
||||
"meal_plan": dietary_plan_response.content,
|
||||
"important_considerations": """
|
||||
- Hydration: Drink plenty of water throughout the day
|
||||
- Electrolytes: Monitor sodium, potassium, and magnesium levels
|
||||
- Fiber: Ensure adequate intake through vegetables and fruits
|
||||
- Listen to your body: Adjust portion sizes as needed
|
||||
"""
|
||||
}
|
||||
|
||||
fitness_plan_response = fitness_agent.run(user_profile)
|
||||
fitness_plan = {
|
||||
"goals": "Build strength, improve endurance, and maintain overall fitness",
|
||||
"routine": fitness_plan_response.content,
|
||||
"tips": """
|
||||
- Track your progress regularly
|
||||
- Allow proper rest between workouts
|
||||
- Focus on proper form
|
||||
- Stay consistent with your routine
|
||||
"""
|
||||
}
|
||||
|
||||
# Display plans
|
||||
display_dietary_plan(dietary_plan)
|
||||
display_fitness_plan(fitness_plan)
|
||||
|
||||
# Q&A Section
|
||||
st.header("❓ Questions about your plan?")
|
||||
with st.expander("Ask a question"):
|
||||
question = st.text_input("What would you like to know?")
|
||||
if st.button("Get Answer"):
|
||||
with st.spinner("Finding the best answer for you..."):
|
||||
context = f"Dietary Plan: {dietary_plan['meal_plan']}\n\nFitness Plan: {fitness_plan['routine']}"
|
||||
response = gemini_model.run(f"{context}\nUser Question: {question}")
|
||||
st.info(response.content)
|
||||
|
||||
except Exception as e:
|
||||
st.error(f"❌ An error occurred: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
import streamlit as st
|
||||
from phi.agent import Agent
|
||||
from phi.model.anthropic import Claude
|
||||
from phi.model.google import Gemini
|
||||
|
||||
def display_dietary_plan(plan_content):
|
||||
st.subheader("Dietary Plan")
|
||||
st.markdown(
|
||||
f"""
|
||||
### Why this plan works:
|
||||
{plan_content["why_this_plan_works"]}
|
||||
|
||||
### Meal Plan:
|
||||
{plan_content["meal_plan"]}
|
||||
|
||||
### Important Considerations:
|
||||
{plan_content["important_considerations"]}
|
||||
"""
|
||||
)
|
||||
|
||||
# Function to format and display the fitness plan
|
||||
def display_fitness_plan(plan_content):
|
||||
st.subheader("Fitness Plan")
|
||||
st.markdown(
|
||||
f"""
|
||||
### Goals:
|
||||
{plan_content["goals"]}
|
||||
|
||||
### Exercise Routine:
|
||||
{plan_content["routine"]}
|
||||
|
||||
### Tips:
|
||||
{plan_content["tips"]}
|
||||
"""
|
||||
)
|
||||
|
||||
# Set up the Streamlit app
|
||||
st.title("AI Health and Fitness Agent 🏋️♂️")
|
||||
st.caption("Get personalized dietary and fitness plans based on your preferences and goals.")
|
||||
|
||||
# Use st.secrets for API key in production
|
||||
gemini_api_key = st.sidebar.text_input("Enter Gemini API Key for health and fitness data", type="password")
|
||||
|
||||
if gemini_api_key:
|
||||
st.success("Gemini API Key accepted! Please fill out your profile below.")
|
||||
|
||||
# Initialize the Gemini model once
|
||||
try:
|
||||
gemini_model = Gemini(id="gemini-1.5-flash", api_key=gemini_api_key)
|
||||
except Exception as e:
|
||||
st.error(f"Error initializing Gemini model: {e}")
|
||||
st.stop()
|
||||
|
||||
# Input fields for user's profile
|
||||
st.header("User Profile")
|
||||
age = st.number_input("Age", min_value=10, max_value=100, step=1)
|
||||
weight = st.number_input("Weight (kg)", min_value=20.0, max_value=300.0, step=0.1)
|
||||
height = st.number_input("Height (cm)", min_value=100.0, max_value=250.0, step=0.1)
|
||||
sex = st.selectbox("Sex", options=["Male", "Female", "Other"])
|
||||
activity_level = st.selectbox(
|
||||
"Activity Level",
|
||||
options=["Sedentary", "Lightly Active", "Moderately Active", "Very Active", "Extremely Active"],
|
||||
)
|
||||
dietary_preferences = st.selectbox("Diet Preferences",
|
||||
options=["Vegetarian", "keto", "Gluten free", "Low Carb", "Dairy free"])
|
||||
fitness_goals = st.selectbox(
|
||||
"Fitness Goals",
|
||||
options=["Lose Weight", "Gain Muscle", "Endurance", "Stay Fitness", "strength training"],
|
||||
)
|
||||
if st.button("Generate Personalized Plan"):
|
||||
with st.spinner("Giving you the best Health and Fitness Routine! Patience my guy ;)"):
|
||||
try:
|
||||
# Define the Dietary Agent
|
||||
dietary_agent = Agent(
|
||||
name="Dietary Agent",
|
||||
role="Provides personalized dietary recommendations",
|
||||
model=gemini_model,
|
||||
instructions=[
|
||||
"Consider the user's input, including dietary restrictions and preferences.",
|
||||
"Suggest a detailed meal plan for the day, including breakfast, lunch, dinner, and snacks.",
|
||||
"Provide a brief explanation of why the plan is suited to the user's goals.",
|
||||
"Focus on clarity, coherence, and quality of the recommendations.",
|
||||
],
|
||||
add_history_to_messages=True,
|
||||
markdown=True,
|
||||
)
|
||||
|
||||
# Define the Fitness Agent
|
||||
fitness_agent = Agent(
|
||||
name="Fitness Agent",
|
||||
role="Provides personalized fitness recommendations",
|
||||
model=gemini_model,
|
||||
instructions=[
|
||||
"Provide exercises tailored to the user's goals (e.g., weight loss, muscle gain, general fitness).",
|
||||
"Include warm-up, main workout, and cool-down exercises.",
|
||||
"Explain the benefits of each recommended exercise.",
|
||||
"Ensure the plan is actionable, detailed, and motivational.",
|
||||
],
|
||||
add_history_to_messages=True,
|
||||
markdown=True,
|
||||
)
|
||||
|
||||
# Compile user input into a profile
|
||||
user_profile = f"Age: {age}, Weight: {weight}kg, Height: {height}cm, Sex: {sex}, Activity Level: {activity_level}, Dietary Preferences: {dietary_preferences}, Fitness Goals: {fitness_goals}"
|
||||
|
||||
dietary_plan_response = dietary_agent.run(user_profile)
|
||||
dietary_plan = {
|
||||
"why_this_plan_works": "High Protein, Healthy Fats, Moderate Carbohydrates, and Caloric Surplus.",
|
||||
"meal_plan": dietary_plan_response.content,
|
||||
"important_considerations": """
|
||||
- Hydration: Drink plenty of water.
|
||||
- Electrolytes: Monitor sodium, potassium, and magnesium levels.
|
||||
- Fiber: Ensure adequate intake through vegetables.
|
||||
- Listen to your body: Adjust portion sizes as needed.
|
||||
""",
|
||||
}
|
||||
display_dietary_plan(dietary_plan)
|
||||
|
||||
# Generate Fitness Plan
|
||||
fitness_plan_response = fitness_agent.run(user_profile)
|
||||
fitness_plan = {
|
||||
"goals": "Build muscle strength and endurance.",
|
||||
"routine": fitness_plan_response.content,
|
||||
"tips": """
|
||||
- Track Progress: Record weights and reps to ensure progressive overload.
|
||||
- Rest: Allow at least 48 hours between sessions for recovery.
|
||||
- Consistency: Stick to the plan for optimal results.
|
||||
""",
|
||||
}
|
||||
display_fitness_plan(fitness_plan)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
st.error(f"An error occurred: {e}")
|
||||
else:
|
||||
st.warning("Please enter your Gemini API Key to proceed. go get it here: https://aistudio.google.com/apikey")
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
phidata
|
||||
google-generativeai
|
||||
anthropic
|
||||
streamlit
|
||||
Loading…
Reference in a new issue