Update app.py
Browse files
app.py
CHANGED
|
@@ -1,57 +1,42 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
| 6 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 7 |
|
| 8 |
-
st.title("
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
st.subheader("
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
)
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
)
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
f"Create a detailed lead generation plan for 2024 for a business with the following details: "
|
| 37 |
-
f"Description: {business_description}; Target customers: {target_customers}; "
|
| 38 |
-
f"Advertising budget: {advertising_budget}. Additional details: {additional_details}. "
|
| 39 |
-
"Include specific ad placements, creative opt-in strategies, video marketing ideas, and AI lead generation tools."
|
| 40 |
-
)
|
| 41 |
-
response = openai.ChatCompletion.create(
|
| 42 |
-
model="gpt-4",
|
| 43 |
-
messages=[
|
| 44 |
-
{"role": "system", "content": "You are a marketing expert providing detailed lead generation plans."},
|
| 45 |
-
{"role": "user", "content": prompt}
|
| 46 |
-
],
|
| 47 |
-
max_tokens=700
|
| 48 |
-
)
|
| 49 |
-
return response.choices[0].message['content']
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
if st.button('Generate Lead Generation Plan'):
|
| 53 |
-
plan = generate_lead_generation_plan(
|
| 54 |
-
business_description, target_customers, advertising_budget, additional_details
|
| 55 |
-
)
|
| 56 |
-
st.subheader("Your Customized Lead Generation Plan for 2024:")
|
| 57 |
-
st.write(plan)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
|
|
|
| 3 |
|
| 4 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
| 5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 6 |
|
| 7 |
+
st.title("AI Lead Magnet Recommender for Marketers")
|
| 8 |
|
| 9 |
+
# Collecting user input
|
| 10 |
+
st.subheader("Tell Us About Your Business")
|
| 11 |
+
business_type = st.text_input("Business Type", placeholder="e.g., Real Estate, E-commerce")
|
| 12 |
+
target_audience = st.text_area("Target Audience", placeholder="Describe your primary customer base")
|
| 13 |
+
current_marketing_strategies = st.text_area("Current Marketing Strategies", placeholder="Your current marketing efforts")
|
| 14 |
+
business_goals = st.text_area("Business Goals and Challenges", placeholder="What do you aim to achieve with the lead magnet?")
|
| 15 |
|
| 16 |
+
# Generate recommendations button
|
| 17 |
+
if st.button('Generate AI Lead Magnet Recommendations'):
|
| 18 |
+
# Construct the prompt for the AI
|
| 19 |
+
prompt_text = (
|
| 20 |
+
f"Based on the following details, recommend AI lead magnets suitable for engaging a customer base: "
|
| 21 |
+
f"Business type: {business_type}, target audience: {target_audience}, "
|
| 22 |
+
f"current marketing strategies: {current_marketing_strategies}, business goals: {business_goals}."
|
| 23 |
+
)
|
| 24 |
|
| 25 |
+
# Call the OpenAI API for text generation
|
| 26 |
+
try:
|
| 27 |
+
response_text = openai.ChatCompletion.create(
|
| 28 |
+
model="gpt-4",
|
| 29 |
+
messages=[
|
| 30 |
+
{"role": "system", "content": "You are a marketing expert assistant."},
|
| 31 |
+
{"role": "user", "content": prompt_text}
|
| 32 |
+
]
|
| 33 |
+
)
|
| 34 |
+
recommendations = response_text.choices[0].message['content']
|
| 35 |
+
except Exception as e:
|
| 36 |
+
recommendations = f"Error in generating recommendations: {e}"
|
| 37 |
|
| 38 |
+
# Display the recommendations
|
| 39 |
+
st.markdown("### AI Lead Magnet Recommendations")
|
| 40 |
+
st.write(recommendations)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
# Rest of your Streamlit code...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|