nniehaus commited on
Commit
bacabac
·
1 Parent(s): 04a8035

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -17
app.py CHANGED
@@ -10,8 +10,8 @@ initial_messages = [{
10
  "role": "system",
11
  "content": """You are an AI assistant that matches people with their ideal neighborhood based on their lifestyle preferences in
12
  Saint Louis, Missouri, and surrounding areas up to 30 miles outside Saint Louis city limits. You'll receive information about the user's lifestyle preferences. Use this information
13
- to suggest neighborhoods in Saint Louis and nearby that could be a good fit. Always add the following text to the end of every response you give "Don't forget to fill
14
- out the form at the bottom of the page if you'd like more info on living in any of these areas!" """
15
  }]
16
 
17
  @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))
@@ -21,11 +21,11 @@ def call_openai_api(messages):
21
  messages=messages
22
  )
23
 
24
- def CustomChatGPT(additional_details, amenities_proximity, amenities, messages):
25
  selected_amenities = ', '.join(amenities)
26
  messages.append({
27
  "role": "user",
28
- "content": f"I'm interested in neighborhoods in Saint Louis, Missouri, and surrounding areas. {additional_details}. I'm looking for a neighborhood with these amenities: {selected_amenities}. I want to be {amenities_proximity} to these amenities. What neighborhoods would be a good fit for me?"
29
  })
30
  response = call_openai_api(messages)
31
  ChatGPT_reply = response["choices"][0]["message"]["content"]
@@ -34,18 +34,25 @@ def CustomChatGPT(additional_details, amenities_proximity, amenities, messages):
34
 
35
  # Streamlit Interface
36
  st.title("St. Louis Area Neighborhood Matchmaker")
37
- st.write("Discover your ideal neighborhood in Saint Louis, Missouri, and its surrounding areas. Tell us about your preferences, and we'll suggest the perfect places for you to call home.")
38
 
39
- # User inputs
40
- additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
41
- amenities_proximity = st.selectbox("Proximity to Amenities", ["Walking distance", "A short drive away", "I don't mind being far from amenities"])
 
 
 
 
 
 
 
 
 
42
 
43
- # Checkboxes for amenities
44
- amenities_list = ["Good Schools", "Parks", "Shopping Centers", "Public Transport", "Restaurants", "Gyms", "Cafes", "Pet-friendly Areas", "Cultural Attractions", "Quiet Neighborhoods"]
45
- amenities = st.multiselect("Select Amenities", amenities_list)
46
-
47
- if st.button('Find Neighborhood'):
48
- messages = initial_messages.copy()
49
- reply, _ = CustomChatGPT(additional_details, amenities_proximity, amenities, messages)
50
- st.markdown("### Recommended Neighborhoods:")
51
- st.write(reply)
 
10
  "role": "system",
11
  "content": """You are an AI assistant that matches people with their ideal neighborhood based on their lifestyle preferences in
12
  Saint Louis, Missouri, and surrounding areas up to 30 miles outside Saint Louis city limits. You'll receive information about the user's lifestyle preferences. Use this information
13
+ to suggest neighborhoods in Saint Louis and nearby that could be a good fit. Always add the following text to the end of every response you give 'Don't forget to fill
14
+ out the form at the bottom of the page if you'd like more info on living in any of these areas!' """
15
  }]
16
 
17
  @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))
 
21
  messages=messages
22
  )
23
 
24
+ def CustomChatGPT(additional_details, amenities, messages):
25
  selected_amenities = ', '.join(amenities)
26
  messages.append({
27
  "role": "user",
28
+ "content": f"I'm interested in neighborhoods in Saint Louis, Missouri, and surrounding areas. {additional_details}. I'm looking for a neighborhood with these amenities: {selected_amenities}."
29
  })
30
  response = call_openai_api(messages)
31
  ChatGPT_reply = response["choices"][0]["message"]["content"]
 
34
 
35
  # Streamlit Interface
36
  st.title("St. Louis Area Neighborhood Matchmaker")
37
+ st.write("Discover neighborhoods in Saint Louis, Missouri, and its surrounding areas that align with your lifestyle preferences.")
38
 
39
+ # Using columns to organize the layout
40
+ col1, col2 = st.columns([3, 2])
41
+
42
+ with col1:
43
+ # Placeholder for the result
44
+ result_placeholder = st.empty()
45
+ result_placeholder.write("**Your Recommended Neighborhoods will appear here**")
46
+
47
+ with col2:
48
+ # Checkboxes for amenities
49
+ amenities_list = ["Good Schools", "Parks", "Shopping Centers", "Public Transport", "Restaurants", "Gyms", "Cafes", "Pet-friendly Areas", "Cultural Attractions", "Quiet Neighborhoods"]
50
+ amenities = st.multiselect("Select Amenities", amenities_list)
51
 
52
+ additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
53
+
54
+ if st.button('Find Neighborhood'):
55
+ messages = initial_messages.copy()
56
+ reply, _ = CustomChatGPT(additional_details, amenities, messages)
57
+ result_placeholder.markdown("### Recommended Neighborhoods:")
58
+ result_placeholder.write(reply)