Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,32 +13,40 @@ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
13 |
# Funci贸n para obtener una menci贸n del producto de manera probabil铆stica
|
14 |
def get_random_product_mention():
|
15 |
mentions = ["Directa", "Indirecta", "Metaf贸rica"]
|
16 |
-
probabilities = [0.
|
17 |
return random.choices(mentions, probabilities)[0]
|
18 |
|
19 |
# Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
|
20 |
def get_mention_instruction(product_mention, product):
|
21 |
if product_mention == "Directa":
|
22 |
return f"""
|
23 |
-
|
24 |
"""
|
25 |
elif product_mention == "Indirecta":
|
26 |
return f"""
|
27 |
-
|
28 |
"""
|
29 |
elif product_mention == "Metaf贸rica":
|
30 |
return f"""
|
31 |
-
Introduce
|
32 |
"""
|
33 |
return ""
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# System Prompt - Instrucci贸n en ingl茅s para el modelo
|
36 |
system_instruction = """
|
37 |
You are a world-class copywriter, expert in creating benefits that connect symptoms with problems. You deeply understand the emotions, desires, and challenges of a specific audience, allowing you to design personalized marketing strategies that resonate and motivate action. You know how to use proven structures to attract your target audience, generating interest and creating a powerful connection.
|
38 |
Generate unusual, creative, and fascinating bullets that capture readers' attention about the product. Respond in Spanish and use a numbered list format. Important: Only answer bullets, never include explanations or categories, like this: 'La leyenda del padre soltero: Dice que nunca hay tiempo suficiente. El yoga te ense帽a a usar mejor el tiempo que tienes, incluso cuando te parece imposible(este bullet es cursioso).'.
|
39 |
"""
|
40 |
|
41 |
-
# Funci贸n para obtener
|
42 |
def get_gemini_response_bullets(target_audience, product, num_bullets, creativity):
|
43 |
product_mention = get_random_product_mention()
|
44 |
mention_instruction = get_mention_instruction(product_mention, product) # Define aqu铆
|
@@ -132,10 +140,13 @@ if submit:
|
|
132 |
try:
|
133 |
# Obtener la respuesta del modelo
|
134 |
generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, creativity)
|
|
|
135 |
col2.markdown(f"""
|
136 |
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
137 |
<h4>Observa la magia en acci贸n:</h4>
|
138 |
<p>{generated_bullets}</p>
|
|
|
|
|
139 |
</div>
|
140 |
""", unsafe_allow_html=True)
|
141 |
except ValueError as e:
|
|
|
13 |
# Funci贸n para obtener una menci贸n del producto de manera probabil铆stica
|
14 |
def get_random_product_mention():
|
15 |
mentions = ["Directa", "Indirecta", "Metaf贸rica"]
|
16 |
+
probabilities = [0.20, 0.30, 0.50] # Mayor probabilidad para Metaf贸rica
|
17 |
return random.choices(mentions, probabilities)[0]
|
18 |
|
19 |
# Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
|
20 |
def get_mention_instruction(product_mention, product):
|
21 |
if product_mention == "Directa":
|
22 |
return f"""
|
23 |
+
Presenta el producto '{product}' como la soluci贸n clara al problema que enfrenta el lector. Destaca sus beneficios clave y demuestra c贸mo aborda directamente el problema. La menci贸n debe sentirse natural e integrada en la narrativa.
|
24 |
"""
|
25 |
elif product_mention == "Indirecta":
|
26 |
return f"""
|
27 |
+
Haz referencia al producto '{product}' como una posible soluci贸n al problema del lector sin nombrarlo expl铆citamente. Integra los beneficios del producto en la descripci贸n de c贸mo el lector puede superar el problema, creando una conexi贸n impl铆cita entre la soluci贸n y el producto.
|
28 |
"""
|
29 |
elif product_mention == "Metaf贸rica":
|
30 |
return f"""
|
31 |
+
Introduce el producto '{product}' utilizando una met谩fora, conect谩ndolo simb贸licamente a la soluci贸n que necesita el lector. La met谩fora debe relacionarse con el problema discutido y sugerir creativamente c贸mo el producto ofrece una resoluci贸n sin mencionarlo expl铆citamente.
|
32 |
"""
|
33 |
return ""
|
34 |
|
35 |
+
# Funci贸n para obtener una cantidad de bullets orientados a la acci贸n
|
36 |
+
def get_action_oriented_bullets(product):
|
37 |
+
return [
|
38 |
+
f"驴Sab铆as que el {product} puede transformar tu rutina diaria? Desc煤brelo ahora.",
|
39 |
+
f"No dejes pasar la oportunidad: el {product} est谩 dise帽ado para facilitarte la vida.",
|
40 |
+
f"Imagina lo que podr铆as lograr con el {product} en tu arsenal. 隆Act煤a y pru茅balo hoy!"
|
41 |
+
]
|
42 |
+
|
43 |
# System Prompt - Instrucci贸n en ingl茅s para el modelo
|
44 |
system_instruction = """
|
45 |
You are a world-class copywriter, expert in creating benefits that connect symptoms with problems. You deeply understand the emotions, desires, and challenges of a specific audience, allowing you to design personalized marketing strategies that resonate and motivate action. You know how to use proven structures to attract your target audience, generating interest and creating a powerful connection.
|
46 |
Generate unusual, creative, and fascinating bullets that capture readers' attention about the product. Respond in Spanish and use a numbered list format. Important: Only answer bullets, never include explanations or categories, like this: 'La leyenda del padre soltero: Dice que nunca hay tiempo suficiente. El yoga te ense帽a a usar mejor el tiempo que tienes, incluso cuando te parece imposible(este bullet es cursioso).'.
|
47 |
"""
|
48 |
|
49 |
+
# Funci贸n para obtener los bullets
|
50 |
def get_gemini_response_bullets(target_audience, product, num_bullets, creativity):
|
51 |
product_mention = get_random_product_mention()
|
52 |
mention_instruction = get_mention_instruction(product_mention, product) # Define aqu铆
|
|
|
140 |
try:
|
141 |
# Obtener la respuesta del modelo
|
142 |
generated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, creativity)
|
143 |
+
action_bullets = get_action_oriented_bullets(product)
|
144 |
col2.markdown(f"""
|
145 |
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
146 |
<h4>Observa la magia en acci贸n:</h4>
|
147 |
<p>{generated_bullets}</p>
|
148 |
+
<h4>Bullets orientados a la acci贸n:</h4>
|
149 |
+
<p>{'<br>'.join(action_bullets)}</p>
|
150 |
</div>
|
151 |
""", unsafe_allow_html=True)
|
152 |
except ValueError as e:
|