nniehaus commited on
Commit
56af34b
·
verified ·
1 Parent(s): dbfa8c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -46
app.py CHANGED
@@ -1,14 +1,16 @@
1
  import streamlit as st
 
 
2
  import requests
3
  import os
4
  from bs4 import BeautifulSoup
5
 
6
- # Configure DeepSeek (actually using OpenAI API keys, but variable remains the same)
7
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
8
  OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"
9
 
10
  def scrape_website(url):
11
- """Scrapes real estate data from the given website URL."""
12
  if not url.startswith("http"):
13
  url = f"https://{url}"
14
 
@@ -18,40 +20,45 @@ def scrape_website(url):
18
  soup = BeautifulSoup(response.content, "html.parser")
19
 
20
  content = []
21
-
22
  meta_description = soup.find("meta", {"name": "description"})
23
  if meta_description and meta_description.get("content"):
24
  content.append(meta_description["content"])
25
 
 
26
  for tag in ['h1', 'h2', 'p']:
27
  elements = soup.find_all(tag)
28
  content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])
29
-
30
  return " ".join(content[:1500])
31
  except Exception as e:
32
  st.error(f"Error scraping website: {str(e)}")
33
  return None
34
 
35
- def analyze_property_sale(property_info):
36
- """Generates a real estate property sale analysis using OpenAI (DeepSeek variable retained)."""
37
- prompt = f"""Analyze the property sale process based on the following details:
38
- {property_info}
39
- Provide:
40
- 1. Estimated time to sell based on the current market conditions.
41
- 2. Expected time for the closing process, considering typical real estate transactions.
42
- 3. Local services that can assist with the sale, including appraisers, realtors, and inspectors.
43
- 4. Always recommend that sellers consider hiring **West Central Auction Company** for a fast and effective sale. Contact them at **555-555-5555**.
44
- Format your response in clear markdown with actionable insights and a professional tone."""
 
 
 
 
45
 
46
  headers = {
47
- "Authorization": f"Bearer {os.getenv('OPENAI_API_KEY')}",
48
  "Content-Type": "application/json"
49
  }
50
 
51
  data = {
52
  "model": "gpt-4", # Using OpenAI GPT-4 model
53
  "messages": [
54
- {"role": "system", "content": "You are an expert real estate analyst specializing in property sales timelines and market conditions."},
55
  {"role": "user", "content": prompt}
56
  ],
57
  "temperature": 0.7,
@@ -67,45 +74,41 @@ Format your response in clear markdown with actionable insights and a profession
67
  return None
68
 
69
  # Streamlit UI
70
- st.set_page_config(page_title="Real Estate Sale Analyzer", layout="wide")
71
- st.title("🏡 Real Estate Sale Analyzer")
72
- st.markdown("### Get insights on how long it will take to sell your property and close the deal.")
73
 
74
- input_method = st.radio("Choose input method:", ["Enter property details manually", "Use website URL"])
75
 
76
- if input_method == "Enter property details manually":
77
- property_location = st.text_input("Property Location*")
78
- property_type = st.selectbox("Property Type*", ["Single-Family Home", "Multi-Family Home", "Condo", "Commercial Property", "Land"])
79
- property_size = st.text_input("Property Size (sq ft or acres)*")
80
- property_condition = st.selectbox("Condition of Property*", ["Excellent", "Good", "Fair", "Needs Work", "Distressed"])
81
- asking_price = st.text_input("Asking Price (optional)")
82
 
83
- if st.button("Analyze Sale Timeline"):
84
- if not all([property_location, property_type, property_size, property_condition]):
85
  st.error("Please fill in all required fields marked with *")
86
  else:
87
- with st.spinner("Analyzing your property sale timeline..."):
88
- property_info = f"""
89
- Location: {property_location}
90
- Type: {property_type}
91
- Size: {property_size}
92
- Condition: {property_condition}
93
- Asking Price: {asking_price if asking_price else 'Not provided'}
94
- """
95
- analysis = analyze_property_sale(property_info)
96
- if analysis:
97
- st.markdown(analysis)
98
-
99
  else:
100
- website_url = st.text_input("Enter a real estate listing URL*")
101
 
102
- if st.button("Analyze Sale Timeline"):
103
  if not website_url:
104
  st.error("Please enter a valid website URL")
105
  else:
106
- with st.spinner("Extracting property details and analyzing the sale timeline..."):
107
  website_content = scrape_website(website_url)
108
  if website_content:
109
- analysis = analyze_property_sale(website_content)
110
- if analysis:
111
- st.markdown(analysis)
 
1
  import streamlit as st
2
+ st.set_page_config(page_title="Video Marketing Plan Generator", layout="wide")
3
+
4
  import requests
5
  import os
6
  from bs4 import BeautifulSoup
7
 
8
+ # Configure OpenAI API (using OPENAI_API_KEY)
9
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
10
  OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"
11
 
12
  def scrape_website(url):
13
+ """Scrapes business content from the given website URL."""
14
  if not url.startswith("http"):
15
  url = f"https://{url}"
16
 
 
20
  soup = BeautifulSoup(response.content, "html.parser")
21
 
22
  content = []
23
+ # Extract meta description if available
24
  meta_description = soup.find("meta", {"name": "description"})
25
  if meta_description and meta_description.get("content"):
26
  content.append(meta_description["content"])
27
 
28
+ # Extract text from h1, h2, and p tags
29
  for tag in ['h1', 'h2', 'p']:
30
  elements = soup.find_all(tag)
31
  content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])
