File size: 2,323 Bytes
3d5c81c
d33b8ce
 
 
601159b
 
 
d33b8ce
 
 
 
 
 
 
 
601159b
 
 
 
 
 
 
d33b8ce
 
601159b
 
 
 
 
 
 
 
 
 
 
d33b8ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601159b
 
 
 
 
 
d33b8ce
601159b
 
 
 
 
d33b8ce
601159b
 
 
 
 
 
 
 
d33b8ce
 
 
 
 
601159b
d33b8ce
 
 
601159b
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import streamlit as st
from model_api import query_model
from prompt_builder import build_prompt

# --------------------------------------------------
# Page Config
# --------------------------------------------------
st.set_page_config(page_title="FitPlan AI", layout="centered")

st.title("๐Ÿ‹๏ธ FitPlan AI โ€“ Personalized Workout Generator")

# ---------------- INPUT ---------------- #

name = st.text_input("Enter Your Name")

age = st.number_input(
    "Age (years)",
    min_value=10,
    max_value=100,
    step=1
)

gender = st.radio("Gender", ["Male", "Female"])

height = st.number_input(
    "Height (cm)",
    min_value=100.0,
    max_value=250.0
)

weight = st.number_input(
    "Weight (kg)",
    min_value=30.0,
    max_value=200.0
)

goal = st.selectbox(
    "Fitness Goal",
    ["Build Muscle", "Lose Weight", "Improve Endurance", "General Fitness"]
)

fitness_level = st.radio(
    "Fitness Level",
    ["Beginner", "Intermediate", "Advanced"]
)

equipment = st.multiselect(
    "Available Equipment",
    [
        "No Equipment", "Dumbbells", "Barbell",
        "Pull-up Bar", "Resistance Bands",
        "Treadmill", "Kettlebells", "Full Gym"
    ]
)

# ---------------- GENERATE ---------------- #

if st.button("Generate Workout Plan"):

    # -------- Validation --------
    if not name.strip():
        st.warning("Please enter your name.")

    elif age <= 0:
        st.warning("Please enter a valid age.")

    elif height <= 0 or weight <= 0:
        st.warning("Please enter valid height and weight.")

    else:
        # build_prompt now includes age
        prompt, bmi, bmi_status = build_prompt(
            name,
            age,
            gender,
            height,
            weight,
            goal,
            fitness_level,
            equipment
        )

        with st.spinner("Generating your personalized plan..."):
            response = query_model(prompt)

        # -------- Output --------
        st.subheader("๐Ÿ“‹ Your Personalized Workout Plan")
        st.write(response)

        st.info(
            f"""
            **Profile Summary**
            - Name: {name}
            - Age: {age}
            - Gender: {gender}
            - BMI: {bmi:.2f} ({bmi_status})
            - Goal: {goal}
            - Level: {fitness_level}
            """
        )