Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,137 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
from model_api import query_model
|
| 5 |
-
from prompt_builder import build_prompt
|
| 6 |
-
|
| 7 |
-
st.set_page_config(page_title="FitPlan AI- Login", layout="centered")
|
| 8 |
-
|
| 9 |
-
# ------------------ CSS DESIGN ------------------
|
| 10 |
-
|
| 11 |
-
st.markdown("""
|
| 12 |
-
<style>
|
| 13 |
-
|
| 14 |
-
.stApp{
|
| 15 |
-
background: linear-gradient(rgba(0,0,0,0.75), rgba(0,0,0,0.85)),
|
| 16 |
-
url("https://images.unsplash.com/photo-1534438327276-14e5300c3a48");
|
| 17 |
-
background-size: cover;
|
| 18 |
-
background-position: center;
|
| 19 |
-
background-attachment: fixed;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
.login-card{
|
| 23 |
-
background: rgba(255,255,255,0.08);
|
| 24 |
-
backdrop-filter: blur(10px);
|
| 25 |
-
padding:40px;
|
| 26 |
-
border-radius:20px;
|
| 27 |
-
width:420px;
|
| 28 |
-
margin:auto;
|
| 29 |
-
margin-top:120px;
|
| 30 |
-
box-shadow:0 10px 35px rgba(0,0,0,0.6);
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
.title{
|
| 34 |
-
text-align:center;
|
| 35 |
-
font-size:34px;
|
| 36 |
-
font-weight:700;
|
| 37 |
-
color:white;
|
| 38 |
-
margin-bottom:25px;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
.subtitle{
|
| 42 |
-
text-align:center;
|
| 43 |
-
color:#cbd5f5;
|
| 44 |
-
margin-bottom:25px;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
div[data-baseweb="input"]{
|
| 48 |
-
background:#0f172a;
|
| 49 |
-
border-radius:10px;
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
.stTextInput input{
|
| 53 |
-
color:white;
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
.stButton>button{
|
| 57 |
-
width:100%;
|
| 58 |
-
height:48px;
|
| 59 |
-
border-radius:12px;
|
| 60 |
-
border:none;
|
| 61 |
-
font-size:16px;
|
| 62 |
-
font-weight:600;
|
| 63 |
-
color:white;
|
| 64 |
-
background:linear-gradient(90deg,#3b82f6,#6366f1);
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
.stButton>button:hover{
|
| 68 |
-
background:linear-gradient(90deg,#2563eb,#4f46e5);
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
</style>
|
| 72 |
-
""", unsafe_allow_html=True)
|
| 73 |
-
|
| 74 |
-
# ------------------ SESSION ------------------
|
| 75 |
-
|
| 76 |
-
if "logged_in" not in st.session_state:
|
| 77 |
-
st.session_state.logged_in = False
|
| 78 |
-
|
| 79 |
-
if "otp" not in st.session_state:
|
| 80 |
-
st.session_state.otp = None
|
| 81 |
-
|
| 82 |
-
# ------------------ LOGIN PAGE ------------------
|
| 83 |
-
|
| 84 |
-
if not st.session_state.logged_in:
|
| 85 |
-
|
| 86 |
-
st.markdown('<div class="login-card">', unsafe_allow_html=True)
|
| 87 |
-
|
| 88 |
-
st.markdown('<div class="title">💪 FitPlan AI</div>', unsafe_allow_html=True)
|
| 89 |
-
st.markdown('<div class="subtitle">Login to your account</div>', unsafe_allow_html=True)
|
| 90 |
-
|
| 91 |
-
email = st.text_input("📧 Enter Email")
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
send_otp_email(email, otp)
|
| 100 |
-
|
| 101 |
-
st.success("OTP sent to your email")
|
| 102 |
-
|
| 103 |
-
else:
|
| 104 |
-
st.warning("Please enter email")
|
| 105 |
-
|
| 106 |
-
user_otp = st.text_input("🔐 Enter OTP")
|
| 107 |
-
|
| 108 |
-
if st.button("Verify OTP"):
|
| 109 |
-
|
| 110 |
-
if user_otp and user_otp == st.session_state.otp:
|
| 111 |
-
|
| 112 |
-
token = create_jwt(email)
|
| 113 |
-
|
| 114 |
-
st.session_state.logged_in = True
|
| 115 |
-
st.session_state.token = token
|
| 116 |
-
|
| 117 |
-
st.success("Login Successful 🎉")
|
| 118 |
-
st.rerun()
|
| 119 |
-
|
| 120 |
-
else:
|
| 121 |
-
st.error("Invalid OTP")
|
| 122 |
-
|
| 123 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 124 |
-
|
| 125 |
-
st.stop()
|
| 126 |
|
| 127 |
-
# =====================================================
|
| 128 |
-
# 💪 WORKOUT GENERATOR PAGE
|
| 129 |
-
# =====================================================
|
| 130 |
|
|
|
|
| 131 |
st.title("🏋️ AI Personalized 5-Day Workout Planner")
|
| 132 |
|
| 133 |
name = st.text_input("Name")
|
| 134 |
-
age = st.number_input("Age", min_value=0, max_value=100)
|
| 135 |
gender = st.selectbox("Gender", ["Male", "Female", "Other"])
|
| 136 |
|
| 137 |
height = st.number_input("Height (cm)", min_value=0, max_value=250)
|
|
@@ -155,9 +38,9 @@ equipment = st.multiselect(
|
|
| 155 |
if st.button("Generate 5-Day Plan 💪"):
|
| 156 |
|
| 157 |
prompt, bmi, bmi_status = build_prompt(
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
)
|
| 161 |
|
| 162 |
st.subheader(f"Your BMI: {bmi:.2f} ({bmi_status})")
|
| 163 |
|
|
@@ -165,21 +48,4 @@ if st.button("Generate 5-Day Plan 💪"):
|
|
| 165 |
result = query_model(prompt)
|
| 166 |
|
| 167 |
st.markdown("## 🗓️ Your 5-Day Workout Plan")
|
| 168 |
-
|
| 169 |
-
if isinstance(result, dict):
|
| 170 |
-
|
| 171 |
-
st.markdown("## 🗓️ Your 5-Day Workout Plan")
|
| 172 |
-
|
| 173 |
-
st.markdown(result, unsafe_allow_html=True)
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
else:
|
| 177 |
-
st.error("Model returned invalid workout format")
|
| 178 |
-
st.write(result)
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
# ---------- LOGOUT ----------
|
| 182 |
-
if st.button("Logout"):
|
| 183 |
-
st.session_state.logged_in = False
|
| 184 |
-
st.session_state.token = None
|
| 185 |
-
st.rerun()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import sys
|
| 3 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# ---------- ADD EXTERNAL PATHS ----------
|
| 6 |
+
sys.path.append(os.path.abspath("../model"))
|
| 7 |
+
sys.path.append(os.path.abspath("../prompt"))
|
| 8 |
|
| 9 |
+
# ---------- IMPORT YOUR FILES ----------
|
| 10 |
+
from model_api import query_model
|
| 11 |
+
from prompt_builder import build_prompt, calculate_bmi, bmi_category
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
# ---------- STREAMLIT UI ----------
|
| 15 |
st.title("🏋️ AI Personalized 5-Day Workout Planner")
|
| 16 |
|
| 17 |
name = st.text_input("Name")
|
|
|
|
| 18 |
gender = st.selectbox("Gender", ["Male", "Female", "Other"])
|
| 19 |
|
| 20 |
height = st.number_input("Height (cm)", min_value=0, max_value=250)
|
|
|
|
| 38 |
if st.button("Generate 5-Day Plan 💪"):
|
| 39 |
|
| 40 |
prompt, bmi, bmi_status = build_prompt(
|
| 41 |
+
name, gender, height, weight,
|
| 42 |
+
goal, fitness_level, equipment
|
| 43 |
+
)
|
| 44 |
|
| 45 |
st.subheader(f"Your BMI: {bmi:.2f} ({bmi_status})")
|
| 46 |
|
|
|
|
| 48 |
result = query_model(prompt)
|
| 49 |
|
| 50 |
st.markdown("## 🗓️ Your 5-Day Workout Plan")
|
| 51 |
+
st.write(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|