Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,26 +102,34 @@ if submit:
|
|
| 102 |
# -------------------------
|
| 103 |
with st.spinner("Generating your 5-day workout plan..."):
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 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 |
|