JeCabrera commited on
Commit
4d67c66
·
verified ·
1 Parent(s): c6a5afe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -29
app.py CHANGED
@@ -36,11 +36,10 @@ def get_mention_instruction(product_mention, product):
36
  system_instruction = """
37
  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.
38
  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.'.
39
- IMPORTANT: Only write the bullets. No headers, no explanations, no types of bullets, just the bullets.
40
  """
41
 
42
  # Función para obtener una cantidad de bullets
43
- def get_gemini_response_bullets(target_audience, product, num_bullets, creativity, desired_action):
44
  product_mention = get_random_product_mention()
45
  mention_instruction = get_mention_instruction(product_mention, product) # Define aquí
46
  model_choice = "gemini-1.5-flash" # Modelo por defecto
@@ -50,29 +49,22 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, creativit
50
  # System Prompt - Instrucción en inglés para el modelo
51
  system_instruction = """
52
  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.
53
- Create these bullets to inspire the {target_audience} to take the following action: {desired_action}, capturing readers' attention. 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.'.
54
  """
55
 
56
  # Crear el prompt para generar bullets
57
  full_prompt = f"""
58
  {system_instruction}
59
- Your task is to create {num_bullets} benefits or bullets that connect the symptom with the problem faced by {target_audience}, increasing their curiosity about the {product}.
60
- Infuse your responses with a creativity level of {creativity}. The bullets should be written with the primary focus of driving the reader to take the desired action: {desired_action}.
61
- * 'The bathroom cabinet is the best place to store medicine, right? Incorrect. It's the worst. The facts are on page 10.'
62
- * 'The best verb tense that gives your clients the feeling they've already bought from you.'
63
- * 'The story of...', 'The mysteries of...', 'The legend of...'
64
- * 'A simple system to write copy without trying to convince them to buy.'
65
- * 'The truth that you've never been told in school, or at home, about how to make a living from music.'
66
- * 'Did you know that...'
67
- * '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.'
68
- Use the following mention instructions to guide your writing: {mention_instruction}
69
- 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:
70
- - Direct: Clearly highlight the product as the solution.
71
- - Indirect: Subtly suggest the product without naming it.
72
- - Metaphorical: Use a metaphor to connect the product to the solution.
73
- All bullets must lead towards and emphasize the desired action: {desired_action}.
74
- Please create the bullets now.
75
- Cuando respondas siempre escribe un titular que mencione el público objetivo, el producto de la siguiente manera: 'Aquí tienes 5 bullets para Papás solteros, que aumenten el deseo de adquirir el Aceite multigrado, usando la mención indirecta:'
76
  """
77
 
78
  response = model.generate_content([full_prompt])
@@ -83,11 +75,18 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, creativit
83
  raise ValueError("Lo sentimos, intenta con una combinación diferente de entradas.")
84
 
85
  # Inicializar la aplicación Streamlit
86
- st.set_page_config(page_title="Impact Bullet Generator", layout="wide")
 
 
 
 
 
 
 
87
 
88
  # Centrar el título y el subtítulo
89
- st.markdown("<h1 style='text-align: center;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)
90
- 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)
91
 
92
  # Añadir CSS personalizado para el botón
