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}")