File size: 9,143 Bytes
6cbfd9d
 
 
 
 
 
 
 
 
 
 
 
b9934d5
 
 
 
 
 
 
7531340
6cbfd9d
 
 
b250bba
6cbfd9d
 
 
 
1c38693
7531340
 
b250bba
 
 
af65d5e
7531340
b250bba
 
 
af65d5e
b250bba
7531340
 
 
 
b250bba
7531340
 
1c38693
7531340
 
1c38693
 
 
 
 
b250bba
6cbfd9d
b250bba
6cbfd9d
7531340
6cbfd9d
 
 
 
 
b250bba
 
 
 
1c38693
f319c1c
 
 
 
 
 
 
6cbfd9d
 
 
 
 
 
b250bba
 
 
 
1c38693
6cbfd9d
 
 
 
b250bba
 
 
 
 
 
 
 
 
7531340
b250bba
 
 
 
6cbfd9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9934d5
1c38693
6cbfd9d
 
 
 
e411757
 
 
 
232fce4
1c38693
ad8bd78
232fce4
3d42c0e
e411757
232fce4
ad8bd78
e411757
 
 
346ec34
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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 que genera descripciones de menciones usando el producto como variable
def mention_descriptions(product):
    return {
        "Directa": f"Introduce el producto '{product}' como la soluci贸n clara al problema que enfrenta el lector.",
        "Indirecta": f"Referencia el producto '{product}' como una posible soluci贸n sin nombrarlo expl铆citamente.",
        "Metaf贸rica": f"Usa una met谩fora para conectar el producto '{product}' con la soluci贸n necesaria."
    }

# Funci贸n para obtener una menci贸n del producto de manera probabil铆stica
def get_random_product_mention():
    mentions = ["Directa", "Indirecta", "Metaf贸rica"]
    probabilities = [0.25, 0.35, 0.40]  
    return random.choices(mentions, probabilities)[0]

# Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
def get_mention_instruction(product_mention, product):
    mention_descriptions = mention_descriptions(product)  # Llamar la funci贸n con el producto
    examples = {
        "Directa": [
            f"Este curso de ingl茅s te proporcionar谩 las herramientas necesarias para abrir nuevas oportunidades laborales.",
            f"Con este curso de ingl茅s, transforma tu carrera y tu vida familiar.",
            f"No permitas que la falta de ingl茅s limite tu futuro; inscr铆bete y empieza a disfrutar de m谩s tiempo con tus peque帽os."
        ],
        "Indirecta": [
            f"Imagina tener la confianza hablando un idioma diferente para brillar en tus reuniones de trabajo.",
            f"El mejor regalo que puedes darles a tus hijos es su crecimiento profesional dandoles herramientas como otros idiomas.",
            f"Visualiza c贸mo tus peque帽os se sentir谩n orgullosos al verte alcanzar esa promoci贸n por hablar en otro idioma."
        ],
        
        "Metaf贸rica": [
            f"Aprender ingl茅s es como lanzarse a la piscina, al principio puede dar un poco de miedo, en el webinar te ense帽are como sumergirte para descubrir un mundo nuevo lleno de oportunidades que antes parec铆an inaccesibles.",
            f"Hablar ingl茅s es tu br煤jula en el oc茅ano laboral para navegar hacia esas rutas que solo parec铆an estar disponibles para biling眉es.",
            f"Dominar el ingl茅s es encender una luz en la oscuridad que te permite ver otras oportunidades laborales."
        ]
    }

    # Retornar la descripci贸n de la menci贸n seleccionada junto con ejemplos
    return f"{mention_descriptions[product_mention]} Ejemplos: {', '.join(examples[product_mention])}"

# Funci贸n que obtiene una instrucci贸n aleatoria de menci贸n
def get_random_mention_instruction(product):
    mention_type = get_random_product_mention()  # Obtener tipo de menci贸n aleatoria
    mention_instruction = get_mention_instruction(mention_type, product)  # Obtener instrucci贸n con base en el producto y tipo de menci贸n
    return mention_instruction
    
# Funci贸n para obtener una cantidad de bullets
def generate_bullets(number_of_bullets, target_audience, product, temperature):
    product_mention = get_random_product_mention()
    mention_instruction = get_mention_instruction(product_mention, product)  # Get mention instruction
    model_choice = "gemini-1.5-flash"  # Modelo por defecto

    model = genai.GenerativeModel(model_choice)

    # System Prompt - Instrucci贸n en ingl茅s para el modelo
    system_instruction = f"""
    You are a world-class copywriter, expert in creating benefits that connect symptoms with problems of {target_audience}. You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized copywriting that resonate and motivate action. You know how to use proven structures to attract your {target_audience}, generating interest and creating a powerful connection with {product}. 
    Respond in Spanish and use a numbered list format. Important: 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.'.
    Your task is to create 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 that aligns with the specified temperature of {temperature}, leveraging the imaginative capabilities of the Gemini 1.5 Flash model to produce innovative and boundary-pushing ideas. The bullets should be of the following types: 
    * 'The bathroom cabinet is the best place to store medicine, right? Incorrect. It's the worst. The facts are on page 10.' 
    * 'The best verb tense that gives your clients the feeling they've already bought from you.' 
    * 'The story of...', 'The mysteries of...', 'The legend of...' 
    * 'A simple system to write copy without trying to convince them to buy.' 
    * Truth: 'The truth that you've never been told in school, or at home, about how to make a living from music.' 
    * 'Did you know that...' 
    * '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.' 
    Using {mention_instruction} when you want to mention {product}.
    Use the following mention instructions to guide your writing: {mention_instruction}
    Using the mention type '{product_mention}' to guide how to mention the product in the benefits or bullets. Ensure the mention is adapted based on this type:
    - Direct: Clearly highlight the product as the solution.
    - Indirect: Subtly suggest the product without naming it.
    - Metaphorical: Use a metaphor to connect the product to the solution.
   """

    # Crear el prompt para generar bullets
    full_prompt = f"""
    Write {number_of_bullets} unusual, creative, and fascinating bullets that capturing readers' attention. 
    When responding, always include a headline that references the {target_audience} and the product in the following way: 'Aqu铆 tienes 5 bullets para Pap谩s solteros, que aumenten el deseo de adquirir el Aceite multigrado, usando la menci贸n indirecta:' 
    Please create the bullets now.
    """

    try:
        response = model.generate_content([full_prompt])
        
        # Extract text from the response
        generated_bullets = response.candidates[0].content.parts[0].text.strip()
        
        return generated_bullets
    except Exception as e:
        raise ValueError(f"Tuvimos este error al generar los bullets: {str(e)}")
        
# Example usage
if __name__ == "__main__":
    bullets = generate_bullets(5, "target audience", "product name", 0.7)
    print(bullets)

# 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;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)
st.markdown("<h4 style='text-align: center;'>Transforma los pensamientos de tu audiencia en balas persuasivas que inspiren a la acci贸n.</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)
    tempeture = st.selectbox("Creatividad", ["Alta", "Media", "Baja"])

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

# Mostrar los bullets generados
if submit:
    if target_audience and product:
        try:
            # Obtener la respuesta del modelo
            generated_bullets = generate_bullets(number_of_bullets, target_audience, product, tempeture)
            col2.markdown(f"""
                <div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
                    <h4>Observa la magia en acci贸n:</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.")