93
  st.markdown("""
@@ -119,9 +118,6 @@ with col1:
119
  # Campos de entrada
120
  target_audience = st.text_input("¿Quién es tu público objetivo?")
121
  product = st.text_input("¿Qué producto tienes en mente?")
122
-
123
- # Añadir nuevo campo de entrada para la Acción Deseada
124
- desired_action = st.text_input("¿Cuál es la acción deseada?")
125
 
126
  # Campos de personalización sin acordeón
127
  num_bullets = st.slider("Número de Bullets", min_value=1, max_value=15, value=5)
@@ -135,14 +131,14 @@ if submit:
135
  if target_audience and product:
136
  try:
137
  # Obtener la respuesta del modelo
138
- generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, creativity, desired_action)
139
  col2.markdown(f"""
140
  <div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
141
- <h4>Mira la magia en acción:</h4>
142
  <p>{generated_bullets}</p>
143
  </div>
144
  """, unsafe_allow_html=True)
145
  except ValueError as e:
146
  col2.error(f"Error: {str(e)}")
147
  else:
148
- col2.error("Por favor, proporciona el público objetivo y el producto.")
 
36
  system_instruction = """
37
  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.
38
  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.'.
 
39
  """
40
 
41
  # Función para obtener una cantidad de bullets
42
+ def get_gemini_response_bullets(target_audience, product, num_bullets, creativity):
43
  product_mention = get_random_product_mention()
44
  mention_instruction = get_mention_instruction(product_mention, product) # Define aquí
45
  model_choice = "gemini-1.5-flash" # Modelo por defecto
 
49
  # System Prompt - Instrucción en inglés para el modelo
50
  system_instruction = """
51
  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.
52
+ Generate unusual, creative, and fascinating bullets that subtly hint at the product without direct mention, capturing readers' attention. 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.'.
53
  """
54
 
55
  # Crear el prompt para generar bullets
56
  full_prompt = f"""
57
  {system_instruction}
58
+ 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}.
59
+ Infuse your responses with a creativity level of {creativity}. The bullets should be of the following types:
60
+ * 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.'
61
+ * The Best/The Worst: 'The best verb tense that gives your clients the feeling they've already bought from you.'
62
+ * Stories: 'The story of...', 'The mysteries of...', 'The legend of...'
63
+ * Trick: 'A simple system to write copy without trying to convince them to buy.'
64
+ * The Truth: 'The truth that you've never been told in school, or at home, about how to make a living from music.'
65
+ * Asking a Question: 'Did you know that...'
66
+ * 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.'
67
+ Using {mention_instruction} when you want to mention {product}.
 
 
 
 
 
 
 
68
  """
69
 
70
  response = model.generate_content([full_prompt])
 
75
  raise ValueError("Lo sentimos, intenta con una combinación diferente de entradas.")
76
 
77
  # Inicializar la aplicación Streamlit
78
+ st.set_page_config(page_title="Generador de Bullets", layout="wide")
79
+
80
+ # Inicializar el estado de la expansión del acordeón
81
+ if "accordion_expanded" not in st.session_state:
82
+ st.session_state["accordion_expanded"] = False
83
+
84
+ def toggle_accordion():
85
+ st.session_state["accordion_expanded"] = not st.session_state["accordion_expanded"]
86
 
87
  # Centrar el título y el subtítulo
88
+ st.markdown("<h1 style='text-align: center;'>Generador de Bullets</h1>", unsafe_allow_html=True)
89
+ st.markdown("<h4 style='text-align: center;'>Crea bullets efectivos que conecten emocionalmente con tu audiencia.</h4>", unsafe_allow_html=True)
90
 
91
  # Añadir CSS personalizado para el botón
92
  st.markdown("""
 
118
  # Campos de entrada
119
  target_audience = st.text_input("¿Quién es tu público objetivo?")
120
  product = st.text_input("¿Qué producto tienes en mente?")
 
 
 
121
 
122
  # Campos de personalización sin acordeón
123
  num_bullets = st.slider("Número de Bullets", min_value=1, max_value=15, value=5)
 
131
  if target_audience and product:
132
  try:
133
  # Obtener la respuesta del modelo
134
+ generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, creativity)
135
  col2.markdown(f"""
136
  <div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
137
+ <h4>Aquí están tus bullets:</h4>
138
  <p>{generated_bullets}</p>
139
  </div>
140
  """, unsafe_allow_html=True)
141
  except ValueError as e:
142
  col2.error(f"Error: {str(e)}")
143
  else:
144
+ col2.error("Por favor, proporciona el público objetivo y el producto.")