AICopyCC commited on
Commit
9adda79
·
verified ·
1 Parent(s): eee8f57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -24
app.py CHANGED
@@ -8,10 +8,7 @@ openai.api_key = os.environ["YOUR_OPENAI_API_KEY"]
8
 
9
  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 +18,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."
29
  })
30
  response = call_openai_api(messages)
31
  ChatGPT_reply = response["choices"][0]["message"]["content"]
@@ -34,36 +31,37 @@ def CustomChatGPT(additional_details, amenities_proximity, amenities, messages):
34
 
35
  # Streamlit Interface
36
  st.set_page_config(layout="wide") # Set the layout to wide
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(2)
42
 
43
  with col1:
44
  st.subheader("Your Preferences")
45
- amenities_list = ["Good Schools", "Parks", "Shopping Centers", "Public Transport", "Restaurants", "Gyms", "Cafes", "Pet-friendly Areas", "Cultural Attractions", "Quiet Neighborhoods"]
46
- # Splitting amenities into two columns
47
- half = len(amenities_list) // 2
48
- amenities_col1, amenities_col2 = st.columns(2)
49
- with amenities_col1:
50
- amenities1 = [amenity for amenity in amenities_list[:half] if st.checkbox(amenity)]
51
- with amenities_col2:
52
- amenities2 = [amenity for amenity in amenities_list[half:] if st.checkbox(amenity)]
53
- amenities = amenities1 + amenities2
54
 
55
- amenities_proximity = st.selectbox("Proximity to Amenities", ["Walking distance", "A short drive away", "I don't mind being far from amenities"])
56
- additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
 
57
 
58
- submit_button = st.button('Find Neighborhood')
59
 
60
  with col2:
61
  # Placeholder for the result
62
- st.subheader("Recommended Neighborhoods")
63
  result_placeholder = st.empty()
64
  if submit_button:
65
  messages = initial_messages.copy()
66
- reply, _ = CustomChatGPT(additional_details, amenities_proximity, amenities, messages)
67
- result_placeholder.write(reply)
68
  else:
69
  result_placeholder.write("**Results will appear here after you submit your preferences**")
 
8
 
9
  initial_messages = [{
10
  "role": "system",
11
+ "content": """You are an AI assistant that suggests weekend activities in Chelmsford, Essex, and surrounding areas up to 10 miles away. You'll receive information about the user's preferences for the weekend. Use this information to suggest activities in the area. Always add the following text to the end of every response you give: 'Enjoy your weekend!' """
 
 
 
12
  }]
13
 
14
  @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))
 
18
  messages=messages
19
  )
20
 
21
+ def CustomChatGPT(activities, location_proximity, location_type, group_type, messages):
22
+ selected_activities = ', '.join(activities)
23
  messages.append({
24
  "role": "user",
25
+ "content": f"I'm looking for weekend activities in Chelmsford, Essex, and surrounding areas up to 10 miles away. I'm interested in {selected_activities}. I prefer to do activities {location_proximity} and in {location_type}. My group type is {group_type}."
26
  })
27
  response = call_openai_api(messages)
28
  ChatGPT_reply = response["choices"][0]["message"]["content"]
 
31
 
32
  # Streamlit Interface
33
  st.set_page_config(layout="wide") # Set the layout to wide
34
+ st.title("Weekend Activity Matchmaker")
35
+ st.write("This tool suggests weekend activities in Chelmsford, Essex, and surrounding areas based on your preferences.")
36
 
37
  # Using columns to organize the layout
38
  col1, col2 = st.columns(2)
39
 
40
  with col1:
41
  st.subheader("Your Preferences")
42
+ activities_list = ["Outdoor activities", "Indoor activities", "Free activities", "On a budget", "Restaurants", "Live music", "Museums", "Sports", "Games", "Animals", "Shopping", "Parks", "Cultural attractions", "Spas", "Swimming pools"]
43
+ # Splitting activities into two columns
44
+ half = len(activities_list) // 2
45
+ activities_col1, activities_col2 = st.columns(2)
46
+ with activities_col1:
47
+ activities1 = [activity for activity in activities_list[:half] if st.checkbox(activity)]
48
+ with activities_col2:
49
+ activities2 = [activity for activity in activities_list[half:] if st.checkbox(activity)]
50
+ activities = activities1 + activities2
51
 
52
+ location_proximity = st.selectbox("Proximity to Activities", ["Nearby", "A short drive away", "I don't mind travelling"])
53
+ location_type = st.selectbox("Location Type", ["City centre", "Out of town", "Any"])
54
+ group_type = st.selectbox("Group Type", ["Individual", "Small group", "Family", "Pet-friendly", "Accessible"])
55
 
56
+ submit_button = st.button('Find Activities')
57
 
58
  with col2:
59
  # Placeholder for the result
60
+ st.subheader("Recommended Activities")
61
  result_placeholder = st.empty()
62
  if submit_button:
63
  messages = initial_messages.copy()
64
+ reply, _ = CustomChatGPT(activities, location_proximity, location_type, group_type, messages)
65
+ result_placeholder.write(reply + "\nEnjoy your weekend!")
66
  else:
67
  result_placeholder.write("**Results will appear here after you submit your preferences**")