Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,13 @@ 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 |
|
|
@@ -33,29 +40,44 @@ def CustomChatGPT(additional_details, amenities_proximity, amenities, messages):
|
|
| 33 |
return ChatGPT_reply, messages
|
| 34 |
|
| 35 |
# Streamlit Interface
|
|
|
|
| 36 |
st.title("St. Louis Area Neighborhood Matchmaker")
|
| 37 |
st.write("This tool helps you find neighborhoods in Saint Louis, Missouri, and surrounding areas based on your lifestyle preferences.")
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
|
|
|
|
| 41 |
|
|
|
|
|
|
|
| 42 |
with col1:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
if submit_button:
|
| 58 |
-
messages = initial_messages.copy()
|
| 59 |
-
reply, _ = CustomChatGPT(additional_details, amenities_proximity, amenities, messages)
|
| 60 |
-
result_placeholder.markdown("**Recommended Neighborhoods:**")
|
| 61 |
-
result_placeholder.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 |
+
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 |
|
|
|
|
| 40 |
return ChatGPT_reply, messages
|
| 41 |
|
| 42 |
# Streamlit Interface
|
| 43 |
+
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|