JeCabrera commited on
Commit
c66c797
·
verified ·
1 Parent(s): d794586

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -70
app.py CHANGED
@@ -63,22 +63,21 @@ def generate_headlines(number_of_headlines, target_audience, product, temperatur
63
  product=product
64
  )
65
 
66
- system_prompt = """You are a world-class copywriter specialized in writing headlines, hooks, and subject lines that capture attention fast and spark curiosity.
67
 
68
  FORMAT RULES:
69
- - Each headline must start with number and period
70
- - One headline per line
71
- - No explanations or categories
72
- - Add a line break between each headline
73
- - Avoid unnecessary : symbols
74
- - Each headline must be a complete and intriguing sentence
75
-
76
- IMPORTANT:
77
- - Each headline must be unique and memorable
78
- - Avoid clichés and generalities
79
- - Maintain an intriguing but credible tone
80
- - Adapt speaking language from the audience
81
- - Focus on transformative benefits
82
  """
83
 
84
  headlines_instruction = f"{system_prompt}\n\n"
@@ -86,91 +85,63 @@ IMPORTANT:
86
  if selected_angle != "NINGUNO":
87
  headlines_instruction += f"""
88
  ÁNGULO PRINCIPAL: {selected_angle}
89
- Aplica este ángulo como una capa de estilo sobre la fórmula, sin alterar su estructura base.
90
 
91
- INSTRUCCIONES DE ÁNGULO ESPECÍFICAS:
92
  {context["angle_instruction"]}
93
 
94
- EJEMPLOS EXITOSOS DEL ÁNGULO {selected_angle}:
95
  """
96
  for example in context["angle_examples"]:
97
  headlines_instruction += f"- {example}\n"
98
 
99
  headlines_instruction += (
100
- f"\nTu tarea es crear {number_of_headlines} titulares irresistibles para {target_audience} "
101
- f"que capturen la atención instantáneamente y generen curiosidad sobre {product}. "
102
- )
103
-
104
- headlines_instruction += (
105
- f"Antes de escribir, determina quién es realmente {target_audience}: "
106
- f"qué desea, qué le frustra, qué objeciones tiene, qué transformación busca y cómo suele pensar o hablar sobre este problema. "
107
- f"Usa esa comprensión para que cada titular conecte con su situación de forma natural y relevante.\n\n"
108
- )
109
-
110
- if selected_angle != "NINGUNO":
111
- headlines_instruction += (
112
- f"IMPORTANTE: Cada titular DEBE seguir el ángulo {selected_angle} de manera clara y consistente.\n\n"
113
- )
114
-
115
- headlines_instruction += (
116
- f"No dependas de mencionar explícitamente {product} para generar interés genuino"
117
  )
118
 
119
  if selected_angle != "NINGUNO":
120
- headlines_instruction += " usando el ángulo seleccionado"
121
 
122
  headlines_instruction += ".\n\n"
123
 
124
- headlines_instruction += "GUÍA ADICIONAL:\n"
125
- for rule in context["extra_guidance"]:
126
- headlines_instruction += f"- {rule}\n"
127
- headlines_instruction += "\n"
128
-
129
  headlines_instruction += (
130
- "IMPORTANTE: Estudia cuidadosamente estos ejemplos de la fórmula seleccionada. "
131
- "Cada ejemplo representa el estilo y estructura a seguir"
 
132
  )
133
 
134
- if selected_angle != "NINGUNO":
135
- headlines_instruction += f", adaptados al ángulo {selected_angle}"
136
-
137
- headlines_instruction += ":\n\n"
138
 
139
  random_examples = context["formula_examples"]
140
 
141
- headlines_instruction += "EJEMPLOS DE LA FÓRMULA A SEGUIR:\n"
 
 
 
142
  for i, example in enumerate(random_examples, 1):
143
  headlines_instruction += f"{i}. {example}\n"
144
 
145
- headlines_instruction += "\nINSTRUCCIONES ESPECÍFICAS:\n"
146
- headlines_instruction += "1. Mantén una estructura y longitud similares a las de los ejemplos anteriores\n"
147
- headlines_instruction += "2. Conserva el nivel de especificidad y detalle\n"
148
- headlines_instruction += "3. Inspírate en los patrones de construcción sin copiarlos literalmente\n"
149
- headlines_instruction += "4. Haz que cada titular suene natural para el público objetivo\n"
150
- headlines_instruction += "5. Asegúrate de que cada titular sea claro, atractivo y creíble\n\n"
151
 
152
- headlines_instruction += f"FÓRMULA A SEGUIR:\n{context['formula_description']}\n\n"
 
 
153
 
154
  if selected_angle != "NINGUNO":
