nniehaus commited on
Commit
b70f7b6
·
verified ·
1 Parent(s): ecee095

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -62
app.py CHANGED
@@ -4,6 +4,7 @@ st.set_page_config(page_title="Video Funnel Generator", layout="wide")
4
  import requests
5
  import os
6
  from bs4 import BeautifulSoup
 
7
 
8
  # Set the Space URL for your tool on Hugging Face.
9
  SPACE_URL = os.getenv("SPACE_URL", "https://huggingface.co/spaces/nniehaus/Video-Funnel-Planner")
@@ -24,9 +25,13 @@ if st.button("Turn on Video Funnel Tool"):
24
  except Exception as e:
25
  st.error(f"Error waking the tool: {str(e)}")
26
 
27
- # Configure DeepSeek
28
- DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
29
- DEEPSEEK_ENDPOINT = "https://api.deepseek.com/v1/chat/completions"
 
 
 
 
30
 
31
  def scrape_website(url, max_pages=3):
32
  """Scrapes content from the given website URL."""
@@ -51,8 +56,43 @@ def scrape_website(url, max_pages=3):
51
  return None
52
 
53
  def generate_marketing_plan(business_info):
54
- """Generate comprehensive video marketing plan using DeepSeek"""
55
- prompt = f"""As a leading video marketing strategist, analyze this business and create an immediately actionable video funnel strategy:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  BUSINESS INFORMATION:
58
  {business_info}
@@ -259,66 +299,21 @@ By implementing this strategy, you should see:
259
  - [Specific metric improvement] within 60 days
260
  - [Specific metric improvement] within 90 days
261
 
262
- Remember: The key to video marketing success is consistency and testing. Start with one platform, master your content format, then scale to additional channels.
263
- """
264
-
265
- headers = {
266
- "Authorization": f"Bearer {DEEPSEEK_API_KEY}",
267
- "Content-Type": "application/json"
268
- }
269
-
270
- data = {
271
- "model": "deepseek-chat",
272
- "messages": [
273
- {
274
- "role": "system",
275
- "content": """You are a world-class video marketing strategist who combines proven methodologies from industry leaders:
276
-
277
- CORE EXPERTISE:
278
- - Gary Vaynerchuk's "Document Don't Create" philosophy and pattern interruption techniques
279
- - Alex Hormozi's high-value content frameworks and offer psychology
280
- - MrBeast's viral video engineering and thumbnail psychology
281
- - Russell Brunson's funnel optimization and customer journey mapping
282
- - Seth Godin's permission marketing and storytelling principles
283
-
284
- SPECIALIZATIONS:
285
- - Behavioral psychology in video engagement (hooks, retention, conversions)
286
- - Platform-specific algorithm optimization (YouTube, TikTok, Instagram, LinkedIn)
287
- - ROI-focused content strategies for small businesses
288
- - Video SEO and discoverability tactics
289
- - Mobile-first content creation
290
- - Community building through video content
291
-
292
- 2025 FOCUS AREAS:
293
- - AI-powered personalization at scale
294
- - Short-form video dominance across platforms
295
- - Authentic storytelling over polished production
296
- - Interactive and shoppable video content
297
- - Cross-platform content repurposing strategies
298
- - Privacy-first marketing approaches
299
-
300
- YOUR APPROACH:
301
- - Every recommendation must be immediately actionable
302
- - Focus on high-impact, low-cost strategies first
303
- - Provide specific examples, not generic advice
304
- - Include exact metrics and timelines
305
- - Account for resource constraints of small businesses
306
- - Emphasize testing and optimization over perfection
307
-
308
- TONE: Professional but accessible, confident but humble, data-driven but creative"""
309
- },
310
- {"role": "user", "content": prompt}
311
- ],
312
- "temperature": 0.7,
313
- "max_tokens": 4000
314
- }
315
 
316
  try:
317
- response = requests.post(DEEPSEEK_ENDPOINT, json=data, headers=headers)
318
- response.raise_for_status()
319
- return response.json()["choices"][0]["message"]["content"]
 
 
 
 
 
 
 
