Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -65,26 +65,36 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, temperatu
|
|
65 |
model_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizando
|
66 |
generation_config=generation_config, # Configuración de generación
|
67 |
system_instruction=(
|
68 |
-
f"
|
69 |
-
"
|
70 |
-
"
|
|
|
71 |
)
|
72 |
)
|
73 |
|
74 |
-
# Crear
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
)
|
79 |
|
80 |
-
#
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
raise ValueError("Error generando el contenido: " + str(e))
|
88 |
|
89 |
# Inicializar la aplicación Streamlit
|
90 |
st.set_page_config(page_title="Generador de Bullets", layout="wide")
|
@@ -137,8 +147,6 @@ if submit:
|
|
137 |
try:
|
138 |
# Obtener la respuesta del modelo
|
139 |
generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, temperature)
|
140 |
-
# Limpiar el texto para eliminar caracteres extraños
|
141 |
-
generated_bullets = generated_bullets.replace("\n", "<br>") # Para formatear en HTML
|
142 |
col2.markdown(f"""
|
143 |
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
144 |
<h4>🧙🏻♂️ Mira la magia en acción:</h4>
|
|
|
65 |
model_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizando
|
66 |
generation_config=generation_config, # Configuración de generación
|
67 |
system_instruction=(
|
68 |
+
f"You are a world-class copywriter, expert in creating bullets that connect symptoms with problems of {target_audience}. "
|
69 |
+
f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized bullets that resonate and motivate action. "
|
70 |
+
"Generate unusual, creative, and fascinating bullets that capture {target_audience}'s attention. Respond in Spanish and use a numbered list format. "
|
71 |
+
f"When responding, always include a heading referencing {target_audience} as follows: 'Aquí hay {num_bullets} bullets para convencer a {target_audience}.'"
|
72 |
)
|
73 |
)
|
74 |
|
75 |
+
# Crear la instrucción para generar bullets
|
76 |
+
chat_session = model.start_chat(
|
77 |
+
history=[
|
78 |
+
{
|
79 |
+
"role": "user",
|
80 |
+
"parts": [
|
81 |
+
f"Tu tarea es escribir {num_bullets} bullets que denoten los beneficios al hablar de {product} que resolverán los problemas de {target_audience}. "
|
82 |
+
"Un buen bullet conecta los síntomas con los problemas enfrentados por {target_audience} de una manera natural, que no se note como manipuladora. "
|
83 |
+
f"Escribe bullets creativos, en un estilo conversacional, que no sean aburridos, sino más bien divertidos. "
|
84 |
+
f"Sé sutil a la hora de crear los bullets para referirte a los beneficios de tu {product}. "
|
85 |
+
"Por favor, crea los bullets ahora."
|
86 |
+
],
|
87 |
+
},
|
88 |
+
]
|
89 |
)
|
90 |
|
91 |
+
# Crear un mensaje para el modelo que incluye los bullets generados
|
92 |
+
response = model.generate_content(chat_session.history)
|
93 |
+
|
94 |
+
if response and response.parts:
|
95 |
+
return response.parts[0].text
|
96 |
+
else:
|
97 |
+
raise ValueError("Lo sentimos, intenta con una combinación diferente de entradas.")
|
|
|
98 |
|
99 |
# Inicializar la aplicación Streamlit
|
100 |
st.set_page_config(page_title="Generador de Bullets", layout="wide")
|
|
|
147 |
try:
|
148 |
# Obtener la respuesta del modelo
|
149 |
generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, temperature)
|
|
|
|
|
150 |
col2.markdown(f"""
|
151 |
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
152 |
<h4>🧙🏻♂️ Mira la magia en acción:</h4>
|