nniehaus commited on
Commit
5436913
·
verified ·
1 Parent(s): 20dd630

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -34
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=500
30
  )
31
 
32
- def CustomChatGPT(home_size, stories, paint_type, paint_cost, labor_cost, business_info, messages):
 
 
 
33
  query = f"""
34
  The user has provided the following details:
35
- - Square footage: {home_size} sqft
36
- - Number of stories: {stories}
37
- - Painting type requested: {paint_type}
38
- - Paint cost per gallon: ${paint_cost}
39
- - Labor cost per hour: ${labor_cost}
40
-
41
- Additional business information: {business_info}
42
 
43
- Provide a detailed cost estimate to paint the home, factoring in the user-specified paint
44
- and labor costs. Include a breakdown for labor, materials, and other expenses. Provide insights
45
- on any factors that might affect the cost.
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;'>Home Painting Cost Estimator with Business Info</h1>", unsafe_allow_html=True)
63
 
64
  # User inputs
65
  col1, col2 = st.columns(2)
66
  with col1:
67
- st.markdown("<h2 style='text-align: center; color: black;'>Enter Home and Cost Details</h2>", unsafe_allow_html=True)
68
- home_size = st.number_input("Square Footage of Home", min_value=100, max_value=10000, step=50)
69
- stories = st.selectbox("Number of Stories", options=["1", "2", "3"])
70
- paint_type = st.selectbox("Type of Painting", options=["Interior", "Exterior", "Both"])
71
- paint_cost = st.number_input("Cost of Paint per Gallon ($)", min_value=1.0, step=0.5)
72
- labor_cost = st.number_input("Labor Cost per Hour ($)", min_value=1.0, step=0.5)
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
- business_info = scrape_website(website_url) if website_url else "No additional business information provided."
79
- messages = [{
80
- "role": "system",
81
- "content": """
82
- You are a detailed home painting cost estimator. Based on provided home details
83
- and optional business information, generate a comprehensive cost estimate.
84
- Include a breakdown for labor, materials, and other expenses, factoring in any
85
- user-provided costs. Offer insights on factors that might affect pricing.
86
- """
87
- }]
88
- st.session_state["reply"], _ = CustomChatGPT(home_size, stories, paint_type, paint_cost, labor_cost, business_info, messages)
 
 
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;'>Estimated Painting Cost ⬇️</h2>", unsafe_allow_html=True)
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"])