nniehaus commited on
Commit
f9ec6e7
·
verified ·
1 Parent(s): cca4fc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
app.py CHANGED
@@ -4,27 +4,28 @@ import openai
4
  # Access the OpenAI API key from environment variables or secrets
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
- st.title("Personalized 6-Month Fitness and Health Plan Generator")
8
 
9
  # User inputs
10
  st.subheader("About You")
11
- age = st.number_input("Your Age", min_value=12, max_value=100, step=1)
12
- gender = st.selectbox("Your Gender", ["Female", "Male", "Prefer not to say"])
13
 
14
- st.subheader("Current Fitness and Health Status")
15
- current_fitness_level = st.selectbox("Your Current Fitness Level", ["Beginner", "Intermediate", "Advanced"])
16
- current_health_issues = st.text_area("Current Health Issues", placeholder="Any known health issues or concerns")
17
- dietary_preferences = st.text_area("Dietary Preferences", placeholder="e.g., Vegan, Gluten-free, Keto, No preferences")
18
 
19
- st.subheader("Your Fitness Goals")
20
- fitness_goals = st.multiselect("Select Your Fitness Goals", ["Weight loss", "Muscle gain", "Endurance improvement", "Flexibility", "General well-being"])
21
- goal_timeframe = st.selectbox("Goal Timeframe", ["3 months", "6 months", "1 year"])
22
 
23
- if st.button('Generate My Fitness Plan'):
24
  # Construct the prompt for the AI
25
  prompt_text = (
26
- f"Create a personalized 6-month fitness and health plan for the user, a {age}-year-old {gender} with {current_fitness_level} fitness level. "
27
- f"Health issues: {current_health_issues}. Dietary preferences: {dietary_preferences}. Fitness goals: {', '.join(fitness_goals)} over {goal_timeframe}."
 
28
  )
29
 
30
  # Call the OpenAI API for text generation
@@ -32,17 +33,17 @@ if st.button('Generate My Fitness Plan'):
32
  response_text = openai.ChatCompletion.create(
33
  model="gpt-4",
34
  messages=[
35
- {"role": "system", "content": "You are an AI fitness coach."},
36
  {"role": "user", "content": prompt_text}
37
  ]
38
  )
39
- fitness_plan = response_text.choices[0].message['content']
40
  except Exception as e:
41
- fitness_plan = f"Error in generating fitness plan: {e}"
42
 
43
- # Display the fitness plan
44
- st.markdown("### Your Personalized 6-Month Fitness Plan")
45
- st.write(fitness_plan)
46
 
47
  # Disclaimer
48
- st.write("Disclaimer: This tool provides suggestions based on AI-generated content. Please consult with a healthcare provider or a professional fitness trainer before starting any new fitness program.")
 
4
  # Access the OpenAI API key from environment variables or secrets
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
+ st.title("Find Your Ideal Neighborhood")
8
 
9
  # User inputs
10
  st.subheader("About You")
11
+ age = st.number_input("Your Age", min_value=18, max_value=100, step=1)
12
+ occupation = st.text_input("Your Occupation", placeholder="e.g., Software Developer, Teacher")
13
 
14
+ st.subheader("Lifestyle and Preferences")
15
+ preferred_climate = st.selectbox("Preferred Climate", ["Warm", "Temperate", "Cold"])
16
+ interests = st.text_area("Interests", placeholder="e.g., Outdoor activities, Arts and culture, Nightlife")
17
+ housing_budget = st.number_input("Housing Budget", min_value=500, max_value=10000, step=100, format="$%i")
18
 
19
+ st.subheader("Your Ideal Neighborhood")
20
+ neighborhood_preferences = st.multiselect("Select Your Neighborhood Preferences", ["Safe", "Family-friendly", "Vibrant nightlife", "Quiet", "Pet-friendly", "Close to nature", "Urban"])
21
+ commute_preference = st.selectbox("Preferred Commute Time", ["Less than 15 minutes", "15-30 minutes", "30-60 minutes", "More than an hour"])
22
 
23
+ if st.button('Find My Ideal Neighborhood'):
24
  # Construct the prompt for the AI
25
  prompt_text = (
26
+ f"Find an ideal neighborhood for the user, a {age}-year-old working as {occupation}. "
27
+ f"Preferred climate: {preferred_climate}. Interests: {interests}. Housing budget: {housing_budget}. "
28
+ f"Neighborhood preferences: {', '.join(neighborhood_preferences)} with a preferred commute time of {commute_preference}."
29
  )
30
 
31
  # Call the OpenAI API for text generation
 
33
  response_text = openai.ChatCompletion.create(
34
  model="gpt-4",
35
  messages=[
36
+ {"role": "system", "content": "You are an AI specializing in neighborhood recommendations."},
37
  {"role": "user", "content": prompt_text}
38
  ]
39
  )
40
+ neighborhood_recommendation = response_text.choices[0].message['content']
41
  except Exception as e:
42
+ neighborhood_recommendation = f"Error in finding ideal neighborhood: {e}"
43
 
44
+ # Display the neighborhood recommendation
45
+ st.markdown("### Your Ideal Neighborhood Recommendation")
46
+ st.write(neighborhood_recommendation)
47
 
48
  # Disclaimer
49
+ st.write("Disclaimer: This tool provides suggestions based on AI-generated content. Please ensure to conduct your own research or consult with a real estate professional before making any decisions.")