Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,18 +29,13 @@ def respond(message, history):
|
|
| 29 |
return response['choices'][0]['message']['content'].strip()
|
| 30 |
|
| 31 |
# --- Personalized workout planner ---
|
| 32 |
-
def make_workout_plan(
|
| 33 |
plan = f"""
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
**Plan:**
|
| 40 |
-
- Warm-up: 5 min light cardio
|
| 41 |
-
- Main workout: Mix of {style}-focused exercises ({days} days/week)
|
| 42 |
-
- Nutrition tip: Stay hydrated and eat balanced meals π₯
|
| 43 |
-
- Motivation: Progress over perfection, always! β¨
|
| 44 |
"""
|
| 45 |
return plan
|
| 46 |
|
|
@@ -54,59 +49,13 @@ quotes = [
|
|
| 54 |
def random_quote():
|
| 55 |
return random.choice(quotes)
|
| 56 |
|
| 57 |
-
# --- Gear & clothing recommendations ---
|
| 58 |
-
def recommend_gear(style):
|
| 59 |
-
gear = {
|
| 60 |
-
"Yoga": [
|
| 61 |
-
"Non-slip yoga mat π§ββοΈ",
|
| 62 |
-
"Comfortable leggings & sports bra set",
|
| 63 |
-
"Yoga blocks for better flexibility",
|
| 64 |
-
"Water bottle with time markers"
|
| 65 |
-
],
|
| 66 |
-
"HIIT": [
|
| 67 |
-
"Breathable tank top & shorts",
|
| 68 |
-
"Lightweight running shoes with good grip",
|
| 69 |
-
"Resistance bands",
|
| 70 |
-
"Sweat-proof headband"
|
| 71 |
-
],
|
| 72 |
-
"Strength Training": [
|
| 73 |
-
"Supportive lifting gloves",
|
| 74 |
-
"Compression leggings",
|
| 75 |
-
"Adjustable dumbbells",
|
| 76 |
-
"Weightlifting belt"
|
| 77 |
-
],
|
| 78 |
-
"Pilates": [
|
| 79 |
-
"Soft Pilates mat",
|
| 80 |
-
"Grippy socks",
|
| 81 |
-
"Resistance ring",
|
| 82 |
-
"Comfort-fit workout set"
|
| 83 |
-
],
|
| 84 |
-
"Mixed": [
|
| 85 |
-
"All-purpose sneakers",
|
| 86 |
-
"Moisture-wicking top",
|
| 87 |
-
"Adjustable kettlebell",
|
| 88 |
-
"Foam roller"
|
| 89 |
-
]
|
| 90 |
-
}
|
| 91 |
-
items = gear.get(style, ["Choose a workout style for recommendations!"])
|
| 92 |
-
return "### π Recommended Gear & Clothing\n" + "\n".join([f"- {item}" for item in items])
|
| 93 |
-
|
| 94 |
# --- Build UI ---
|
| 95 |
-
with gr.Blocks(
|
| 96 |
-
theme=gr.themes.Soft(primary_hue="pink", secondary_hue="rose"),
|
| 97 |
-
css=".gradio-container {background-color: #ffe6f0;}" # Light pink background
|
| 98 |
-
) as demo:
|
| 99 |
-
|
| 100 |
-
# Logo
|
| 101 |
-
gr.Image(value="/mnt/data/8e79ec27-2f8b-4ebf-a249-114a8c0dbc15.png", show_label=False, elem_id="logo")
|
| 102 |
-
|
| 103 |
-
# Cute header with extra images
|
| 104 |
gr.Markdown(
|
| 105 |
"""
|
| 106 |
-
#
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
Letβs make workouts fun, personal, and motivating πͺβ¨
|
| 110 |
"""
|
| 111 |
)
|
| 112 |
|
|
@@ -114,25 +63,16 @@ with gr.Blocks(
|
|
| 114 |
gr.ChatInterface(respond, type="messages", title="Fitora - AI Fitness Coach")
|
| 115 |
|
| 116 |
with gr.Tab("π Personalized Workout Planner"):
|
| 117 |
-
name_input = gr.Textbox(label="Your Name", placeholder="e.g., Ella")
|
| 118 |
goal_input = gr.Textbox(label="Your Fitness Goal", placeholder="e.g., tone arms, lose weight")
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
plan_btn = gr.Button("Generate My Plan β¨")
|
| 122 |
plan_output = gr.Markdown()
|
| 123 |
-
plan_btn.click(make_workout_plan, [
|
| 124 |
|
| 125 |
with gr.Tab("β¨ Daily Motivation"):
|
| 126 |
-
gr.
|
| 127 |
-
quote_btn = gr.Button("Get Inspired! π")
|
| 128 |
quote_output = gr.Markdown()
|
| 129 |
quote_btn.click(lambda: random_quote(), outputs=quote_output)
|
| 130 |
|
| 131 |
-
|
| 132 |
-
style_choice = gr.Dropdown(["Yoga", "HIIT", "Strength Training", "Pilates", "Mixed"], label="Your Workout Style")
|
| 133 |
-
gear_btn = gr.Button("Show Recommendations")
|
| 134 |
-
gear_output = gr.Markdown()
|
| 135 |
-
gear_btn.click(recommend_gear, [style_choice], gear_output)
|
| 136 |
-
gr.Image(value="https://i.imgur.com/SMY7V6E.png", show_label=False) # cute shopping image
|
| 137 |
-
|
| 138 |
demo.launch()
|
|
|
|
| 29 |
return response['choices'][0]['message']['content'].strip()
|
| 30 |
|
| 31 |
# --- Personalized workout planner ---
|
| 32 |
+
def make_workout_plan(goal, timeframe):
|
| 33 |
plan = f"""
|
| 34 |
+
π **Personalized Plan for {goal} in {timeframe}**
|
| 35 |
+
- Warm-up: 5 min light cardio (jumping jacks, jogging in place)
|
| 36 |
+
- Main workout: 3x10 {goal}-focused exercises
|
| 37 |
+
- Cool-down: 5 min stretching
|
| 38 |
+
- Nutrition tip: Stay hydrated and aim for balanced meals πΈ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
"""
|
| 40 |
return plan
|
| 41 |
|
|
|
|
| 49 |
def random_quote():
|
| 50 |
return random.choice(quotes)
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# --- Build UI ---
|
| 53 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="pink", secondary_hue="rose")) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
gr.Markdown(
|
| 55 |
"""
|
| 56 |
+
# πΈ **Fitora β Your AI Fitness Coach**
|
| 57 |
+
Welcome to your pink-powered, motivational fitness buddy!
|
| 58 |
+
Let's crush your goals together πͺβ¨
|
|
|
|
| 59 |
"""
|
| 60 |
)
|
| 61 |
|
|
|
|
| 63 |
gr.ChatInterface(respond, type="messages", title="Fitora - AI Fitness Coach")
|
| 64 |
|
| 65 |
with gr.Tab("π Personalized Workout Planner"):
|
|
|
|
| 66 |
goal_input = gr.Textbox(label="Your Fitness Goal", placeholder="e.g., tone arms, lose weight")
|
| 67 |
+
time_input = gr.Textbox(label="Timeframe", placeholder="e.g., 4 weeks, 3 months")
|
| 68 |
+
plan_btn = gr.Button("Generate Plan")
|
|
|
|
| 69 |
plan_output = gr.Markdown()
|
| 70 |
+
plan_btn.click(make_workout_plan, [goal_input, time_input], plan_output)
|
| 71 |
|
| 72 |
with gr.Tab("β¨ Daily Motivation"):
|
| 73 |
+
quote_btn = gr.Button("Get Inspired!")
|
|
|
|
| 74 |
quote_output = gr.Markdown()
|
| 75 |
quote_btn.click(lambda: random_quote(), outputs=quote_output)
|
| 76 |
|
| 77 |
+
# Launch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
demo.launch()
|