saiganesh2004 commited on
Commit
f94a9e1
·
verified ·
1 Parent(s): 5b2a369

Update prompt_builder.py

Browse files
Files changed (1) hide show
  1. prompt_builder.py +50 -17
prompt_builder.py CHANGED
@@ -1,8 +1,14 @@
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:
@@ -12,39 +18,66 @@ def bmi_category(bmi):
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
  - Age: {age} years
31
  - Gender: {gender}
32
  - Height: {height} cm
33
  - Weight: {weight} kg
34
  - BMI: {bmi:.2f} ({bmi_status})
35
- - Goal: {goal}
36
  - Fitness Level: {fitness_level}
37
  - Available Equipment: {equipment_list}
 
 
 
38
 
39
- Instructions:
40
- 1. Divide clearly into Day 1 to Day 5.
41
- 2. Include exercise name.
42
- 3. Include sets and reps.
43
- 4. Include rest period.
44
- 5. Adjust intensity based on BMI category.
45
- 6. Avoid unsafe exercises for beginners.
46
- 7. Keep the plan professional and easy to follow.
 
 
 
 
 
 
 
47
 
 
48
  """
49
 
50
  return prompt, bmi, bmi_status
 
1
  def calculate_bmi(weight, height):
2
+ """
3
+ Calculate BMI from weight (kg) and height (cm)
4
+ """
5
  height_m = height / 100
6
  return weight / (height_m ** 2)
7
 
8
  def bmi_category(bmi):
9
+ """
10
+ Categorize BMI value
11
+ """
12
  if bmi < 18.5:
13
  return "Underweight"
14
  elif bmi < 25:
 
18
  else:
19
  return "Obese"
20
 
21
+ def build_prompt(name, age, gender, height, weight, goal, fitness_level, equipment):
22
+ """
23
+ Build a prompt for the AI model including all user parameters
24
+ """
25
  bmi = calculate_bmi(weight, height)
26
  bmi_status = bmi_category(bmi)
27
 
28
  equipment_list = ", ".join(equipment) if equipment else "No Equipment"
29
+
30
+ # Age-specific considerations
31
+ age_considerations = ""
32
+ if age < 18:
33
+ age_considerations = "\n⚠️ Note: User is under 18. Focus on proper form and bodyweight exercises. Avoid heavy lifting."
34
+ elif age > 50:
35
+ age_considerations = "\n⚠️ Note: User is over 50. Focus on joint-friendly exercises, mobility work, and lower impact activities."
36
+
37
+ # Goal-specific instructions
38
+ goal_instructions = {
39
+ "Weight Loss": "Focus on compound exercises and include cardio intervals. Higher reps with moderate weight.",
40
+ "Build Muscle": "Focus on hypertrophy with moderate weights and higher reps. Include progressive overload.",
41
+ "Strength Gain": "Focus on lower reps with heavier weights. Include compound lifts.",
42
+ "Abs Building": "Include core-specific exercises along with full-body compound movements.",
43
+ "Flexibility": "Include dynamic and static stretching, yoga poses, and mobility work."
44
+ }
45
+
46
+ specific_instruction = goal_instructions.get(goal, "Balance cardio and strength training.")
47
 
48
+ prompt = f"""You are a certified professional fitness trainer. Create a comprehensive 5-day workout plan.
 
49
 
50
+ USER PROFILE:
 
 
51
  - Name: {name}
52
  - Age: {age} years
53
  - Gender: {gender}
54
  - Height: {height} cm
55
  - Weight: {weight} kg
56
  - BMI: {bmi:.2f} ({bmi_status})
57
+ - Primary Goal: {goal}
58
  - Fitness Level: {fitness_level}
59
  - Available Equipment: {equipment_list}
60
+ {age_considerations}
61
+
62
+ SPECIFIC FOCUS: {specific_instruction}
63
 
64
+ REQUIREMENTS FOR THE WORKOUT PLAN:
65
+ 1. Create a COMPLETE 5-day workout plan with clear "Day 1" through "Day 5" headers
66
+ 2. For each day, include 4-6 exercises
67
+ 3. For EVERY exercise, specify:
68
+ - Exercise name
69
+ - Number of sets and reps (e.g., "3 sets of 12 reps")
70
+ - Rest period between sets (e.g., "Rest 60 seconds")
71
+ 4. Include a brief warm-up recommendation for each day
72
+ 5. Include a cool-down/stretch recommendation
73
+ 6. Adjust exercise intensity based on:
74
+ - BMI category ({bmi_status})
75
+ - Fitness level ({fitness_level})
76
+ - Age considerations
77
+ 7. Ensure all exercises are safe and appropriate for a {fitness_level}
78
+ 8. Modify exercises based on available equipment: {equipment_list}
79
 
80
+ Please provide a well-structured, easy-to-follow 5-day workout plan that addresses the user's specific goal of {goal}.
81
  """
82
 
83
  return prompt, bmi, bmi_status