Amrutha04 commited on
Commit
074e3cc
·
verified ·
1 Parent(s): faae1b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -23
app.py CHANGED
@@ -1,11 +1,10 @@
1
  import streamlit as st
2
  from prompt_builder import build_prompt
3
- from model_api import query_model # Import your API function
4
 
5
- # 1. Page Configuration
6
  st.set_page_config(page_title="FitPlan AI", layout="wide")
7
 
8
- # 2. Custom Styling (Forced Black Text)
9
  st.markdown("""
10
  <style>
11
  .stApp { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); background-attachment: fixed; }
@@ -24,31 +23,27 @@ st.markdown("""
24
 
25
  st.title("🏋️ Personalised Fitness Plan")
26
 
27
- # --- INPUT SECTION ---
28
- st.markdown("### 1️⃣ User Information")
29
  col1, col2, col3 = st.columns([2, 1, 1])
30
  with col1: name = st.text_input("Name")
31
  with col2: gender = st.selectbox("Gender", ["Male", "Female", "Other"])
32
- with col3: age = st.number_input("Age", min_value=1, value=25)
33
 
34
  col_h, col_w = st.columns(2)
35
- with col_h: height = st.number_input("Height (cm)", min_value=10.0)
36
  with col_w: weight = st.number_input("Weight (kg)", min_value=1.0)
37
 
38
- st.markdown("### 2️⃣ Training Goals")
39
  goal = st.selectbox("Goal", ["Build Muscle", "Weight Loss", "Strength", "Flexibility"])
40
  level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
41
- equip = st.multiselect("Equipment", ["Dumbbells", "Barbell", "Resistance Bands", "Yoga Mat", "No Equipment"])
42
 
43
- # --- GENERATION ---
44
- if st.button("Generate My Professional Plan"):
45
  if not name or height <= 0 or weight <= 0:
46
  st.error("Please fill in all details.")
47
  else:
48
- # Build the prompt using your external file
49
  prompt, bmi, bmi_status, status_color = build_prompt(name, gender, height, weight, goal, level, equip)
50
 
51
- # Show Assessment
52
  st.markdown(f"""
53
  <div class="result-card">
54
  <h2>Assessment for {name}</h2>
@@ -56,26 +51,18 @@ if st.button("Generate My Professional Plan"):
56
  </div>
57
  """, unsafe_allow_html=True)
58
 
59
- with st.spinner("AI Trainer is calculating your routine..."):
60
- # Call your model_api.py function
61
  raw_workout = query_model(prompt)
62
 
63
  if "Error" in raw_workout:
64
  st.error(raw_workout)
65
  else:
66
  st.markdown("### 📋 Your 5-Day Routine")
67
-
68
- # Visual Parsing logic
69
  days = ["Day 1:", "Day 2:", "Day 3:", "Day 4:", "Day 5:"]
70
 
71
  for i in range(len(days)):
72
  start = raw_workout.find(days[i])
73
  if start != -1:
74
- # Logic to find the end of the day's text
75
  end = raw_workout.find(days[i+1]) if i+1 < len(days) else len(raw_workout)
76
  day_content = raw_workout[start:end].strip()
77
-
78
- # Render in Black Text Card
79
- st.markdown(f'<div class="day-card">{day_content}</div>', unsafe_allow_html=True)
80
-
81
- st.info("Note: Consult a doctor before starting any new exercise program.")
 
1
  import streamlit as st
2
  from prompt_builder import build_prompt
3
+ from model_api import query_model
4
 
 
5
  st.set_page_config(page_title="FitPlan AI", layout="wide")
6
 
7
+ # Styling for visibility
8
  st.markdown("""
9
  <style>
10
  .stApp { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); background-attachment: fixed; }
 
23
 
24
  st.title("🏋️ Personalised Fitness Plan")
25
 
26
+ # Input Section
 
27
  col1, col2, col3 = st.columns([2, 1, 1])
28
  with col1: name = st.text_input("Name")
29
  with col2: gender = st.selectbox("Gender", ["Male", "Female", "Other"])
30
+ with col3: age = st.number_input("Age", min_value=1, value=19)
31
 
32
  col_h, col_w = st.columns(2)
33
+ with col_h: height = st.number_input("Height (cm)", min_value=1.0)
34
  with col_w: weight = st.number_input("Weight (kg)", min_value=1.0)
35
 
 
36
  goal = st.selectbox("Goal", ["Build Muscle", "Weight Loss", "Strength", "Flexibility"])
37
  level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
38
+ equip = st.multiselect("Equipment", ["Dumbbells", "Kettlebells", "Pull-up Bar", "Resistance Bands", "Yoga Mat", "No Equipment"])
39
 
40
+ if st.button("Submit Profile"):
 
41
  if not name or height <= 0 or weight <= 0:
42
  st.error("Please fill in all details.")
43
  else:
44
+ # Line 75 Fix: Matches the 4 values returned by prompt_builder
45
  prompt, bmi, bmi_status, status_color = build_prompt(name, gender, height, weight, goal, level, equip)
46
 
 
47
  st.markdown(f"""
48
  <div class="result-card">
49
  <h2>Assessment for {name}</h2>
 
51
  </div>
52
  """, unsafe_allow_html=True)
53
 
54
+ with st.spinner("AI Trainer is thinking..."):
 
55
  raw_workout = query_model(prompt)
56
 
57
  if "Error" in raw_workout:
58
  st.error(raw_workout)
59
  else:
60
  st.markdown("### 📋 Your 5-Day Routine")
 
 
61
  days = ["Day 1:", "Day 2:", "Day 3:", "Day 4:", "Day 5:"]
62
 
63
  for i in range(len(days)):
64
  start = raw_workout.find(days[i])
65
  if start != -1:
 
66
  end = raw_workout.find(days[i+1]) if i+1 < len(days) else len(raw_workout)
67
  day_content = raw_workout[start:end].strip()
68
+ st.markdown(f'<div class="day-card">{day_content}</div>', unsafe_allow_html=True)