Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 67 |
|
| 68 |
FORMAT RULES:
|
| 69 |
-
- Each headline must start with number and period
|
| 70 |
-
-
|
| 71 |
-
-
|
| 72 |
-
-
|
| 73 |
-
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
-
|
| 78 |
-
-
|
| 79 |
-
-
|
| 80 |
-
-
|
| 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 |
-
|
| 90 |
|
| 91 |
-
|
| 92 |
{context["angle_instruction"]}
|
| 93 |
|
| 94 |
-
EJEMPLOS
|
| 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
|
| 101 |
-
f"
|
| 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 += "
|
| 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 |
-
"
|
| 131 |
-
"
|
|
|
|
| 132 |
)
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
headlines_instruction += ":\n\n"
|
| 138 |
|
| 139 |
random_examples = context["formula_examples"]
|
| 140 |
|
| 141 |
-
headlines_instruction += "
|
|
|
|
|
|
|
|
|
|
| 142 |
for i, example in enumerate(random_examples, 1):
|
| 143 |
headlines_instruction += f"{i}. {example}\n"
|
| 144 |
|
| 145 |
-
headlines_instruction += "\
|
| 146 |
-
headlines_instruction += "
|
| 147 |
-
headlines_instruction += "
|
| 148 |
-
headlines_instruction += "
|
| 149 |
-
headlines_instruction += "
|
| 150 |
-
headlines_instruction += "5. Asegúrate de que cada titular sea claro, atractivo y creíble\n\n"
|
| 151 |
|
| 152 |
-
headlines_instruction +=
|
|
|
|
|
|
|
| 153 |
|
| 154 |
if selected_angle != "NINGUNO":
|
| 155 |
-
headlines_instruction += f""
|
| 156 |
-
|
| 157 |
-
|
| 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\
|
| 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,
|