Spaces:
Sleeping
Sleeping
Create prompt_builder.py
Browse files- prompt_builder.py +48 -0
prompt_builder.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def calculate_bmi(weight, height):
|
| 2 |
+
height_m = height / 100
|
| 3 |
+
return weight / (height_m ** 2)
|
| 4 |
+
|
| 5 |
+
def bmi_category(bmi):
|
| 6 |
+
if bmi < 18.5:
|
| 7 |
+
return "Underweight"
|
| 8 |
+
elif bmi < 25:
|
| 9 |
+
return "Normal Weight"
|
| 10 |
+
elif bmi < 30:
|
| 11 |
+
return "Overweight"
|
| 12 |
+
else:
|
| 13 |
+
return "Obese"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def build_prompt(name, gender, height, weight, goal, fitness_level, equipment):
|
| 17 |
+
|
| 18 |
+
bmi = calculate_bmi(weight, height)
|
| 19 |
+
bmi_status = bmi_category(bmi)
|
| 20 |
+
|
| 21 |
+
equipment_list = ", ".join(equipment) if equipment else "No Equipment"
|
| 22 |
+
|
| 23 |
+
prompt = f"""
|
| 24 |
+
You are a certified professional fitness trainer.
|
| 25 |
+
|
| 26 |
+
Create a structured 5-day personalized workout plan.
|
| 27 |
+
|
| 28 |
+
User Profile:
|
| 29 |
+
- Name: {name}
|
| 30 |
+
- Gender: {gender}
|
| 31 |
+
- Height: {height} cm
|
| 32 |
+
- Weight: {weight} kg
|
| 33 |
+
- BMI: {bmi:.2f} ({bmi_status})
|
| 34 |
+
- Goal: {goal}
|
| 35 |
+
- Fitness Level: {fitness_level}
|
| 36 |
+
- Available Equipment: {equipment_list}
|
| 37 |
+
|
| 38 |
+
Instructions:
|
| 39 |
+
1. Divide clearly into Day 1 to Day 5.
|
| 40 |
+
2. Include exercise name.
|
| 41 |
+
3. Include sets and reps.
|
| 42 |
+
4. Include rest period.
|
| 43 |
+
5. Adjust intensity based on BMI category.
|
| 44 |
+
6. Avoid unsafe exercises for beginners.
|
| 45 |
+
7. Keep the plan professional and easy to follow.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
return prompt, bmi, bmi_status
|