nniehaus commited on
Commit
29a733a
·
verified ·
1 Parent(s): 4ab4a0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +125 -121
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 folium
7
- from streamlit_folium import folium_static
8
- from fake_useragent import UserAgent
9
 
10
- # Configure environment
11
- DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_KEY")
12
- API_ENDPOINT = "https://api.deepseek.com/v1/chat/completions"
13
 
14
- # Customizable branding
15
- PROMOTION_LINK = "www.myeverydayai.com"
16
- BRANDING_TEXT = "Powered by [Everyday AI Solutions](https://www.myeverydayai.com)"
17
-
18
- def get_scraping_headers():
19
- ua = UserAgent()
20
- return {
21
- 'User-Agent': ua.chrome,
22
- 'Accept-Language': 'en-US,en;q=0.9',
23
- 'Referer': 'https://www.google.com/'
 
 
 
 
 
 
24
  }
 
25
 
26
- @st.cache_data
27
- def scrape_location_data(query):
28
- session = requests.Session()
29
- try:
30
- response = session.get(
31
- f"https://www.niche.com/places-to-live/search/{query}",
32
- headers=get_scraping_headers(),
33
- timeout=15
34
- )
35
- # Add scraping logic here
36
- return ["Sample Neighborhood 1", "Sample Neighborhood 2"]
37
- except Exception:
38
- return []
39
-
40
- def generate_recommendations(preferences, custom_factors):
 
 
 
 
 
 
 
 
 
41
  headers = {
42
  "Authorization": f"Bearer {DEEPSEEK_API_KEY}",
43
  "Content-Type": "application/json"
44
  }
45
 
46
- base_prompt = f"""
47
- Analyze these neighborhood preferences:
48
- {preferences}
49
-
50
- Additional Custom Factors:
51
- {custom_factors}
52
-
53
- Create a detailed report with:
54
- - Top 3 neighborhood matches
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
- API_ENDPOINT,
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(layout="wide", page_icon="🏡")
80
-
81
- # Branding Header
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.title("🏡 Smart Neighborhood Finder")
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
- # Core inputs
100
- city = st.text_input("City/Region", "New York, NY")
101
- budget = st.slider("Price Range ($)", 1000, 5000, (2000, 4000))
102
- home_type = st.selectbox("Home Type", ["House", "Apartment", "Condominium"])
 
 
103
 
104
- # Custom factors
105
- custom_factors = st.text_area(
106
- "Add Your Special Requirements",
107
- placeholder="e.g., Near dog parks, Vegan restaurants, Yoga studios"
108
- )
109
-
110
- # Generate report
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
- report = generate_recommendations(preferences, custom_factors)
120
-
121
- if report:
122
- st.subheader("Your Personalized Neighborhood Report")
123
- st.markdown(report)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- # Promotional footer
126
- st.markdown(f"""
127
- ---
128
- <div style="text-align:center;margin-top:40px">
129
- <h4>Want this AI tool on your website?</h4>
130
- <a href="https://{PROMOTION_LINK}">
131
- <button style="background:#1e88e5;color:white;padding:10px 20px;border:none;border-radius:5px">
132
- Get Your Free Version
133
- </button>
134
- </a>
135
- </div>
136
- """, unsafe_allow_html=True)
137
- else:
138
- st.error("Error generating report. Please try again.")
139
 
140
- # Always show branding footer
141
- st.markdown(f"""
142
- <div style="text-align:center;margin-top:50px;padding:20px;background:#f8f9fa">
143
- {BRANDING_TEXT} - Provide AI-powered tools to your clients
144
- </div>
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
+ """)