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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -22
app.py CHANGED
@@ -4,28 +4,25 @@ 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("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,17 +30,17 @@ if st.button('Find My Ideal Neighborhood'):
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.")
 
4
  # Access the OpenAI API key from environment variables or secrets
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
+ st.title("Plan Your Investment Strategy")
8
 
9
  # User inputs
10
+ st.subheader("Investment Profile")
11
  age = st.number_input("Your Age", min_value=18, max_value=100, step=1)
12
+ investment_experience = st.selectbox("Your Investment Experience", ["Beginner", "Intermediate", "Advanced"])
13
+ investment_goal = st.text_input("Investment Goal", placeholder="e.g., Retirement, Buying a Home, Education")
14
 
15
+ st.subheader("Financial Information")
16
+ annual_income = st.number_input("Annual Income", min_value=10000, max_value=1000000, step=1000, format="$%i")
17
+ investment_amount = st.number_input("Amount Available for Investment", min_value=1000, max_value=500000, step=100, format="$%i")
18
+ risk_tolerance = st.selectbox("Risk Tolerance", ["Low", "Medium", "High"])
19
 
20
+ if st.button('Generate My Investment Strategy'):
 
 
 
 
21
  # Construct the prompt for the AI
22
  prompt_text = (
23
+ f"Generate an investment strategy for a {age}-year-old with {investment_experience} experience. "
24
+ f"Investment goal: {investment_goal}. Annual income: {annual_income}. "
25
+ f"Amount available for investment: {investment_amount}. Risk tolerance: {risk_tolerance}."
26
  )
27
 
28
  # Call the OpenAI API for text generation
 
30
  response_text = openai.ChatCompletion.create(
31
  model="gpt-4",
32
  messages=[
33
+ {"role": "system", "content": "You are an AI specializing in personalized investment strategies."},
34
  {"role": "user", "content": prompt_text}
35
  ]
36
  )
37
+ investment_strategy = response_text.choices[0].message['content']
38
  except Exception as e:
39
+ investment_strategy = f"Error in generating investment strategy: {e}"
40
 
41
+ # Display the investment strategy
42
+ st.markdown("### Your Personalized Investment Strategy")
43
+ st.write(investment_strategy)
44
 
45
  # Disclaimer
46
+ st.write("Disclaimer: This tool provides suggestions based on AI-generated content. Please ensure to conduct your own research or consult with a financial advisor before making any investment decisions.")