Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,11 +21,11 @@ def call_openai_api(messages):
|
|
| 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,25 +34,28 @@ def CustomChatGPT(additional_details, amenities, messages):
|
|
| 34 |
|
| 35 |
# Streamlit Interface
|
| 36 |
st.title("St. Louis Area Neighborhood Matchmaker")
|
| 37 |
-
st.write("
|
| 38 |
|
| 39 |
# Using columns to organize the layout
|
| 40 |
-
col1, col2 = st.columns([
|
| 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 =
|
| 51 |
-
|
|
|
|
| 52 |
additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
messages = initial_messages.copy()
|
| 56 |
-
reply, _ = CustomChatGPT(additional_details, amenities, messages)
|
| 57 |
-
result_placeholder.markdown("
|
| 58 |
result_placeholder.write(reply)
|
|
|
|
| 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."
|
| 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("This tool helps you find neighborhoods in Saint Louis, Missouri, and surrounding areas based on your lifestyle preferences.")
|
| 38 |
|
| 39 |
# Using columns to organize the layout
|
| 40 |
+
col1, col2 = st.columns([2, 3])
|
| 41 |
|
| 42 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = [amenity for amenity in amenities_list if st.checkbox(amenity)]
|
| 46 |
+
|
| 47 |
+
amenities_proximity = st.selectbox("Proximity to Amenities", ["Walking distance", "A short drive away", "I don't mind being far from amenities"])
|
| 48 |
additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
|
| 49 |
|
| 50 |
+
submit_button = st.button('Find Neighborhood')
|
| 51 |
+
|
| 52 |
+
with col2:
|
| 53 |
+
# Placeholder for the result
|
| 54 |
+
result_placeholder = st.empty()
|
| 55 |
+
result_placeholder.write("**Your Recommended Neighborhoods will appear here**")
|
| 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)
|