Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ def get_mention_instruction(product_mention, product):
|
|
| 33 |
return ""
|
| 34 |
|
| 35 |
# Funci贸n para obtener una cantidad de bullets
|
| 36 |
-
def get_gemini_response_bullets(target_audience, product, num_bullets,
|
| 37 |
product_mention = get_random_product_mention()
|
| 38 |
mention_instruction = get_mention_instruction(product_mention, product) # Define aqu铆
|
| 39 |
model_choice = "gemini-1.5-flash" # Modelo por defecto
|
|
@@ -41,7 +41,13 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, creativit
|
|
| 41 |
# Configuraci贸n del modelo generativo y las instrucciones del sistema
|
| 42 |
model = genai.GenerativeModel(
|
| 43 |
model_name=model_choice, # Nombre del modelo que estamos utilizando
|
| 44 |
-
generation_config=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
system_instruction=(
|
| 46 |
f"You are a world-class copywriter, expert in creating benefits that connect symptoms with problems of {target_audience}. "
|
| 47 |
f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized copywriting that resonate and motivate action. "
|
|
@@ -68,7 +74,7 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, creativit
|
|
| 68 |
bullets_instruction = (
|
| 69 |
f"Tu tarea es escribir {num_bullets} beneficios o bullets que conecten el s铆ntoma con el problema enfrentado por {target_audience}, "
|
| 70 |
f"aumentando su deseo de adquirir, asistir, descargar o comprar el {product}. "
|
| 71 |
-
f"Escribe los bullets con un nivel de creatividad {
|
| 72 |
"Aseg煤rate de que la menci贸n se adapte seg煤n este tipo: "
|
| 73 |
"Por favor, crea los bullets ahora."
|
| 74 |
)
|
|
@@ -123,7 +129,7 @@ with col1:
|
|
| 123 |
|
| 124 |
# Campos de personalizaci贸n sin acorde贸n
|
| 125 |
num_bullets = st.slider("N煤mero de Bullets", min_value=1, max_value=15, value=5)
|
| 126 |
-
|
| 127 |
|
| 128 |
# Bot贸n de enviar
|
| 129 |
submit = st.button("Generar Bullets")
|
|
@@ -133,7 +139,7 @@ if submit:
|
|
| 133 |
if target_audience and product:
|
| 134 |
try:
|
| 135 |
# Obtener la respuesta del modelo
|
| 136 |
-
generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets,
|
| 137 |
col2.markdown(f"""
|
| 138 |
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
| 139 |
<h4>Observa la magia en acci贸n:</h4>
|
|
|
|
| 33 |
return ""
|
| 34 |
|
| 35 |
# Funci贸n para obtener una cantidad de bullets
|
| 36 |
+
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
| 37 |
product_mention = get_random_product_mention()
|
| 38 |
mention_instruction = get_mention_instruction(product_mention, product) # Define aqu铆
|
| 39 |
model_choice = "gemini-1.5-flash" # Modelo por defecto
|
|
|
|
| 41 |
# Configuraci贸n del modelo generativo y las instrucciones del sistema
|
| 42 |
model = genai.GenerativeModel(
|
| 43 |
model_name=model_choice, # Nombre del modelo que estamos utilizando
|
| 44 |
+
generation_config={
|
| 45 |
+
"temperature": temperature, # Cambiamos creatividad por temperature
|
| 46 |
+
"top_p": 0.85,
|
| 47 |
+
"top_k": 128,
|
| 48 |
+
"max_output_tokens": 2048,
|
| 49 |
+
"response_mime_type": "text/plain",
|
| 50 |
+
},
|
| 51 |
system_instruction=(
|
| 52 |
f"You are a world-class copywriter, expert in creating benefits that connect symptoms with problems of {target_audience}. "
|
| 53 |
f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized copywriting that resonate and motivate action. "
|
|
|
|
| 74 |
bullets_instruction = (
|
| 75 |
f"Tu tarea es escribir {num_bullets} beneficios o bullets que conecten el s铆ntoma con el problema enfrentado por {target_audience}, "
|
| 76 |
f"aumentando su deseo de adquirir, asistir, descargar o comprar el {product}. "
|
| 77 |
+
f"Escribe los bullets con un nivel de creatividad {temperature:.1f}. "
|
| 78 |
"Aseg煤rate de que la menci贸n se adapte seg煤n este tipo: "
|
| 79 |
"Por favor, crea los bullets ahora."
|
| 80 |
)
|
|
|
|
| 129 |
|
| 130 |
# Campos de personalizaci贸n sin acorde贸n
|
| 131 |
num_bullets = st.slider("N煤mero de Bullets", min_value=1, max_value=15, value=5)
|
| 132 |
+
temperature = st.slider("Creatividad", min_value=0.0, max_value=1.0, value=0.5, step=0.1)
|
| 133 |
|
| 134 |
# Bot贸n de enviar
|
| 135 |
submit = st.button("Generar Bullets")
|
|
|
|
| 139 |
if target_audience and product:
|
| 140 |
try:
|
| 141 |
# Obtener la respuesta del modelo
|
| 142 |
+
generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, temperature)
|
| 143 |
col2.markdown(f"""
|
| 144 |
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
| 145 |
<h4>Observa la magia en acci贸n:</h4>
|