Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
import os
|
4 |
-
import folium
|
5 |
-
from streamlit_folium import st_folium
|
6 |
-
import urllib.parse
|
7 |
-
import subprocess
|
8 |
|
9 |
# Ensure your OpenAI API key is set in your environment variables
|
10 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
11 |
|
12 |
-
# Ensure folium is installed
|
13 |
-
try:
|
14 |
-
import folium
|
15 |
-
except ModuleNotFoundError:
|
16 |
-
subprocess.check_call(["python", "-m", "pip", "install", "folium"])
|
17 |
-
import folium
|
18 |
-
|
19 |
initial_messages = [{
|
20 |
"role": "system",
|
21 |
"content": """
|
22 |
-
You are
|
|
|
|
|
|
|
|
|
|
|
23 |
"""
|
24 |
}]
|
25 |
|
@@ -29,72 +23,38 @@ def call_openai_api(messages):
|
|
29 |
messages=messages
|
30 |
)
|
31 |
|
32 |
-
def CustomChatGPT(
|
33 |
-
query = f"User
|
34 |
messages.append({"role": "user", "content": query})
|
35 |
response = call_openai_api(messages)
|
36 |
-
ChatGPT_reply = response[
|
37 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
38 |
return ChatGPT_reply, messages
|
39 |
|
40 |
# Set layout to wide
|
41 |
st.set_page_config(layout="wide")
|
42 |
|
43 |
-
# Initialize session state for storing the results
|
44 |
-
if "reply" not in st.session_state:
|
45 |
-
st.session_state.reply = ""
|
46 |
-
|
47 |
# Centered title
|
48 |
-
st.markdown("<h1 style='text-align: center; color: black;'>
|
49 |
|
50 |
# Create columns for input and output
|
51 |
col1, col2 = st.columns(2)
|
52 |
|
53 |
with col1:
|
54 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Your
|
55 |
-
|
56 |
-
generate_button = st.button('
|
57 |
|
58 |
if generate_button:
|
59 |
messages = initial_messages.copy()
|
60 |
-
reply, _ = CustomChatGPT(
|
61 |
-
st.session_state.reply = reply # Store the reply in session state
|
62 |
|
63 |
-
if st.session_state.reply:
|
64 |
with col2:
|
65 |
-
st.markdown("<h2 style='text-align: center; color: black;'>
|
66 |
-
st.write(
|
67 |
-
|
68 |
-
# Add map integration
|
69 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Map of Suggested Neighborhoods ⬇️</h2>", unsafe_allow_html=True)
|
70 |
-
map_center = [37.7749, -122.4194] # Default to San Francisco coordinates
|
71 |
-
m = folium.Map(location=map_center, zoom_start=12)
|
72 |
-
|
73 |
-
# Placeholder coordinates for neighborhoods (these should be updated with actual data)
|
74 |
-
neighborhoods = [
|
75 |
-
{"name": "Neighborhood 1", "coordinates": [37.7749, -122.4194]},
|
76 |
-
{"name": "Neighborhood 2", "coordinates": [37.7849, -122.4094]},
|
77 |
-
{"name": "Neighborhood 3", "coordinates": [37.7649, -122.4294]}
|
78 |
-
]
|
79 |
-
|
80 |
-
for neighborhood in neighborhoods:
|
81 |
-
folium.Marker(
|
82 |
-
location=neighborhood["coordinates"],
|
83 |
-
popup=neighborhood["name"],
|
84 |
-
icon=folium.Icon(color='blue')
|
85 |
-
).add_to(m)
|
86 |
-
|
87 |
-
st_folium(m, width=700, height=500)
|
88 |
-
|
89 |
-
# Add Zillow search links for neighborhoods
|
90 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Search for Homes in Suggested Neighborhoods ⬇️</h2>", unsafe_allow_html=True)
|
91 |
-
for neighborhood in neighborhoods:
|
92 |
-
query = urllib.parse.quote(neighborhood["name"])
|
93 |
-
zillow_url = f"https://www.zillow.com/homes/{query}_rb/"
|
94 |
-
st.markdown(f"[Search for homes in {neighborhood['name']} on Zillow]({zillow_url})")
|
95 |
|
96 |
# Contact capture form
|
97 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Get in Touch for More
|
98 |
with st.form(key='contact_form'):
|
99 |
name = st.text_input("Your Name", placeholder="Enter your name")
|
100 |
email = st.text_input("Your Email", placeholder="Enter your email address")
|
|
|
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["OPENAI_API_KEY"]
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
initial_messages = [{
|
9 |
"role": "system",
|
10 |
"content": """
|
11 |
+
You are an assistant that helps people plan their first YouTube video. Your suggestions should be geared toward creating engaging content that matches the user's expertise, personality, and interests. Provide a structured plan including:
|
12 |
+
- Video Topic
|
13 |
+
- Suggested Title
|
14 |
+
- Video Outline (main points or segments)
|
15 |
+
- Hook/Opening Line
|
16 |
+
- Recommended Call to Action
|
17 |
"""
|
18 |
}]
|
19 |
|
|
|
23 |
messages=messages
|
24 |
)
|
25 |
|
26 |
+
def CustomChatGPT(user_input, messages):
|
27 |
+
query = f"User's expertise and interests: {user_input}. Suggest a structured plan for their first YouTube video."
|
28 |
messages.append({"role": "user", "content": query})
|
29 |
response = call_openai_api(messages)
|
30 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
31 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
32 |
return ChatGPT_reply, messages
|
33 |
|
34 |
# Set layout to wide
|
35 |
st.set_page_config(layout="wide")
|
36 |
|
|
|
|
|
|
|
|
|
37 |
# Centered title
|
38 |
+
st.markdown("<h1 style='text-align: center; color: black;'>YouTube Video Planner</h1>", unsafe_allow_html=True)
|
39 |
|
40 |
# Create columns for input and output
|
41 |
col1, col2 = st.columns(2)
|
42 |
|
43 |
with col1:
|
44 |
+
st.markdown("<h2 style='text-align: center; color: black;'>Your Expertise & Interests</h2>", unsafe_allow_html=True)
|
45 |
+
user_input = st.text_area("Describe your expertise and interests", placeholder="E.g., cooking, fitness, real estate, technology, travel, etc.")
|
46 |
+
generate_button = st.button('Generate Video Plan')
|
47 |
|
48 |
if generate_button:
|
49 |
messages = initial_messages.copy()
|
50 |
+
reply, _ = CustomChatGPT(user_input, messages)
|
|
|
51 |
|
|
|
52 |
with col2:
|
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")
|