Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -10,44 +10,60 @@ load_dotenv()
|
|
10 |
# Configurar la API de Google
|
11 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
"
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
"
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
"
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
# Función para seleccionar bullets aleatorios
|
29 |
def get_random_bullets(num_bullets):
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
return selected_bullets
|
33 |
|
34 |
# Función para obtener una cantidad de bullets
|
35 |
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
36 |
-
model_choice = "gemini-1.5-flash" # Modelo por defecto
|
37 |
-
|
38 |
# Seleccionar bullets aleatorios usando la nueva función
|
39 |
selected_bullets = get_random_bullets(num_bullets)
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Configuración del modelo generativo y las instrucciones del sistema
|
42 |
model = genai.GenerativeModel(
|
43 |
-
model_name=
|
44 |
-
generation_config=
|
45 |
-
"temperature": 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. "
|
|
|
10 |
# Configurar la API de Google
|
11 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
12 |
|
13 |
+
# Ejemplos de bullets por tipo
|
14 |
+
bullets_types = {
|
15 |
+
"directos": [
|
16 |
+
"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.",
|
17 |
+
"El mejor tiempo verbal que le da a tus clientes la sensación de que ya te han comprado.",
|
18 |
+
"La historia de un joven emprendedor que transformó su vida aplicando esta técnica simple pero poderosa."
|
19 |
+
],
|
20 |
+
"misterios": [
|
21 |
+
"Los misterios de cómo algunas personas parecen tener éxito sin esfuerzo, mientras otras luchan. La clave está en esta pequeña diferencia.",
|
22 |
+
"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."
|
23 |
+
],
|
24 |
+
"leyendas": [
|
25 |
+
"La leyenda de aquellos que dominaron la productividad con un solo hábito. ¿Te atreves a descubrirlo?",
|
26 |
+
"La verdad que nunca te han contado en la escuela, o en casa, sobre cómo ganarte la vida con la música."
|
27 |
+
],
|
28 |
+
"historias_personales": [
|
29 |
+
"La historia de un padre ocupado que, con solo 10 minutos al día, logró transformar su salud y bienestar.",
|
30 |
+
"¿Sabías que muchas personas están usando este método y han mejorado su bienestar en solo 7 días?"
|
31 |
+
],
|
32 |
+
"preguntas_retoricas": [
|
33 |
+
"¿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."
|
34 |
+
]
|
35 |
}
|
36 |
|
37 |
# Función para seleccionar bullets aleatorios
|
38 |
def get_random_bullets(num_bullets):
|
39 |
+
selected_bullets = []
|
40 |
+
# Selección aleatoria de tipos de bullet, manteniendo variedad en la salida
|
41 |
+
selected_types = random.sample(list(bullets_types.keys()), min(num_bullets, len(bullets_types)))
|
42 |
+
|
43 |
+
for bullet_type in selected_types:
|
44 |
+
bullet = random.choice(bullets_types[bullet_type])
|
45 |
+
selected_bullets.append(bullet)
|
46 |
+
|
47 |
return selected_bullets
|
48 |
|
49 |
# Función para obtener una cantidad de bullets
|
50 |
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
|
|
|
|
51 |
# Seleccionar bullets aleatorios usando la nueva función
|
52 |
selected_bullets = get_random_bullets(num_bullets)
|
53 |
|
54 |
+
# Configuración del modelo
|
55 |
+
generation_config = {
|
56 |
+
"temperature": temperature,
|
57 |
+
"top_p": 0.85,
|
58 |
+
"top_k": 128,
|
59 |
+
"max_output_tokens": 2048,
|
60 |
+
"response_mime_type": "text/plain",
|
61 |
+
}
|
62 |
+
|
63 |
# Configuración del modelo generativo y las instrucciones del sistema
|
64 |
model = genai.GenerativeModel(
|
65 |
+
model_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizando
|
66 |
+
generation_config=generation_config, # Configuración de generación
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
system_instruction=(
|
68 |
f"You are a world-class copywriter, expert in creating benefits that connect symptoms with problems of {target_audience}. "
|
69 |
f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized copywriting that resonate and motivate action. "
|