Aadarshwahmare commited on
Commit
d1da58a
Β·
verified Β·
1 Parent(s): 51bf834

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -13
app.py CHANGED
@@ -12,31 +12,50 @@ genai.configure(api_key=api_key)
12
 
13
  model = genai.GenerativeModel("gemini-1.5-flash")
14
 
15
-
16
  def fitness_coach(age, weight, goal, activity):
17
  try:
18
  prompt = f"""
19
- You are a certified fitness coach.
20
-
21
- Create a personalized fitness plan:
22
-
23
  Age: {age}
24
  Weight: {weight}
25
  Goal: {goal}
26
- Activity Level: {activity}
27
-
28
- Include:
29
- 1. Workout Plan
30
- 2. Diet Plan
31
- 3. Tips
32
  """
33
 
34
  response = model.generate_content(prompt)
35
 
36
- return response.candidates[0].content.parts[0].text if response.text else "No response generated"
 
37
 
38
  except Exception as e:
39
- return f"Error: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
 
42
  interface = gr.Interface(
 
12
 
13
  model = genai.GenerativeModel("gemini-1.5-flash")
14
 
 
15
  def fitness_coach(age, weight, goal, activity):
16
  try:
17
  prompt = f"""
18
+ Create a fitness plan:
 
 
 
19
  Age: {age}
20
  Weight: {weight}
21
  Goal: {goal}
22
+ Activity: {activity}
 
 
 
 
 
23
  """
24
 
25
  response = model.generate_content(prompt)
26
 
27
+ if response and hasattr(response, "text"):
28
+ return response.text
29
 
30
  except Exception as e:
31
+ print("API failed:", e)
32
+
33
+
34
+ return f"""
35
+ πŸ’ͺ Personalized Fitness Plan
36
+
37
+ πŸ‘€ Age: {age}
38
+ βš– Weight: {weight} kg
39
+ 🎯 Goal: {goal}
40
+ πŸƒ Activity Level: {activity}
41
+
42
+ πŸ‹ Workout Plan:
43
+ - 3-5 days exercise per week
44
+ - Cardio + Strength training
45
+ - Beginner β†’ start light
46
+
47
+ πŸ₯— Diet Plan:
48
+ - High protein foods
49
+ - Reduce junk food
50
+ - Drink 2-3L water daily
51
+
52
+ πŸ’‘ Tips:
53
+ - Sleep 7-8 hours
54
+ - Stay consistent
55
+ - Track progress weekly
56
+ """
57
+
58
+
59
 
60
 
61
  interface = gr.Interface(