Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 20 |
-
|
| 21 |
-
Create a personalized fitness plan:
|
| 22 |
-
|
| 23 |
Age: {age}
|
| 24 |
Weight: {weight}
|
| 25 |
Goal: {goal}
|
| 26 |
-
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 |
-
|
|
|
|
| 37 |
|
| 38 |
except Exception as e:
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|