Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,38 +90,19 @@ if st.button("Generate Workout Plan"):
|
|
| 90 |
st.write(f"Category: **{bmi_status}**")
|
| 91 |
|
| 92 |
prompt = f"""
|
| 93 |
-
You are a
|
| 94 |
|
| 95 |
-
Generate
|
| 96 |
-
DO NOT generate Day 6 or beyond.
|
| 97 |
-
DO NOT add explanations before or after.
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
Warm-up
|
| 103 |
-
Workout
|
| 104 |
-
Rest
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
Workout:
|
| 109 |
-
Rest:
|
| 110 |
-
|
| 111 |
-
Day 3:
|
| 112 |
-
Warm-up:
|
| 113 |
-
Workout:
|
| 114 |
-
Rest:
|
| 115 |
-
|
| 116 |
-
Day 4:
|
| 117 |
-
Warm-up:
|
| 118 |
-
Workout:
|
| 119 |
-
Rest:
|
| 120 |
-
|
| 121 |
-
Day 5:
|
| 122 |
-
Warm-up:
|
| 123 |
-
Workout:
|
| 124 |
-
Rest:
|
| 125 |
|
| 126 |
User Details:
|
| 127 |
Name: {name}
|
|
@@ -133,7 +114,9 @@ Goal: {goal}
|
|
| 133 |
Fitness Level: {fitness_level}
|
| 134 |
Equipment: {equipment_list}
|
| 135 |
|
| 136 |
-
Start directly with
|
|
|
|
|
|
|
| 137 |
"""
|
| 138 |
|
| 139 |
with st.spinner("Generating structured workout plan..."):
|
|
@@ -142,19 +125,20 @@ Start directly with Day 1.
|
|
| 142 |
|
| 143 |
outputs = model.generate(
|
| 144 |
**inputs,
|
| 145 |
-
max_new_tokens=
|
| 146 |
-
temperature=0.
|
| 147 |
do_sample=True,
|
| 148 |
-
top_p=0.
|
| 149 |
-
repetition_penalty=1.
|
| 150 |
-
no_repeat_ngram_size=3
|
|
|
|
| 151 |
)
|
| 152 |
|
| 153 |
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 154 |
|
| 155 |
-
#
|
| 156 |
if "Day 6" in result:
|
| 157 |
result = result.split("Day 6")[0]
|
| 158 |
|
| 159 |
st.subheader("🏋️ Your 5-Day Workout Plan")
|
| 160 |
-
st.
|
|
|
|
| 90 |
st.write(f"Category: **{bmi_status}**")
|
| 91 |
|
| 92 |
prompt = f"""
|
| 93 |
+
You are a certified professional fitness trainer.
|
| 94 |
|
| 95 |
+
Generate a COMPLETE 5-day workout plan.
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
RULES:
|
| 98 |
+
- Generate ONLY Day 1 to Day 5.
|
| 99 |
+
- Each day must include:
|
| 100 |
+
Warm-up (minimum 3 exercises)
|
| 101 |
+
Workout (minimum 4 exercises with sets and reps)
|
| 102 |
+
Rest time in seconds.
|
| 103 |
+
- Do NOT create Day 6.
|
| 104 |
+
- Do NOT leave any section empty.
|
| 105 |
+
- Do NOT write placeholders.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
User Details:
|
| 108 |
Name: {name}
|
|
|
|
| 114 |
Fitness Level: {fitness_level}
|
| 115 |
Equipment: {equipment_list}
|
| 116 |
|
| 117 |
+
Start directly with:
|
| 118 |
+
|
| 119 |
+
Day 1:
|
| 120 |
"""
|
| 121 |
|
| 122 |
with st.spinner("Generating structured workout plan..."):
|
|
|
|
| 125 |
|
| 126 |
outputs = model.generate(
|
| 127 |
**inputs,
|
| 128 |
+
max_new_tokens=700,
|
| 129 |
+
temperature=0.95,
|
| 130 |
do_sample=True,
|
| 131 |
+
top_p=0.95,
|
| 132 |
+
repetition_penalty=1.3,
|
| 133 |
+
no_repeat_ngram_size=3,
|
| 134 |
+
early_stopping=True
|
| 135 |
)
|
| 136 |
|
| 137 |
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 138 |
|
| 139 |
+
# Hard stop safety (guarantee 5 days only)
|
| 140 |
if "Day 6" in result:
|
| 141 |
result = result.split("Day 6")[0]
|
| 142 |
|
| 143 |
st.subheader("🏋️ Your 5-Day Workout Plan")
|
| 144 |
+
st.write(result)
|