320
  except Exception as e:
321
- st.error(f"API Error: {str(e)}")
322
  return None
323
 
324
  # Enhanced UI with better visual hierarchy
 
4
  import requests
5
  import os
6
  from bs4 import BeautifulSoup
7
+ from openai import OpenAI
8
 
9
  # Set the Space URL for your tool on Hugging Face.
10
  SPACE_URL = os.getenv("SPACE_URL", "https://huggingface.co/spaces/nniehaus/Video-Funnel-Planner")
 
25
  except Exception as e:
26
  st.error(f"Error waking the tool: {str(e)}")
27
 
28
+ # Configure OpenAI
29
+ openai_api_key = os.getenv("OPENAI_API_KEY")
30
+ if not openai_api_key:
31
+ st.error("⚠️ OpenAI API key not found. Please set your OPENAI_API_KEY environment variable.")
32
+ st.stop()
33
+
34
+ client = OpenAI(api_key=openai_api_key)
35
 
36
  def scrape_website(url, max_pages=3):
37
  """Scrapes content from the given website URL."""
 
56
  return None
57
 
58
  def generate_marketing_plan(business_info):
59
+ """Generate comprehensive video marketing plan using OpenAI"""
60
+ system_prompt = """You are a world-class video marketing strategist who combines proven methodologies from industry leaders:
61
+
62
+ CORE EXPERTISE:
63
+ - Gary Vaynerchuk's "Document Don't Create" philosophy and pattern interruption techniques
64
+ - Alex Hormozi's high-value content frameworks and offer psychology
65
+ - MrBeast's viral video engineering and thumbnail psychology
66
+ - Russell Brunson's funnel optimization and customer journey mapping
67
+ - Seth Godin's permission marketing and storytelling principles
68
+
69
+ SPECIALIZATIONS:
70
+ - Behavioral psychology in video engagement (hooks, retention, conversions)
71
+ - Platform-specific algorithm optimization (YouTube, TikTok, Instagram, LinkedIn)
72
+ - ROI-focused content strategies for small businesses
73
+ - Video SEO and discoverability tactics
74
+ - Mobile-first content creation
75
+ - Community building through video content
76
+
77
+ 2025 FOCUS AREAS:
78
+ - AI-powered personalization at scale
79
+ - Short-form video dominance across platforms
80
+ - Authentic storytelling over polished production
81
+ - Interactive and shoppable video content
82
+ - Cross-platform content repurposing strategies
83
+ - Privacy-first marketing approaches
84
+
85
+ YOUR APPROACH:
86
+ - Every recommendation must be immediately actionable
87
+ - Focus on high-impact, low-cost strategies first
88
+ - Provide specific examples, not generic advice
89
+ - Include exact metrics and timelines
90
+ - Account for resource constraints of small businesses
91
+ - Emphasize testing and optimization over perfection
92
+
93
+ TONE: Professional but accessible, confident but humble, data-driven but creative"""
94
+
95
+ user_prompt = f"""As a leading video marketing strategist, analyze this business and create an immediately actionable video funnel strategy:
96
 
97
  BUSINESS INFORMATION:
98
  {business_info}
 
299
  - [Specific metric improvement] within 60 days
300
  - [Specific metric improvement] within 90 days
301
 
302
+ Remember: The key to video marketing success is consistency and testing. Start with one platform, master your content format, then scale to additional channels."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
  try:
305
+ response = client.chat.completions.create(
306
+ model="gpt-4",
307
+ messages=[
308
+ {"role": "system", "content": system_prompt},
309
+ {"role": "user", "content": user_prompt}
310
+ ],
311
+ temperature=0.7,
312
+ max_tokens=4000
313
+ )
314
+ return response.choices[0].message.content
315
  except Exception as e:
316
+ st.error(f"OpenAI API Error: {str(e)}")
317
  return None
318
 
319
  # Enhanced UI with better visual hierarchy