Update app.py
Browse files
app.py
CHANGED
@@ -23,26 +23,29 @@ def scrape_website(url):
|
|
23 |
return f"Error fetching website data: {e}"
|
24 |
|
25 |
def call_openai_api(messages):
|
|
|
|
|
|
|
26 |
return openai.ChatCompletion.create(
|
27 |
model="gpt-3.5-turbo",
|
28 |
messages=messages,
|
29 |
-
max_tokens=
|
30 |
)
|
31 |
|
32 |
-
def
|
|
|
|
|
|
|
33 |
query = f"""
|
34 |
The user has provided the following details:
|
35 |
-
-
|
36 |
-
-
|
37 |
-
-
|
38 |
-
-
|
39 |
-
- Labor cost per hour: ${labor_cost}
|
40 |
-
|
41 |
-
Additional business information: {business_info}
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
"""
|
47 |
|
48 |
messages.append({"role": "user", "content": query})
|
@@ -59,36 +62,36 @@ if "reply" not in st.session_state:
|
|
59 |
st.session_state["reply"] = None
|
60 |
|
61 |
# Centered title
|
62 |
-
st.markdown("<h1 style='text-align: center; color: black;'>
|
63 |
|
64 |
# User inputs
|
65 |
col1, col2 = st.columns(2)
|
66 |
with col1:
|
67 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Enter
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
website_url = st.text_input("Enter your business website (optional)", placeholder="https://example.com")
|
74 |
-
generate_button = st.button('Estimate Painting Cost')
|
75 |
|
76 |
# Process results on button click
|
77 |
-
if generate_button:
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
89 |
|
90 |
# Display results if there is a reply in session state
|
91 |
if st.session_state["reply"]:
|
92 |
with col2:
|
93 |
-
st.markdown("<h2 style='text-align: center; color: black;'>
|
94 |
st.write(st.session_state["reply"])
|
|
|
23 |
return f"Error fetching website data: {e}"
|
24 |
|
25 |
def call_openai_api(messages):
|
26 |
+
"""
|
27 |
+
Calls the OpenAI API to generate marketing plan suggestions.
|
28 |
+
"""
|
29 |
return openai.ChatCompletion.create(
|
30 |
model="gpt-3.5-turbo",
|
31 |
messages=messages,
|
32 |
+
max_tokens=1000 # Allow for detailed marketing strategies
|
33 |
)
|
34 |
|
35 |
+
def generate_marketing_plan(website_info, industry, goals, budget, messages):
|
36 |
+
"""
|
37 |
+
Generates a marketing plan based on website information, industry, and user goals.
|
38 |
+
"""
|
39 |
query = f"""
|
40 |
The user has provided the following details:
|
41 |
+
- Website information: {website_info}
|
42 |
+
- Industry: {industry}
|
43 |
+
- Goals for 2025: {goals}
|
44 |
+
- Marketing budget for 2025: ${budget}
|
|
|
|
|
|
|
45 |
|
46 |
+
Please create a comprehensive marketing plan for 2025. Include specific strategies
|
47 |
+
(e.g., content marketing, social media, advertising, SEO) and a timeline for implementing them.
|
48 |
+
Highlight how the website's strengths can be leveraged to achieve the stated goals.
|
49 |
"""
|
50 |
|
51 |
messages.append({"role": "user", "content": query})
|
|
|
62 |
st.session_state["reply"] = None
|
63 |
|
64 |
# Centered title
|
65 |
+
st.markdown("<h1 style='text-align: center; color: black;'>2025 Marketing Planner</h1>", unsafe_allow_html=True)
|
66 |
|
67 |
# User inputs
|
68 |
col1, col2 = st.columns(2)
|
69 |
with col1:
|
70 |
+
st.markdown("<h2 style='text-align: center; color: black;'>Enter Business Details</h2>", unsafe_allow_html=True)
|
71 |
+
website_url = st.text_input("Enter your business website", placeholder="https://example.com")
|
72 |
+
industry = st.text_input("Industry", placeholder="E.g., Real Estate, Retail, Technology")
|
73 |
+
goals = st.text_area("Goals for 2025", placeholder="E.g., increase brand awareness, drive online sales, expand audience")
|
74 |
+
budget = st.number_input("Marketing Budget for 2025 ($)", min_value=1000, step=1000)
|
75 |
+
generate_button = st.button('Generate Marketing Plan')
|
|
|
|
|
76 |
|
77 |
# Process results on button click
|
78 |
+
if generate_button and website_url:
|
79 |
+
website_info = scrape_website(website_url)
|
80 |
+
if "Error" not in website_info:
|
81 |
+
messages = [{
|
82 |
+
"role": "system",
|
83 |
+
"content": """
|
84 |
+
You are a marketing strategist specializing in creating detailed yearly plans. Based on provided website information,
|
85 |
+
industry, goals, and budget, create a tailored 2025 marketing plan. Include strategies, a timeline, and how the
|
86 |
+
business's website strengths can be used to achieve success.
|
87 |
+
"""
|
88 |
+
}]
|
89 |
+
st.session_state["reply"], _ = generate_marketing_plan(website_info, industry, goals, budget, messages)
|
90 |
+
else:
|
91 |
+
st.session_state["reply"] = website_info
|
92 |
|
93 |
# Display results if there is a reply in session state
|
94 |
if st.session_state["reply"]:
|
95 |
with col2:
|
96 |
+
st.markdown("<h2 style='text-align: center; color: black;'>Your 2025 Marketing Plan ⬇️</h2>", unsafe_allow_html=True)
|
97 |
st.write(st.session_state["reply"])
|