Spaces:
Sleeping
Sleeping
Update app.py
Browse files37 unmodified lines383940414243444546474849505152535455565719 unmodified lines77787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471 unmodified line14915015115215315417 unmodified lines17217317417517617717816 unmodified lines19519619719819920020115 unmodified lines21721821922022122222322413 unmodified lines23823924024124224324437 unmodified linesangle_instruction = angles[selected_angle].get("instruction", "").strip()angle_examples = angles[selected_angle].get("examples", [])[:3]extra_guidance = [f"Escribe para {target_audience} como personas reales, no como una categoría genérica.",f"Piensa en qué desea ese público, qué le frustra, qué objeciones tiene y qué transformación busca en relación con {product}.","No copies literalmente los ejemplos.","Haz que cada titular sea claro, atractivo y creíble.","No dependas de mencionar explícitamente el producto para generar interés."]return {"formula_description": formula_description,"formula_examples": random_examples,"angle_instruction": angle_instruction,"angle_examples": angle_examples,"extra_guidance": extra_guidance}19 unmodified lines- Avoid clichés and generic language- Keep the tone intriguing but credible- Use language that feels natural for the target audience- Focus on clear and desirable benefits"""headlines_instruction = f"{system_prompt}\n\n"if selected_angle != "NINGUNO":headlines_instruction += f"""ÁNGULO PRINCIPAL: {selected_angle}Usa este ángulo como una capa de estilo. Modifica cómo se expresa el titular, no la estructura de la fórmula.INSTRUCCIÓN DEL ÁNGULO:{context["angle_instruction"]}EJEMPLOS DEL ÁNGULO:"""for example in context["angle_examples"]:headlines_instruction += f"- {example}\n"headlines_instruction += (f"\nTu tarea es crear {number_of_headlines} titulares para {target_audience} "f"sobre {product}, usando la fórmula seleccionada")if selected_angle != "NINGUNO":headlines_instruction += f" y el ángulo {selected_angle}"headlines_instruction += ".\n\n"headlines_instruction += (f"Antes de escribir, piensa en {target_audience} como personas reales: "f"qué desean, qué les frustra, qué objeciones tienen y qué transformación buscan. "f"Haz que cada titular conecte con esa realidad de forma natural.\n\n")headlines_instruction += (f"No dependas de mencionar explícitamente {product} para generar interés.\n\n")random_examples = context["formula_examples"]headlines_instruction += "FÓRMULA:\n"headlines_instruction += f"{context['formula_description']}\n\n"headlines_instruction += "EJEMPLOS:\n"for i, example in enumerate(random_examples, 1):headlines_instruction += f"{i}. {example}\n"headlines_instruction += "\nREGLAS DE GENERACIÓN:\n"headlines_instruction += "- Mantén una estructura y longitud similares a las de los ejemplos\n"headlines_instruction += "- Conserva la especificidad y el nivel de detalle\n"headlines_instruction += "- Inspírate en los patrones sin copiar literalmente\n"headlines_instruction += "- Haz que cada titular suene natural, claro y creíble\n\n"headlines_instruction += (f"Genera ahora {number_of_headlines} titulares originales que respeten la estructura de la fórmula")if selected_angle != "NINGUNO":headlines_instruction += f" y apliquen el ángulo {selected_angle}"headlines_instruction += ".\n"response = client.models.generate_content(model="gemini-2.5-flash-lite",contents=headlines_instruction + "\n\nEscribe los titulares ahora.",config=types.GenerateContentConfig(temperature=temperature,top_p=0.65,1 unmodified line),)return response.text17 unmodified lines# Centrar el título y el subtítulost.markdown("<h1 style='text-align: center;'>Enchanted Hooks</h1>", unsafe_allow_html=True)st.markdown("<h4 style='text-align: center;'>Imagina poder conjurar títulos que no solo informan, sino que encantan. Esta app es tu varita mágica en el mundo del copywriting, transformando cada concepto en un titular cautivador que deja a todos deseando más.</h4>",unsafe_allow_html=True)16 unmodified linesindex=4)# Crear un único acordeón para fórmula, creatividad y ángulowith st.expander("Personaliza tus titulares"):temperature = st.slider("Creatividad",15 unmodified lines)selected_formula = headline_formulas[selected_formula_key]# Botón de enviarsubmit = st.button("Generar Titulares")# Mostrar los titulares generados13 unmodified linesselected_angle)formatted_headlines = generated_headlines.replace("\n", "<br>")col2.markdown(f"""37 unmodified lines383940414243444546474819 unmodified lines68697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751 unmodified line17717817918018118218318418517 unmodified lines20320420520620720820916 unmodified lines22622722822923023115 unmodified lines24724824925025125213 unmodified lines26626726826927027127237 unmodified linesangle_instruction = angles[selected_angle].get("instruction", "").strip()angle_examples = angles[selected_angle].get("examples", [])[:3]return {"formula_description": formula_description,"formula_examples": random_examples,"angle_instruction": angle_instruction,"angle_examples": angle_examples}19 unmodified lines- Avoid clichés and generic language- Keep the tone intriguing but credible- Use language that feels natural for the target audience- Focus on clear and desirable outcomesANGLE RULES:- The selected angle must be applied to every headline- The formula provides the structure- The angle provides the style- The angle changes how the headline is expressed, not the structure itselfAVATAR REALITY RULES:- Write headlines based on real-life situations the audience experiences- Focus on specific moments, problems, obstacles, or daily scenarios- Each headline must describe something the audience can immediately recognize- Every headline must feel like something that happens on a real day- Write scenes, not concepts- Show what is happening, when it happens, or why it mattersAVOID ABSTRACT PROMISES LIKE:- improve- transform- master- dominate- optimizeBAD EXAMPLES:- Improve your cooking skills- Transform your meals- Master the kitchenThese are too generic because they describe outcomes without showing a real situation.GOOD EXAMPLES:- Cook something decent when you get home tired and don't know what to prepare- Prepare dinner fast when unexpected guests arrive- Stop ordering takeout every time you run out of ideas"""headlines_instruction = f"{system_prompt}\n\n"if selected_angle != "NINGUNO":headlines_instruction += f"""SELECTED ANGLE: {selected_angle}ANGLE INSTRUCTION:{context["angle_instruction"]}ANGLE EXAMPLES:"""for example in context["angle_examples"]:headlines_instruction += f"- {example}\n"headlines_instruction += "\n"headlines_instruction += (f"Your task is to create {number_of_headlines} headlines for {target_audience} "f"about {product}, using the selected formula")if selected_angle != "NINGUNO":headlines_instruction += f" and the angle {selected_angle}"headlines_instruction += ".\n\n"headlines_instruction += (f"Before writing, imagine a real day in the life of {target_audience}. "f"Think about what they want, what frustrates them, what slows them down, "f"what awkward, stressful, repetitive, annoying, or meaningful moments they experience, "f"and what kind of situation would make them immediately say: 'yes, that is me.'\n\n")headlines_instruction += (f"Do not rely on mentioning {product} explicitly to create interest. "f"Create interest through the situation, the moment, the tension, the obstacle, or the desire.\n\n")headlines_instruction += "FORMULA:\n"headlines_instruction += f"{context['formula_description']}\n\n"headlines_instruction += "FORMULA EXAMPLES:\n"for i, example in enumerate(context["formula_examples"], 1):headlines_instruction += f"{i}. {example}\n"headlines_instruction += "\nGENERATION RULES:\n"headlines_instruction += "- Keep a structure and length similar to the examples\n"headlines_instruction += "- Maintain specificity and concreteness\n"headlines_instruction += "- Use recognizable real-life situations\n"headlines_instruction += "- Inspire yourself from the examples without copying them literally\n"headlines_instruction += "- Make every headline feel human, clear, and credible\n"headlines_instruction += "- Avoid generic promises without context\n"headlines_instruction += "- Make the audience feel seen in a real moment of life\n\n"headlines_instruction += (f"Generate now {number_of_headlines} original headlines that respect the formula structure")if selected_angle != "NINGUNO":headlines_instruction += f" and apply the angle {selected_angle}"headlines_instruction += ".\n"response = client.models.generate_content(model="gemini-2.5-flash-lite",contents=headlines_instruction + "\n\nWrite the headlines now.",config=types.GenerateContentConfig(temperature=temperature,top_p=0.65,1 unmodified line),)if not response.text:return "No se generaron titulares. Prueba con otra fórmula, ángulo o nivel de creatividad."return response.text17 unmodified lines# Centrar el título y el subtítulost.markdown("<h1 style='text-align: center;'>Enchanted Hooks</h1>", unsafe_allow_html=True)st.markdown("<h4 style='text-align: center;'>Genera titulares más claros, persuasivos y alineados con tu audiencia usando fórmulas y ángulos de copywriting.</h4>",unsafe_allow_html=True)16 unmodified linesindex=4)with st.expander("Personaliza tus titulares"):temperature = st.slider("Creatividad",15 unmodified lines)selected_formula = headline_formulas[selected_formula_key]submit = st.button("Generar Titulares")# Mostrar los titulares generados13 unmodified linesselected_angle)formatted_headlines = (generated_headlines or "").replace("\n", "<br>")col2.markdown(f"""
app.py+68-40