Spaces:
Running
Running
File size: 2,763 Bytes
bd77c8d b9ba5dd bd77c8d 3e410e7 b9ba5dd bd77c8d 05cfe90 bd77c8d 05a5ccf bd77c8d |
1 2 3 4 5 6 7 8 9 10 11 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import streamlit as st
import requests
# Set Streamlit page config
st.set_page_config(page_title="π TrendWhiz", page_icon="π―")
st.title("π TrendWhiz")
st.markdown("AI-Powered Content & Campaign Idea Generator π")
# User Inputs
brand = st.text_input("π Brand or Product Name")
audience = st.selectbox(
"π― Target Audience",
("Gen Z (18-24)", "Millennials (25-40)", "Gen X (41-56)", "Boomers (57+)", "Parents", "Students", "Professionals")
)
platform = st.selectbox(
"π± Social Media Platform",
("Instagram", "Facebook", "TikTok", "YouTube", "LinkedIn", "Pinterest", "Twitter / X")
)
goal = st.text_area("π― Campaign Goal", placeholder="e.g., Increase brand awareness, drive engagement...")
# Groq API Key (Put your key here or use Streamlit secrets)
GROQ_API_KEY = st.secrets.get("GROQ_API_KEY")
# Function to call Groq API with Llama3
def generate_campaign_ideas(brand, audience, platform, goal):
url = "https://api.groq.com/openai/v1/chat/completions"
headers = {
"Authorization": f"Bearer {GROQ_API_KEY}",
"Content-Type": "application/json"
}
data = {
"model": "llama3-70b-8192",
"messages": [
{
"role": "system",
"content": "You are a professional social media marketing expert. Generate exactly 5 unique, creative, and actionable campaign ideas. Each idea should suggest post formats, influencer collaboration, and engagement tips. Use fun and engaging language with emojis."
},
{
"role": "user",
"content": f"""Generate exactly 5 creative social media campaign ideas for brand '{brand}', targeting '{audience}' on '{platform}'.
Goal: {goal}.
Format ideas clearly as:
1. π― Idea 1...
2. π Idea 2...
3. π Idea 3...
4. π Idea 4...
5. π‘ Idea 5...
Each idea must be actionable and unique."""
}
],
"temperature": 0.7,
"max_tokens": 800,
"top_p": 0.95
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
return result['choices'][0]['message']['content']
# Generate Button
if st.button("β¨ Generate Campaign Ideas"):
if not brand or not goal:
st.warning("β οΈ Please enter both the Brand Name and Campaign Goal.")
else:
with st.spinner("π‘ Generating creative ideas... please wait..."):
try:
output = generate_campaign_ideas(brand, audience, platform, goal)
st.success("π Generated 5 unique campaign ideas!")
st.markdown(output)
st.balloons()
except Exception as e:
st.error(f"β οΈ Error: {e}")
|