155
- headlines_instruction += f"""
156
- RECORDATORIO FINAL:
157
- 1. Sigue la estructura de la fórmula seleccionada
158
- 2. Aplica el ángulo como una capa de estilo
159
- 3. Mantén la coherencia entre fórmula y ángulo
160
- 4. Asegura que cada titular refleje ambos elementos
161
-
162
- GENERA AHORA:
163
- Crea {number_of_headlines} titulares que sigan fielmente la estructura de la fórmula y mantengan la esencia de los ejemplos mostrados.
164
- """
165
- else:
166
- headlines_instruction += f"""
167
- GENERA AHORA:
168
- Crea {number_of_headlines} titulares que sigan fielmente la estructura de la fórmula y mantengan la esencia de los ejemplos mostrados.
169
- """
170
 
171
  response = client.models.generate_content(
172
  model="gemini-2.5-flash-lite",
173
- contents=headlines_instruction + "\n\nGenera titulares originales que respeten la estructura de la fórmula seleccionada, apliquen el ángulo elegido y mantengan la esencia de los ejemplos sin copiarlos literalmente.",
174
  config=types.GenerateContentConfig(
175
  temperature=temperature,
176
  top_p=0.65,
 
63
  product=product
64
  )
65
 
66
+ system_prompt = """You are a world-class copywriter specialized in writing headlines, hooks, and subject lines that capture attention quickly and spark genuine curiosity.
67
 
68
  FORMAT RULES:
69
+ - Each headline must start with a number and period
70
+ - Write one headline per line
71
+ - Do not add explanations or categories
72
+ - Avoid unnecessary symbols
73
+ - Each headline must feel complete, intriguing, and natural
74
+
75
+ CORE RULES:
76
+ - Each headline must be unique
77
+ - Avoid clichés and generic language
78
+ - Keep the tone intriguing but credible
79
+ - Use language that feels natural for the target audience
80
+ - Focus on clear and desirable benefits
 
81
  """
82
 
83
  headlines_instruction = f"{system_prompt}\n\n"
 
85
  if selected_angle != "NINGUNO":
86
  headlines_instruction += f"""
87
  ÁNGULO PRINCIPAL: {selected_angle}
88
+ Usa este ángulo como una capa de estilo. Modifica cómo se expresa el titular, no la estructura de la fórmula.
89
 
90
+ INSTRUCCIÓN DEL ÁNGULO:
91
  {context["angle_instruction"]}
92
 
93
+ EJEMPLOS DEL ÁNGULO:
94
  """
95
  for example in context["angle_examples"]:
96
  headlines_instruction += f"- {example}\n"
97
 
98
  headlines_instruction += (
99
+ f"\nTu tarea es crear {number_of_headlines} titulares para {target_audience} "
100
+ f"sobre {product}, usando la fórmula seleccionada"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  )
102
 
103
  if selected_angle != "NINGUNO":
104
+ headlines_instruction += f" y el ángulo {selected_angle}"
105
 
106
  headlines_instruction += ".\n\n"
107
 
 
 
 
 
 
108
  headlines_instruction += (
109
+ f"Antes de escribir, piensa en {target_audience} como personas reales: "
110
+ f"qué desean, qué les frustra, qué objeciones tienen y qué transformación buscan. "
111
+ f"Haz que cada titular conecte con esa realidad de forma natural.\n\n"
112
  )
113
 
114
+ headlines_instruction += (
115
+ f"No dependas de mencionar explícitamente {product} para generar interés.\n\n"
116
+ )
 
117
 
118
  random_examples = context["formula_examples"]
119
 
120
+ headlines_instruction += "FÓRMULA:\n"
121
+ headlines_instruction += f"{context['formula_description']}\n\n"
122
+
123
+ headlines_instruction += "EJEMPLOS:\n"
124
  for i, example in enumerate(random_examples, 1):
125
  headlines_instruction += f"{i}. {example}\n"
126
 
127
+ headlines_instruction += "\nREGLAS DE GENERACIÓN:\n"
128
+ headlines_instruction += "- Mantén una estructura y longitud similares a las de los ejemplos\n"
129
+ headlines_instruction += "- Conserva la especificidad y el nivel de detalle\n"
130
+ headlines_instruction += "- Inspírate en los patrones sin copiar literalmente\n"
131
+ headlines_instruction += "- Haz que cada titular suene natural, claro y creíble\n\n"
 
132
 
133
+ headlines_instruction += (
134
+ f"Genera ahora {number_of_headlines} titulares originales que respeten la estructura de la fórmula"
135
+ )
136
 
137
  if selected_angle != "NINGUNO":
138
+ headlines_instruction += f" y apliquen el ángulo {selected_angle}"
139
+
140
+ headlines_instruction += ".\n"
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  response = client.models.generate_content(
143
  model="gemini-2.5-flash-lite",
144
+ contents=headlines_instruction + "\n\nEscribe los titulares ahora.",
145
  config=types.GenerateContentConfig(
146
  temperature=temperature,
147
  top_p=0.65,