Update app.py
Browse files
app.py
CHANGED
|
@@ -1,145 +1,149 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
-
from bs4 import BeautifulSoup
|
| 4 |
-
from geopy.geocoders import Nominatim
|
| 5 |
import os
|
| 6 |
-
import
|
| 7 |
-
from streamlit_folium import folium_static
|
| 8 |
-
from fake_useragent import UserAgent
|
| 9 |
|
| 10 |
-
# Configure
|
| 11 |
-
DEEPSEEK_API_KEY = os.getenv("
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
headers = {
|
| 42 |
"Authorization": f"Bearer {DEEPSEEK_API_KEY}",
|
| 43 |
"Content-Type": "application/json"
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
- Unique benefits for each
|
| 56 |
-
- Comparison of custom factors
|
| 57 |
-
- Final recommendation
|
| 58 |
-
|
| 59 |
-
End with: "Want your own AI tool? Visit {PROMOTION_LINK}"
|
| 60 |
-
"""
|
| 61 |
|
| 62 |
try:
|
| 63 |
-
response = requests.post(
|
| 64 |
-
|
| 65 |
-
json={
|
| 66 |
-
"model": "deepseek-chat",
|
| 67 |
-
"messages": [{"role": "user", "content": base_prompt}],
|
| 68 |
-
"temperature": 0.7,
|
| 69 |
-
"max_tokens": 1500
|
| 70 |
-
},
|
| 71 |
-
headers=headers,
|
| 72 |
-
timeout=30
|
| 73 |
-
)
|
| 74 |
return response.json()["choices"][0]["message"]["content"]
|
| 75 |
-
except Exception:
|
|
|
|
| 76 |
return None
|
| 77 |
|
| 78 |
-
# Streamlit UI
|
| 79 |
-
st.set_page_config(
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
st.markdown(f"""
|
| 83 |
-
<div style="background:#f0f2f6;padding:10px;border-radius:5px;margin-bottom:20px">
|
| 84 |
-
<h3 style="color:#1e88e5;text-align:center;">{BRANDING_TEXT}</h3>
|
| 85 |
-
</div>
|
| 86 |
-
""", unsafe_allow_html=True)
|
| 87 |
|
| 88 |
-
st.
|
| 89 |
-
|
| 90 |
-
with st.sidebar:
|
| 91 |
-
st.header("Realtor Instructions")
|
| 92 |
-
st.markdown(f"""
|
| 93 |
-
Add this tool to your website for free!
|
| 94 |
-
[Get your customized version](https://{PROMOTION_LINK})
|
| 95 |
-
""")
|
| 96 |
-
st.markdown("---")
|
| 97 |
-
st.header("Client Preferences")
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
if st.button("Find My Perfect Neighborhood"):
|
| 112 |
-
with st.spinner("Creating your custom report..."):
|
| 113 |
-
preferences = {
|
| 114 |
-
"City": city,
|
| 115 |
-
"Budget": f"${budget[0]} - ${budget[1]}",
|
| 116 |
-
"Home Type": home_type
|
| 117 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
| 126 |
-
st.
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
</button>
|
| 134 |
-
</a>
|
| 135 |
-
</div>
|
| 136 |
-
""", unsafe_allow_html=True)
|
| 137 |
-
else:
|
| 138 |
-
st.error("Error generating report. Please try again.")
|
| 139 |
|
| 140 |
-
|
| 141 |
-
st.markdown(
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
""", unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
|
|
|
|
|
|
| 3 |
import os
|
| 4 |
+
from datetime import datetime
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Configure DeepSeek
|
| 7 |
+
DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
|
| 8 |
+
DEEPSEEK_ENDPOINT = "https://api.deepseek.com/v1/chat/completions"
|
| 9 |
|
| 10 |
+
FUNNEL_STAGES = {
|
| 11 |
+
"Awareness": {
|
| 12 |
+
"examples": ["Educational content", "Problem-awareness", "Trend discussions"],
|
| 13 |
+
"channels": ["YouTube", "Facebook", "TikTok", "Instagram Reels"]
|
| 14 |
+
},
|
| 15 |
+
"Consideration": {
|
| 16 |
+
"examples": ["Product demos", "Comparison videos", "Testimonials"],
|
| 17 |
+
"channels": ["LinkedIn", "Email campaigns", "YouTube Ads"]
|
| 18 |
+
},
|
| 19 |
+
"Conversion": {
|
| 20 |
+
"examples": ["Limited-time offers", "Case studies", "Live Q&A sessions"],
|
| 21 |
+
"channels": ["Website landing pages", "Retargeting ads", "SMS campaigns"]
|
| 22 |
+
},
|
| 23 |
+
"Retention": {
|
| 24 |
+
"examples": ["Customer success stories", "Loyalty programs", "Product updates"],
|
| 25 |
+
"channels": ["Email sequences", "Private Facebook groups", "Mobile app notifications"]
|
| 26 |
}
|
| 27 |
+
}
|
| 28 |
|
| 29 |
+
def generate_marketing_plan(business_details, customer_profile):
|
| 30 |
+
"""Generate complete video marketing plan using DeepSeek"""
|
| 31 |
+
prompt = f"""Create a detailed video marketing funnel plan for:
|
| 32 |
+
|
| 33 |
+
Business Details:
|
| 34 |
+
- Name: {business_details['name']}
|
| 35 |
+
- Industry: {business_details['industry']}
|
| 36 |
+
- Unique Value Proposition: {business_details['uvp']}
|
| 37 |
+
|
| 38 |
+
Target Customer:
|
| 39 |
+
- Demographics: {customer_profile['demographics']}
|
| 40 |
+
- Main Challenges: {customer_profile['challenges']}
|
| 41 |
+
- Preferred Content Types: {customer_profile['content_prefs']}
|
| 42 |
+
|
| 43 |
+
Create a 12-month plan including:
|
| 44 |
+
1. 3 video ideas for each funnel stage (Awareness, Consideration, Conversion, Retention)
|
| 45 |
+
2. Script outline for top 2 Awareness videos
|
| 46 |
+
3. Promotion strategies for each stage
|
| 47 |
+
4. Lead magnet ideas aligned with each video
|
| 48 |
+
5. Recommended tools/software
|
| 49 |
+
6. Key performance metrics to track
|
| 50 |
+
|
| 51 |
+
Format with markdown headers and bullet points."""
|
| 52 |
+
|
| 53 |
headers = {
|
| 54 |
"Authorization": f"Bearer {DEEPSEEK_API_KEY}",
|
| 55 |
"Content-Type": "application/json"
|
| 56 |
}
|
| 57 |
|
| 58 |
+
data = {
|
| 59 |
+
"model": "deepseek-chat",
|
| 60 |
+
"messages": [
|
| 61 |
+
{"role": "system", "content": "You are a video marketing expert specializing in creating conversion funnels for small businesses."},
|
| 62 |
+
{"role": "user", "content": prompt}
|
| 63 |
+
],
|
| 64 |
+
"temperature": 0.7,
|
| 65 |
+
"max_tokens": 2000
|
| 66 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
try:
|
| 69 |
+
response = requests.post(DEEPSEEK_ENDPOINT, json=data, headers=headers)
|
| 70 |
+
response.raise_for_status()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
return response.json()["choices"][0]["message"]["content"]
|
| 72 |
+
except Exception as e:
|
| 73 |
+
st.error(f"API Error: {str(e)}")
|
| 74 |
return None
|
| 75 |
|
| 76 |
+
# Streamlit UI (same as before)
|
| 77 |
+
st.set_page_config(page_title="Video Funnel Builder", layout="wide")
|
| 78 |
+
st.title("🎥 AI Video Marketing Funnel Builder")
|
| 79 |
+
st.markdown("### Transform viewers into customers with strategic video content")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
with st.expander("🚀 Start Here - Enter Business Details", expanded=True):
|
| 82 |
+
col1, col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
with col1:
|
| 85 |
+
business_details = {
|
| 86 |
+
"name": st.text_input("Business Name", "The Urban Bakery"),
|
| 87 |
+
"industry": st.selectbox("Industry", ["Food & Beverage", "Retail", "Services", "E-commerce", "Other"]),
|
| 88 |
+
"uvp": st.text_area("Unique Value Proposition", "Artisan breads using 100-year-old sourdough starters")
|
| 89 |
+
}
|
| 90 |
|
| 91 |
+
with col2:
|
| 92 |
+
customer_profile = {
|
| 93 |
+
"demographics": st.text_input("Target Customer Demographics", "Ages 25-45, urban professionals, health-conscious"),
|
| 94 |
+
"challenges": st.text_input("Their Main Challenges", "Finding time to cook healthy meals, wanting premium quality"),
|
| 95 |
+
"content_prefs": st.multiselect("Their Preferred Content Types",
|
| 96 |
+
["How-to Guides", "Behind-the-Scenes", "Testimonials", "Live Videos"],
|
| 97 |
+
default=["How-to Guides", "Behind-the-Scenes"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 99 |
+
|
| 100 |
+
if st.button("Generate Video Marketing Plan"):
|
| 101 |
+
with st.spinner("Creating your custom 12-month video strategy..."):
|
| 102 |
+
plan = generate_marketing_plan(business_details, customer_profile)
|
| 103 |
|
| 104 |
+
if plan:
|
| 105 |
+
st.success("✅ Your AI-Generated Video Marketing Plan")
|
| 106 |
+
with st.expander("📘 Full Plan Overview", expanded=True):
|
| 107 |
+
st.markdown(plan)
|
| 108 |
+
|
| 109 |
+
# Rest of the UI components remain the same
|
| 110 |
+
st.subheader("🎯 Stage-by-Stage Breakdown")
|
| 111 |
+
|
| 112 |
+
for stage in FUNNEL_STAGES:
|
| 113 |
+
with st.expander(f"{stage} Stage Strategy"):
|
| 114 |
+
col_a, col_b = st.columns([1,2])
|
| 115 |
+
|
| 116 |
+
with col_a:
|
| 117 |
+
st.markdown(f"**Top Video Ideas**")
|
| 118 |
+
for example in FUNNEL_STAGES[stage]["examples"][:3]:
|
| 119 |
+
st.write(f"- {example}")
|
| 120 |
+
|
| 121 |
+
st.markdown(f"\n**Best Promotion Channels**")
|
| 122 |
+
for channel in FUNNEL_STAGES[stage]["channels"][:3]:
|
| 123 |
+
st.write(f"- {channel}")
|
| 124 |
+
|
| 125 |
+
with col_b:
|
| 126 |
+
st.markdown("**Sample Lead Magnets**")
|
| 127 |
+
lead_magnets = {
|
| 128 |
+
"Awareness": ["Free ebook", "Industry report", "Checklist"],
|
| 129 |
+
"Consideration": ["Webinar invite", "Product samples", "Comparison guide"],
|
| 130 |
+
"Conversion": ["Discount code", "Free trial", "Consultation offer"],
|
| 131 |
+
"Retention": ["Loyalty program", "Exclusive content", "Early access"]
|
| 132 |
+
}
|
| 133 |
+
for magnet in lead_magnets[stage]:
|
| 134 |
+
st.write(f"- {magnet}")
|
| 135 |
|
| 136 |
+
st.markdown("---")
|
| 137 |
+
st.subheader("📚 Recommended Resources")
|
| 138 |
+
st.write("""
|
| 139 |
+
- **Free Video Editing Tools**: CapCut, Canva Video
|
| 140 |
+
- **Analytics Tools**: Google Analytics, VidIQ
|
| 141 |
+
- **Content Calendar Template**: [Download Here]
|
| 142 |
+
- **Lighting Equipment Guide**: [View Recommendations]
|
| 143 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
+
st.markdown("---")
|
| 146 |
+
st.markdown("""
|
| 147 |
+
*This AI-powered tool creates customized video marketing strategies. \
|
| 148 |
+
Always validate recommendations with your specific business context.*
|
| 149 |
+
""")
|
|
|