JeCabrera commited on
Commit
b1585ad
verified
1 Parent(s): 233cecb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -29
app.py CHANGED
@@ -10,32 +10,8 @@ load_dotenv()
10
  # Configurar la API de Google
11
  genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
12
 
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] # Probabilidades ajustadas
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
  # 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)
39
  model_choice = "gemini-1.5-flash" # Modelo por defecto
40
 
41
  # Configuraci贸n del modelo generativo y las instrucciones del sistema
@@ -53,7 +29,7 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, temperatu
53
  f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized copywriting that resonate and motivate action. "
54
  f"You know how to use proven structures to attract {target_audience}, generating interest and creating a powerful connection with {product}. "
55
  "Generate unusual, creative, and fascinating bullets that capturing {target_audience}'s attention. Respond in Spanish and use a numbered list format. "
56
- f"When responding, always include a heading referencing {target_audience} and the product as follows:" f"'Aqu铆 hay {num_bullets} bullets para convencer a {target_audience}, de [beneficio de comprar, asistir, descargar, adquirir,] {product}' "
57
  )
58
  )
59
 
@@ -91,10 +67,8 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, temperatu
91
  ]
92
  )
93
 
94
- # Crear un mensaje para el modelo que incluye los bullets generados seg煤n los tipos seleccionados
95
- full_prompt = f"{mention_instruction}"
96
-
97
- response = model.generate_content([full_prompt])
98
 
99
  if response and response.parts:
100
  return response.parts[0].text
 
10
  # Configurar la API de Google
11
  genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  # Funci贸n para obtener una cantidad de bullets
14
  def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
 
 
15
  model_choice = "gemini-1.5-flash" # Modelo por defecto
16
 
17
  # Configuraci贸n del modelo generativo y las instrucciones del sistema
 
29
  f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized copywriting that resonate and motivate action. "
30
  f"You know how to use proven structures to attract {target_audience}, generating interest and creating a powerful connection with {product}. "
31
  "Generate unusual, creative, and fascinating bullets that capturing {target_audience}'s attention. Respond in Spanish and use a numbered list format. "
32
+ f"When responding, always include a heading referencing {target_audience} and the product as follows: 'Aqu铆 hay {num_bullets} bullets para convencer a {target_audience}, de [beneficio de comprar, asistir, descargar, adquirir,] {product}' "
33
  )
34
  )
35
 
 
67
  ]
68
  )
69
 
70
+ # Crear un mensaje para el modelo que incluye los bullets generados
71
+ response = model.generate_content([])
 
 
72
 
73
  if response and response.parts:
74
  return response.parts[0].text