JeCabrera commited on
Commit
48ca5b5
verified
1 Parent(s): 7cdd012

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -13,40 +13,32 @@ 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.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,13 +132,10 @@ if submit:
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:
 
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.34, 0.33, 0.33]
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
+ Directly introduce the product '{product}' as the clear solution to the problem the reader is facing. Ensure that the product is presented in a way that highlights its key benefits and demonstrates how it directly addresses the issue at hand. The mention should feel natural and seamlessly integrated into the narrative.
24
  """
25
  elif product_mention == "Indirecta":
26
  return f"""
27
+ Subtly reference the product '{product}' as a potential solution to the reader's problem without naming it explicitly. Weave the product's core benefits into the description of how the reader can overcome the issue, creating an implicit connection between the solution and the product. Ensure the mention is subtle but clear enough to guide the reader towards the product.
28
  """
29
  elif product_mention == "Metaf贸rica":
30
  return f"""
31
+ Introduce the product '{product}' using a metaphor, connecting it symbolically to the solution the reader needs. The metaphor should relate to the problem being discussed and should creatively suggest how the product offers a resolution without explicitly stating its name. The metaphor should evoke the benefits of the product in a memorable and thought-provoking way.
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 una cantidad de bullets
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
  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: