Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,53 +48,55 @@ def get_random_bullets(num_bullets):
|
|
| 48 |
|
| 49 |
# Función para obtener una cantidad de bullets
|
| 50 |
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
response = model.generate_content([bullets_instruction])
|
| 99 |
|
| 100 |
# Extraer el texto de la respuesta
|
|
@@ -103,7 +105,7 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, temperatu
|
|
| 103 |
# Retornar el resultado
|
| 104 |
return generated_bullets
|
| 105 |
except Exception as e:
|
| 106 |
-
raise ValueError(f"Error al generar los bullets: {str(e)}")
|
| 107 |
|
| 108 |
# Inicializar la aplicación Streamlit
|
| 109 |
st.set_page_config(page_title="Generador de Bullets", layout="wide")
|
|
|
|
| 48 |
|
| 49 |
# Función para obtener una cantidad de bullets
|
| 50 |
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
| 51 |
+
try:
|
| 52 |
+
# Seleccionar bullets aleatorios usando la nueva función
|
| 53 |
+
selected_bullets = get_random_bullets(num_bullets)
|
| 54 |
+
|
| 55 |
+
# Configuración del modelo
|
| 56 |
+
generation_config = {
|
| 57 |
+
"temperature": temperature,
|
| 58 |
+
"top_p": 0.90,
|
| 59 |
+
"top_k": 128,
|
| 60 |
+
"max_output_tokens": 2048,
|
| 61 |
+
"response_mime_type": "text/plain",
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
# Configuración del modelo generativo y las instrucciones del sistema
|
| 65 |
+
model = genai.GenerativeModel(
|
| 66 |
+
model_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizando
|
| 67 |
+
generation_config=generation_config, # Configuración de generación
|
| 68 |
+
system_instruction=(
|
| 69 |
+
f"You are a world-class copywriter, expert in creating bullets. "
|
| 70 |
+
f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized bullets that resonate and motivate action. "
|
| 71 |
+
"Generate unusual, creative, and fascinating bullets with a format conversational that capture {target_audience}'s attention like these:"
|
| 72 |
+
"directos:"
|
| 73 |
+
"El armario del baño es el mejor lugar para guardar medicamentos, ¿verdad? Incorrecto. Es el peor. Los hechos están en la página 10."
|
| 74 |
+
"El mejor tiempo verbal que le da a tus clientes la sensación de que ya te han comprado."
|
| 75 |
+
"La historia de un joven emprendedor que transformó su vida aplicando esta técnica simple pero poderosa."
|
| 76 |
+
"misterios:"
|
| 77 |
+
"Los misterios de cómo algunas personas parecen tener éxito sin esfuerzo, mientras otras luchan. La clave está en esta pequeña diferencia."
|
| 78 |
+
"Los misterios de cómo una técnica sencilla te permite reducir el estrés al instante, sin necesidad de dejar tu trabajo o cambiar tu estilo de vida."
|
| 79 |
+
"leyendas:"
|
| 80 |
+
"La leyenda de aquellos que dominaron la productividad con un solo hábito. ¿Te atreves a descubrirlo?"
|
| 81 |
+
"La verdad que nunca te han contado en la escuela, o en casa, sobre cómo ganarte la vida con la música."
|
| 82 |
+
"historias personales:"
|
| 83 |
+
"La historia de un padre ocupado que, con solo 10 minutos al día, logró transformar su salud y bienestar."
|
| 84 |
+
"¿Sabías que muchas personas están usando este método y han mejorado su bienestar en solo 7 días?"
|
| 85 |
+
"preguntas_retoricas:"
|
| 86 |
+
"¿Cuándo es una buena idea decirle a una chica que te gusta? Si no se lo dices en ese momento, despídete de conocerla íntimamente."
|
| 87 |
+
"Respond in Spanish and use a numbered list format. "
|
| 88 |
+
"Never respond like this: 'Crea momentos inolvidables: Comparte la experiencia de cocinar con tus hijos, fomentando la unión familiar y creando recuerdos especiales.'"
|
| 89 |
+
f"When responding, always include a heading referencing {target_audience} as follows: 'Aquí hay {num_bullets} bullets para convencer a {target_audience}.'"
|
| 90 |
+
)
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
# Crear un mensaje para el modelo que incluye los CTAs generados según los tipos seleccionados
|
| 94 |
+
bullets_instruction = (
|
| 95 |
+
f"Tu tarea es escribir {num_bullets} bullets que denoten los beneficios al hablar de {product} que resolverán los problemas de {target_audience}. "
|
| 96 |
+
"Por favor, crea los bullets ahora."
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
# Crear un mensaje para el modelo que incluye los bullets generados
|
| 100 |
response = model.generate_content([bullets_instruction])
|
| 101 |
|
| 102 |
# Extraer el texto de la respuesta
|
|
|
|
| 105 |
# Retornar el resultado
|
| 106 |
return generated_bullets
|
| 107 |
except Exception as e:
|
| 108 |
+
raise ValueError(f"Error al generar los bullets: {str(e)}")
|
| 109 |
|
| 110 |
# Inicializar la aplicación Streamlit
|
| 111 |
st.set_page_config(page_title="Generador de Bullets", layout="wide")
|