nniehaus commited on
Commit
53542d0
·
1 Parent(s): 8b0495f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -40
app.py CHANGED
@@ -3,13 +3,6 @@ import streamlit as st
3
  import os
4
  from tenacity import retry, stop_after_attempt, wait_fixed
5
 
6
- # Set the OpenAI API key
7
- openai.api_key = os.environ["YOUR_OPENAI_API_KEY"]
8
- import openai
9
- import streamlit as st
10
- import os
11
- from tenacity import retry, stop_after_attempt, wait_fixed
12
-
13
  # Set the OpenAI API key
14
  openai.api_key = os.environ["YOUR_OPENAI_API_KEY"]
15
 
@@ -44,40 +37,26 @@ st.set_page_config(layout="wide") # Set the layout to wide
44
  st.title("St. Louis Area Neighborhood Matchmaker")
45
  st.write("This tool helps you find neighborhoods in Saint Louis, Missouri, and surrounding areas based on your lifestyle preferences.")
46
 
47
- # Checkboxes for amenities
48
- amenities_list = ["Good Schools", "Parks", "Shopping Centers", "Public Transport", "Restaurants", "Gyms", "Cafes", "Pet-friendly Areas", "Cultural Attractions", "Quiet Neighborhoods"]
49
- amenities = []
50
 
51
- # Organize checkboxes into columns
52
- col1, col2, col3, col4, col5 = st.columns(5)
53
  with col1:
54
- for amenity in amenities_list[:2]:
55
- if st.checkbox(amenity, key=amenity):
56
- amenities.append(amenity)
57
- with col2:
58
- for amenity in amenities_list[2:4]:
59
- if st.checkbox(amenity, key=amenity):
60
- amenities.append(amenity)
61
- with col3:
62
- for amenity in amenities_list[4:6]:
63
- if st.checkbox(amenity, key=amenity):
64
- amenities.append(amenity)
65
- with col4:
66
- for amenity in amenities_list[6:8]:
67
- if st.checkbox(amenity, key=amenity):
68
- amenities.append(amenity)
69
- with col5:
70
- for amenity in amenities_list[8:]:
71
- if st.checkbox(amenity, key=amenity):
72
- amenities.append(amenity)
73
 
74
- amenities_proximity = st.selectbox("Proximity to Amenities", ["Walking distance", "A short drive away", "I don't mind being far from amenities"])
75
- additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
 
 
76
 
77
- submit_button = st.button('Find Neighborhood')
78
-
79
- if submit_button:
80
- messages = initial_messages.copy()
81
- reply, _ = CustomChatGPT(additional_details, amenities_proximity, amenities, messages)
82
- st.markdown("**Recommended Neighborhoods:**")
83
- st.write(reply)
 
 
 
 
3
  import os
4
  from tenacity import retry, stop_after_attempt, wait_fixed
5
 
 
 
 
 
 
 
 
6
  # Set the OpenAI API key
7
  openai.api_key = os.environ["YOUR_OPENAI_API_KEY"]
8
 
 
37
  st.title("St. Louis Area Neighborhood Matchmaker")
38
  st.write("This tool helps you find neighborhoods in Saint Louis, Missouri, and surrounding areas based on your lifestyle preferences.")
39
 
40
+ # Using columns to organize the layout
41
+ col1, col2 = st.columns([1, 2])
 
42
 
 
 
43
  with col1:
44
+ # Checkboxes for amenities
45
+ amenities_list = ["Good Schools", "Parks", "Shopping Centers", "Public Transport", "Restaurants", "Gyms", "Cafes", "Pet-friendly Areas", "Cultural Attractions", "Quiet Neighborhoods"]
46
+ amenities = [amenity for amenity in amenities_list if st.checkbox(amenity)]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
+ amenities_proximity = st.selectbox("Proximity to Amenities", ["Walking distance", "A short drive away", "I don't mind being far from amenities"])
49
+ additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
50
+
51
+ submit_button = st.button('Find Neighborhood')
52
 
53
+ with col2:
54
+ # Placeholder for the result
55
+ result_placeholder = st.empty()
56
+ if submit_button:
57
+ messages = initial_messages.copy()
58
+ reply, _ = CustomChatGPT(additional_details, amenities_proximity, amenities, messages)
59
+ result_placeholder.markdown("**Recommended Neighborhoods:**")
60
+ result_placeholder.write(reply)
61
+ else:
62
+ result_placeholder.write("**Results will appear here**")