srustik123 commited on
Commit
6091967
·
verified ·
1 Parent(s): e3b375a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -20
app.py CHANGED
@@ -102,26 +102,34 @@ if submit:
102
  # -------------------------
103
  with st.spinner("Generating your 5-day workout plan..."):
104
 
105
- full_plan = ""
106
-
107
- for day in range(1, 6):
108
-
109
- prompt = f"""
110
- You are a certified professional fitness trainer.
111
- Create a detailed workout plan for Day {day}.
112
- Include:
113
- - Warm-up
114
- - 4 to 6 exercises
115
- - Sets and reps
116
- - Cool down
117
- User Details:
118
- BMI: {bmi} ({bmi_status})
119
- Goal: {goal}
120
- Fitness Level: {level}
121
- Equipment Available: {equipment_list}
122
- Start with:
123
- Day {day}:
124
- """
 
 
 
 
 
 
 
 
125
 
126
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
127
 
 
102
  # -------------------------
103
  with st.spinner("Generating your 5-day workout plan..."):
104
 
105
+ from prompt_builder import build_prompt
106
+
107
+ with st.spinner("Generating your 5-day workout plan..."):
108
+
109
+ prompt, bmi, bmi_status = build_prompt(
110
+ name=name,
111
+ gender="Not specified", # or add gender field in form
112
+ height=height,
113
+ weight=weight,
114
+ goal=goal,
115
+ fitness_level=level,
116
+ equipment=equipment
117
+ )
118
+
119
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
120
+
121
+ outputs = model.generate(
122
+ **inputs,
123
+ max_new_tokens=800, # increase token limit
124
+ temperature=0.7,
125
+ do_sample=True,
126
+ repetition_penalty=1.1
127
+ )
128
+
129
+ full_plan = tokenizer.decode(
130
+ outputs[0],
131
+ skip_special_tokens=True
132
+ ).strip()
133
 
134
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
135