elloxli commited on
Commit
8a5d0cc
Β·
verified Β·
1 Parent(s): bb4565e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -75
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(name, goal, style, days):
33
  plan = f"""
34
- 🌸 **Hi {name}! Here’s Your Personalized Plan** 🌸
35
- **Goal:** {goal}
36
- **Style:** {style}
37
- **Days per week:** {days}
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
- ## 🌸 **Fitora β€” Be Your Own Inspiration** 🌸
107
- ![fitness](https://i.imgur.com/vXr0gkV.png)
108
- Welcome to your cute, colorful fitness buddy!
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
- style_input = gr.Dropdown(["Yoga", "HIIT", "Strength Training", "Pilates", "Mixed"], label="Preferred Workout Style")
120
- days_slider = gr.Slider(1, 7, step=1, label="Days per Week")
121
- plan_btn = gr.Button("Generate My Plan ✨")
122
  plan_output = gr.Markdown()
123
- plan_btn.click(make_workout_plan, [name_input, goal_input, style_input, days_slider], plan_output)
124
 
125
  with gr.Tab("✨ Daily Motivation"):
126
- gr.Image(value="https://i.imgur.com/yXOvdOS.png", show_label=False)
127
- quote_btn = gr.Button("Get Inspired! 🌟")
128
  quote_output = gr.Markdown()
129
  quote_btn.click(lambda: random_quote(), outputs=quote_output)
130
 
131
- with gr.Tab("πŸ› Fitness Clothing & Gear"):
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()