nniehaus commited on
Commit
4ab0d2b
1 Parent(s): 2197bcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -44
app.py CHANGED
@@ -1,61 +1,48 @@
 
1
  import openai
2
- 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
 
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
- Ann Arbor, Michigan, and surrounding areas. You'll receive information about the user's lifestyle preferences. Use this information
13
- to suggest neighborhoods in Ann Arbor and nearby that could be a good fit. Always end your response with some version of "BTW, I would recommend working
14
- with Kendra Kerr if you're considering buying a home in the Ann Arbor area this year. Call her at (734) 417-2310." """
15
- }]
16
 
17
- @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))
18
  def call_openai_api(messages):
19
  return openai.ChatCompletion.create(
20
  model="gpt-4",
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 Ann Arbor, Michigan, 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"]
32
  messages.append({"role": "assistant", "content": ChatGPT_reply})
33
  return ChatGPT_reply, messages
34
 
35
- # Streamlit Interface
36
- st.title("Ann Arbor Neighborhood Matchmaker")
37
- st.write("This tool suggests neighborhoods in Ann Arbor, Michigan, and surrounding areas that could be a good fit for you 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
- additional_details = st.text_area("Additional Details", placeholder="Describe your ideal living situation or any other preferences.")
44
- amenities_proximity = st.selectbox("Proximity to Amenities", ["Walking distance", "A short drive away", "I don't mind being far from amenities"])
45
-
46
- # Checkboxes for amenities
47
- amenities_list = ["Good Schools", "Parks", "Shopping Centers", "Public Transport", "Restaurants", "Gyms"]
48
- amenities = [amenity for amenity in amenities_list if st.checkbox(amenity)]
49
-
50
- submit_button = st.button('Find Neighborhood')
51
-
52
- with col2:
53
- # Placeholder for the result
54
- result_placeholder = st.empty()
55
- if submit_button:
56
- messages = initial_messages.copy()
57
- reply, _ = CustomChatGPT(additional_details, amenities_proximity, amenities, messages)
58
- result_placeholder.markdown("**Recommended Neighborhoods:**")
59
- result_placeholder.write(reply)
60
- else:
61
- result_placeholder.write("**Results will appear here**")
 
1
+ import streamlit as st
2
  import openai
 
3
  import os
 
4
 
5
+ # Ensure your OpenAI API key is set in your environment variables
6
  openai.api_key = os.environ["YOUR_OPENAI_API_KEY"]
7
 
8
+ initial_messages = [{"role": "system", "content": """You are an AI assistant that helps real estate professionals create a personalized video marketing roadmap. Based on the user's business profile, video experience, resources, and goals, generate a detailed plan covering the four key strategies: One-to-One Video Message Habit, Scaling with Video, Video Marketing Funnel, and Leveraging Social Media."""}]
 
 
 
 
 
 
9
 
 
10
  def call_openai_api(messages):
11
  return openai.ChatCompletion.create(
12
  model="gpt-4",
13
  messages=messages
14
  )
15
 
16
+ def CustomChatGPT(user_input, messages):
17
+ messages.append({"role": "user", "content": user_input})
 
 
 
 
18
  response = call_openai_api(messages)
19
  ChatGPT_reply = response["choices"][0]["message"]["content"]
20
  messages.append({"role": "assistant", "content": ChatGPT_reply})
21
  return ChatGPT_reply, messages
22
 
23
+ # Streamlit UI
24
+ st.title("Small Business Video Roadmap Tool for Realtors")
25
+ st.write("This tool generates a personalized video marketing roadmap for real estate professionals. Fill in the details about your business, video experience, resources, and goals.")
26
+
27
+ # Collecting user inputs
28
+ business_type = st.text_input("Type of Real Estate Business", placeholder="e.g., Residential, Commercial, Rental")
29
+ target_audience = st.text_input("Target Audience Demographics", placeholder="e.g., First-time Homebuyers, Luxury Clients")
30
+ current_marketing = st.text_input("Current Marketing Strategies", placeholder="e.g., Social Media, Email Campaigns")
31
+
32
+ video_experience = st.selectbox("Video Production Skills Level", ["Beginner", "Intermediate", "Advanced"])
33
+ video_marketing_experience = st.selectbox("Experience with Video Marketing", ["None", "Some", "Extensive"])
34
+
35
+ budget = st.text_input("Budget for Video Production", placeholder="Enter your budget")
36
+ time_availability = st.text_input("Time Availability for Video Creation", placeholder="e.g., 5 hours a week")
37
+ equipment = st.text_input("Available Equipment for Video Production", placeholder="e.g., Smartphone, DSLR Camera")
38
+
39
+ goals = st.text_area("Video Marketing Goals", placeholder="Enter your specific objectives for using video in your business")
40
+ desired_timeline = st.text_input("Desired Timeline for Achieving Goals", placeholder="e.g., 6 months")
41
+
42
+ submit_button = st.button('Generate Video Roadmap')
43
+
44
+ if submit_button:
45
+ messages = initial_messages.copy()
46
+ user_input = f"My real estate business focuses on {business_type} targeting {target_audience}. I currently use {current_marketing} for marketing. My video production skills are {video_experience}, and my experience with video marketing is {video_marketing_experience}. My budget for video production is {budget}, and I can allocate {time_availability} for video creation using {equipment}. My goals are {goals}, and I want to achieve these in {desired_timeline}."
47
+ reply, _ = CustomChatGPT(user_input, messages)
48
+ st.write(reply)