|
import streamlit as st |
|
import openai |
|
import pdfkit |
|
import os |
|
|
|
|
|
openai.api_key = st.secrets["OPENAI_API_KEY"] |
|
|
|
st.title("2024 Video Marketing Plan Generator") |
|
|
|
|
|
st.subheader("Define Your Business and Audience") |
|
business_type = st.text_input("Your Business Type", placeholder="e.g., Cafe, Yoga Studio") |
|
target_audience = st.text_area("Describe Your Target Audience", placeholder="e.g., demographics, interests") |
|
|
|
st.subheader("Current Marketing Efforts") |
|
current_marketing = st.text_area("Current Marketing Strategies", placeholder="Describe your ongoing marketing activities.") |
|
|
|
|
|
if st.button('Load Test Data'): |
|
st.session_state['business_type'] = "Real Estate Agency" |
|
st.session_state['target_audience'] = "Families and individuals looking to buy homes in suburban areas, focusing on first-time homebuyers and those seeking to upgrade to larger properties." |
|
st.session_state['current_marketing'] = "Monthly newsletter, weekly social media posts on property listings and home buying tips, participation in local community events, and occasional paid ads on local online forums." |
|
|
|
|
|
business_type = st.text_input("Your Business Type", value=st.session_state.get('business_type', ''), placeholder="e.g., Cafe, Yoga Studio") |
|
target_audience = st.text_area("Describe Your Target Audience", value=st.session_state.get('target_audience', ''), placeholder="e.g., demographics, interests") |
|
current_marketing = st.text_area("Current Marketing Strategies", value=st.session_state.get('current_marketing', ''), placeholder="What are your ongoing marketing activities?") |
|
|
|
if st.button('Generate My Video Marketing Plan'): |
|
|
|
prompt_text = ( |
|
f"Generate a 2024 video marketing plan for a {business_type} targeting an audience characterized as: {target_audience}. " |
|
f"Include up to four video ideas for each month and 10 specific distribution strategies to maximize video views, " |
|
f"based on current marketing efforts: {current_marketing}." |
|
) |
|
|
|
|
|
try: |
|
response_text = openai.ChatCompletion.create( |
|
model="gpt-4", |
|
messages=[ |
|
{"role": "system", "content": "You are an AI specializing in marketing strategy."}, |
|
{"role": "user", "content": prompt_text} |
|
] |
|
) |
|
marketing_plan = response_text.choices[0].message['content'] |
|
except Exception as e: |
|
marketing_plan = f"Error in generating marketing plan: {e}" |
|
|
|
|
|
st.markdown("### Your Customized Video Marketing Plan") |
|
st.write(marketing_plan) |
|
|
|
|
|
if marketing_plan: |
|
html = f"<html><body><h2>Your Customized Video Marketing Plan</h2><p>{marketing_plan.replace('\n', '<br>')}</p></body></html>" |
|
pdf = pdfkit.from_string(html, False) |
|
|
|
st.download_button( |
|
label="Download your plan as PDF", |
|
data=pdf, |
|
file_name="video_marketing_plan.pdf", |
|
mime="application/octet-stream" |
|
) |
|
|