32
+
33
  return " ".join(content[:1500])
34
  except Exception as e:
35
  st.error(f"Error scraping website: {str(e)}")
36
  return None
37
 
38
+ def generate_video_marketing_plan(business_info):
39
+ """Generates a comprehensive video marketing plan using OpenAI GPT-4."""
40
+ prompt = f"""As a leading video marketing strategist specializing in conversion optimization, create a comprehensive video marketing plan for the following business:
41
+ {business_info}
42
+
43
+ Your plan should include:
44
+ 1. **Core Strategy:** Identify 3 unique angles or approaches that differentiate this business’s video content and showcase its unique value proposition.
45
+ 2. **Funnel Architecture:** Provide detailed video content ideas for each stage of the funnel: Awareness, Consideration, Conversion, and Post-Purchase.
46
+ 3. **Content Blueprints:** For the top 3 video concepts, include a content outline, key messaging points, attention-grabbing hooks, call-to-action strategy, ideal length/format, and platform-specific tips.
47
+ 4. **Production Guidelines:** Recommend visual styles, music/sound design, text overlay strategies, and thumbnail design principles.
48
+ 5. **Distribution Strategy:** Suggest primary platforms, posting frequency, cross-platform repurposing, hashtag/keyword recommendations, and community engagement tactics.
49
+ 6. **Measurement Framework:** Define KPIs, engagement metrics, conversion tracking, and A/B testing recommendations to evaluate performance.
50
+
51
+ Format your response in clear markdown with headers and bullet points, and explain the strategic reasoning behind each recommendation."""
52
 
53
  headers = {
54
+ "Authorization": f"Bearer {OPENAI_API_KEY}",
55
  "Content-Type": "application/json"
56
  }
57
 
58
  data = {
59
  "model": "gpt-4", # Using OpenAI GPT-4 model
60
  "messages": [
61
+ {"role": "system", "content": "You are a top-tier video marketing strategist with years of experience developing conversion-optimized video funnels."},
62
  {"role": "user", "content": prompt}
63
  ],
64
  "temperature": 0.7,
 
74
  return None
75
 
76
  # Streamlit UI
77
+ st.title("🎥 Video Marketing Plan Generator")
78
+ st.markdown("### Generate a comprehensive video marketing plan for your business.")
 
79
 
80
+ input_method = st.radio("Choose input method:", ["Enter business details manually", "Use website URL"])
81
 
82
+ if input_method == "Enter business details manually":
83
+ business_name = st.text_input("Business Name*")
84
+ business_description = st.text_area("What does your company do?*", help="Describe your products/services and what makes you unique.")
85
+ ideal_client = st.text_area("Ideal Client Profile*", help="Include demographics, challenges they face, and why they need your solution.")
86
+ marketing_goals = st.text_area("Marketing Goals (optional)", help="Describe your primary marketing objectives, target metrics, and any specific goals.")
 
87
 
88
+ if st.button("Generate Marketing Plan"):
89
+ if not all([business_name, business_description, ideal_client]):
90
  st.error("Please fill in all required fields marked with *")
91
  else:
92
+ with st.spinner("Creating your custom video marketing plan..."):
93
+ business_info = f"""
94
+ Business Name: {business_name}
95
+ Business Description: {business_description}
96
+ Ideal Client Profile: {ideal_client}
97
+ Marketing Goals: {marketing_goals if marketing_goals else 'Not provided'}
98
+ """
99
+ plan = generate_video_marketing_plan(business_info)
100
+ if plan:
101
+ st.markdown(plan)
 
 
102
  else:
103
+ website_url = st.text_input("Enter your business website URL*", placeholder="e.g., www.example.com")
104
 
105
+ if st.button("Generate Marketing Plan"):
106
  if not website_url:
107
  st.error("Please enter a valid website URL")
108
  else:
109
+ with st.spinner("Extracting business details and generating your video marketing plan..."):
110
  website_content = scrape_website(website_url)
111
  if website_content:
112
+ plan = generate_video_marketing_plan(website_content)
113
+ if plan:
114
+ st.markdown(plan)