Update app.py
Browse files
app.py
CHANGED
@@ -1,65 +1,44 @@
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
-
import
|
4 |
|
5 |
# Ensure your OpenAI API key is set in your environment variables
|
6 |
-
openai.api_key =
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
"
|
11 |
-
|
12 |
-
|
13 |
-
- Suggested Title
|
14 |
-
- Video Outline (main points or segments)
|
15 |
-
- Hook/Opening Line
|
16 |
-
- Recommended Call to Action
|
17 |
-
"""
|
18 |
-
}]
|
19 |
-
|
20 |
-
def call_openai_api(messages):
|
21 |
-
return openai.ChatCompletion.create(
|
22 |
model="gpt-3.5-turbo",
|
23 |
-
|
|
|
24 |
)
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
st.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
if
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Your YouTube Video Plan ⬇️</h2>", unsafe_allow_html=True)
|
54 |
-
st.write(reply)
|
55 |
-
|
56 |
-
# Contact capture form
|
57 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Get in Touch for More Help ⬇️</h2>", unsafe_allow_html=True)
|
58 |
-
with st.form(key='contact_form'):
|
59 |
-
name = st.text_input("Your Name", placeholder="Enter your name")
|
60 |
-
email = st.text_input("Your Email", placeholder="Enter your email address")
|
61 |
-
message = st.text_area("Your Message", placeholder="Let us know how we can assist you further")
|
62 |
-
submit_button = st.form_submit_button(label='Submit')
|
63 |
-
|
64 |
-
if submit_button:
|
65 |
-
st.success("Thank you for getting in touch! We'll get back to you shortly.")
|
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
+
import urllib.parse
|
4 |
|
5 |
# Ensure your OpenAI API key is set in your environment variables
|
6 |
+
openai.api_key = 'your_openai_api_key'
|
7 |
|
8 |
+
# Function to get neighborhood suggestions from OpenAI
|
9 |
+
def suggest_neighborhoods(user_preferences, city=""):
|
10 |
+
prompt = (f"Based on the following preferences, suggest neighborhoods in {city}: {user_preferences}. "
|
11 |
+
"For each neighborhood, provide a brief description including its main attractions and why it would suit these preferences.")
|
12 |
+
response = openai.Completion.create(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
model="gpt-3.5-turbo",
|
14 |
+
prompt=prompt,
|
15 |
+
max_tokens=150
|
16 |
)
|
17 |
+
return response.choices[0].text.strip()
|
18 |
+
|
19 |
+
# Function to generate Zillow search link for a neighborhood
|
20 |
+
def generate_zillow_link(neighborhood):
|
21 |
+
neighborhood_query = urllib.parse.quote(neighborhood)
|
22 |
+
return f"https://www.zillow.com/homes/{neighborhood_query}_rb/"
|
23 |
+
|
24 |
+
# Streamlit Interface
|
25 |
+
st.title("Ideal Neighborhood Finder")
|
26 |
+
st.write("Describe what you're looking for in an ideal neighborhood, and we'll suggest neighborhoods with Zillow links for homes in those areas.")
|
27 |
+
|
28 |
+
# User Inputs
|
29 |
+
city = st.text_input("City", placeholder="Enter the city you want to search in")
|
30 |
+
user_preferences = st.text_area("Describe Your Ideal Neighborhood", placeholder="E.g., close to schools, parks, public transit, vibrant nightlife, etc.")
|
31 |
+
|
32 |
+
if st.button("Find Neighborhoods"):
|
33 |
+
if city and user_preferences:
|
34 |
+
# Get neighborhood suggestions from OpenAI
|
35 |
+
neighborhoods = suggest_neighborhoods(user_preferences, city)
|
36 |
+
|
37 |
+
# Display results
|
38 |
+
st.subheader("Neighborhood Suggestions")
|
39 |
+
for neighborhood in neighborhoods.splitlines():
|
40 |
+
if neighborhood: # Filter out empty lines
|
41 |
+
zillow_link = generate_zillow_link(neighborhood)
|
42 |
+
st.markdown(f"- **{neighborhood}**: [View homes on Zillow]({zillow_link})")
|
43 |
+
else:
|
44 |
+
st.error("Please provide both a city and a description of your ideal neighborhood.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|