File size: 6,533 Bytes
d51e47b
232fce4
 
 
 
d51e47b
ad8bd78
d51e47b
 
ad8bd78
232fce4
 
1a5dff6
 
 
232fce4
1a5dff6
 
 
 
 
d7768e9
1a5dff6
d7768e9
1a5dff6
d7768e9
d3d375d
 
ad8bd78
c90367c
1e3cd7b
1c22de8
ad8bd78
 
232fce4
d7768e9
1a5dff6
ad8bd78
232fce4
 
 
1e3cd7b
232fce4
ad8bd78
4d67c66
 
 
 
 
 
 
 
 
83edbb2
 
 
232fce4
 
 
 
 
 
 
1a5dff6
232fce4
 
4d67c66
 
232fce4
4d67c66
 
232fce4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50f0928
232fce4
 
 
 
 
 
 
 
 
 
 
 
 
 
1619f38
 
1a5dff6
1619f38
232fce4
1727cae
 
d7768e9
232fce4
1619f38
d51e47b
232fce4
 
ae5ef0d
232fce4
 
ae5ef0d
ad8bd78
232fce4
ae5ef0d
dc18796
232fce4
ad8bd78
232fce4
 
 
ae5ef0d
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from dotenv import load_dotenv
import streamlit as st
import os
import google.generativeai as genai
import random

# Cargar las variables de entorno
load_dotenv()

# Configurar la API de Google
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))

# Funci贸n para obtener una llamada a la acci贸n de manera probabil铆stica
def get_random_call_to_action():
    actions = ["Directo", "Sutil", "Indirecto"]
    probabilities = [0.34, 0.33, 0.33]  
    return random.choices(actions, probabilities)[0]

# Crear la instrucci贸n para la llamada a la acci贸n seg煤n la opci贸n seleccionada
def get_call_to_action_instruction(action_call):
    if action_call == "Directo":
        return "Incorpora una llamada a la acci贸n clara y directa que motive al lector a actuar de inmediato. La llamada debe ser convincente y destacar la urgencia de tomar acci贸n."
    elif action_call == "Sutil":
        return "Sugiere una llamada a la acci贸n de manera sutil, insinuando los beneficios de actuar sin ser demasiado obvio. El lector debe sentir que est谩 tomando la decisi贸n por su cuenta."
    elif action_call == "Indirecto":
        return "Presenta una llamada a la acci贸n de forma indirecta, creando un escenario donde el lector pueda ver la acci贸n como una soluci贸n natural a sus problemas sin nombrarla expl铆citamente."
    return ""

# System Prompt - Instrucci贸n en ingl茅s para el modelo
system_instruction = """
You are a world-class copywriter, expert in creating benefits that connect symptoms with problems. You deeply understand the emotions, desires, and challenges of a specific audience, allowing you to design personalized marketing strategies that resonate and motivate action. You know how to use proven structures to attract your target audience, generating interest and creating a powerful connection.
Generate unusual, creative, and fascinating bullets that capture readers' attention about the product. Respond in Spanish and use a numbered list format. Important: Only answer bullets, never include explanations or categories, like this: 'La leyenda del padre soltero: Dice que nunca hay tiempo suficiente. El yoga te ense帽a a usar mejor el tiempo que tienes, incluso cuando te parece imposible.'.
"""

# Funci贸n para obtener una cantidad de bullets
def get_gemini_response_bullets(target_audience, num_bullets, creativity, action_call):
    call_to_action_instruction = get_call_to_action_instruction(action_call)  # Definir la instrucci贸n aqu铆
    model_choice = "gemini-1.5-flash"  # Modelo por defecto

    model = genai.GenerativeModel(model_choice)

    # Crear el prompt para generar bullets
    full_prompt = f"""
    {system_instruction}
    Your task is to create {num_bullets} benefits or bullets that connect the symptom with the problem faced by {target_audience}, increasing their desire to acquire the {product}. 
    Infuse your responses with a creativity level of {creativity}. The bullets should be of the following types: 
    * Good and Bad: 'The bathroom cabinet is the best place to store medicine, right? Incorrect. It's the worst. The facts are on page 10.' 
    * The Best/The Worst: 'The best verb tense that gives your clients the feeling they've already bought from you.' 
    * Stories: 'The story of...', 'The mysteries of...', 'The legend of...' 
    * Trick: 'A simple system to write copy without trying to convince them to buy.' 
    * The Truth: 'The truth that you've never been told in school, or at home, about how to make a living from music.' 
    * Asking a Question: 'Did you know that...' 
    * When: 'When is it a good idea to tell a girl you like her? If you don't say it at that moment, say goodbye to getting to know her intimately.' 
    Use the following mention instructions to guide your writing: {call_to_action_instruction}
    Additionally, subtly mention the product '{product}' in the bullets without making it the focus. The connection between the action and the product should feel organic and seamless.
    Please create the bullets now.
    """

    response = model.generate_content([full_prompt])

    if response and response.parts:
        return response.parts[0].text
    else:
        raise ValueError("Lo siento, intenta con una combinaci贸n diferente de valores.")

# Inicializar la aplicaci贸n Streamlit
st.set_page_config(page_title="Generador de Bullets", layout="wide")

# Centrar el t铆tulo y el subt铆tulo
st.markdown("<h1 style='text-align: center;'>Generador de Bullets</h1>", unsafe_allow_html=True)
st.markdown("<h4 style='text-align: center;'>Crea bullets efectivos que conecten emocionalmente con tu audiencia.</h4>", unsafe_allow_html=True)

# A帽adir CSS personalizado para el bot贸n
st.markdown("""
    <style>
    div.stButton > button {
        background-color: #FFCC00;
        color: black;
        width: 90%;
        height: 60px;
        font-weight: bold;
        font-size: 22px;
        text-transform: uppercase;
        border: 1px solid #000000;
        border-radius: 8px;
        display: block;
        margin: 0 auto;
    }
    div.stButton > button:hover {
        background-color: #FFD700;
        color: black;
    }
    </style>
    """, unsafe_allow_html=True)

# Crear dos columnas para el layout (40% y 60%)
col1, col2 = st.columns([2, 3])

with col1:
    # Campos de entrada
    target_audience = st.text_input("驴Qui茅n es tu p煤blico objetivo?")
    product = st.text_input("驴Qu茅 producto tienes en mente?")
    
    # Campos de personalizaci贸n sin acorde贸n
    num_bullets = st.slider("N煤mero de Bullets", min_value=1, max_value=10, value=5)
    creativity = st.selectbox("Creatividad", ["Alta", "Media", "Baja"])

    # Campo para la llamada a la acci贸n
    action_call = st.text_input("驴Qu茅 CTA quieres?")

    # Bot贸n de enviar
    submit = st.button("Generar Bullets")

# Mostrar los bullets generados
if submit:
    if target_audience:
        try:
            # Obtener la respuesta del modelo
            generated_bullets = get_gemini_response_bullets(target_audience, num_bullets, creativity, action_call)
            col2.markdown(f"""
                <div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
                    <h4>Mira la magia:</h4>
                    <p>{generated_bullets}</p>
                </div>
            """, unsafe_allow_html=True)
        except ValueError as e:
            col2.error(f"Error: {str(e)}")
    else:
        col2.error("Por favor, proporciona el p煤blico objetivo y el producto.")