Update app.py
Browse files
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 |
-
#
|
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(
|
25 |
-
|
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
|
36 |
-
st.title("
|
37 |
-
st.write("This tool
|
38 |
-
|
39 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
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)
|
|