Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,13 @@ 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"]
|
|
@@ -18,30 +25,27 @@ def get_random_product_mention():
|
|
| 18 |
|
| 19 |
# Crear la instrucción de mención basada en la opción seleccionada
|
| 20 |
def get_mention_instruction(product_mention, product):
|
| 21 |
-
|
| 22 |
-
|
| 23 |
f"Este curso de inglés te proporcionará las herramientas necesarias para abrir nuevas oportunidades laborales.",
|
| 24 |
f"Con este curso de inglés, transforma tu carrera y tu vida familiar.",
|
| 25 |
f"No permitas que la falta de inglés limite tu futuro; inscríbete y empieza a disfrutar de más tiempo con tus pequeños."
|
| 26 |
]
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
elif product_mention == "Indirecta":
|
| 30 |
-
examples = [
|
| 31 |
f"Imagina tener la confianza hablando un idioma diferente para brillar en tus reuniones de trabajo.",
|
| 32 |
f"El mejor regalo que puedes darles a tus hijos es su crecimiento profesional dandoles herramientas como otros idiomas.",
|
| 33 |
f"Visualiza cómo tus pequeños se sentirán orgullosos al verte alcanzar esa promoción por hablar en otro idioma."
|
| 34 |
]
|
| 35 |
-
return f"Subtly reference the product '{product}' as a potential solution to the reader's problem without naming it explicitly. Examples: {', '.join(examples)}"
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
f"
|
| 40 |
-
f"
|
| 41 |
-
f"Dominar el inglés es encender una luz en la oscuridad."
|
| 42 |
]
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
# Function to get a random mention instruction
|
| 46 |
def get_random_mention_instruction():
|
| 47 |
mention_type = get_random_product_mention() # Get random mention type
|
|
@@ -51,7 +55,7 @@ def get_random_mention_instruction():
|
|
| 51 |
# Función para obtener una cantidad de bullets
|
| 52 |
def generate_bullets(number_of_bullets, target_audience, product, temperature):
|
| 53 |
product_mention = get_random_product_mention()
|
| 54 |
-
mention_instruction =
|
| 55 |
model_choice = "gemini-1.5-flash" # Modelo por defecto
|
| 56 |
|
| 57 |
model = genai.GenerativeModel(model_choice)
|
|
@@ -93,7 +97,7 @@ def generate_bullets(number_of_bullets, target_audience, product, temperature):
|
|
| 93 |
return generated_bullets
|
| 94 |
except Exception as e:
|
| 95 |
raise ValueError(f"Tuvimos este error al generar los bullets: {str(e)}")
|
| 96 |
-
|
| 97 |
# Example usage
|
| 98 |
if __name__ == "__main__":
|
| 99 |
bullets = generate_bullets(5, "target audience", "product name", 0.7)
|
|
|
|
| 10 |
# Configurar la API de Google
|
| 11 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 12 |
|
| 13 |
+
# Descripciones de los tipos de menciones
|
| 14 |
+
mention_descriptions = {
|
| 15 |
+
f"Directa: Directly introduce the product '{product}' as the clear solution to the problem the reader is facing."
|
| 16 |
+
f"Indirecta: Subtly reference the product '{product}' as a potential solution to the reader's problem without naming it explicitly."
|
| 17 |
+
f"Metafórica: Introduce the product '{product}' using a metaphor, symbolically connecting it to the solution the reader needs."
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
# Función para obtener una mención del producto de manera probabilística
|
| 21 |
def get_random_product_mention():
|
| 22 |
mentions = ["Directa", "Indirecta", "Metafórica"]
|
|
|
|
| 25 |
|
| 26 |
# Crear la instrucción de mención basada en la opción seleccionada
|
| 27 |
def get_mention_instruction(product_mention, product):
|
| 28 |
+
examples = {
|
| 29 |
+
"Directa": [
|
| 30 |
f"Este curso de inglés te proporcionará las herramientas necesarias para abrir nuevas oportunidades laborales.",
|
| 31 |
f"Con este curso de inglés, transforma tu carrera y tu vida familiar.",
|
| 32 |
f"No permitas que la falta de inglés limite tu futuro; inscríbete y empieza a disfrutar de más tiempo con tus pequeños."
|
| 33 |
]
|
| 34 |
+
"Indirecta": [
|
|
|
|
|
|
|
|
|
|
| 35 |
f"Imagina tener la confianza hablando un idioma diferente para brillar en tus reuniones de trabajo.",
|
| 36 |
f"El mejor regalo que puedes darles a tus hijos es su crecimiento profesional dandoles herramientas como otros idiomas.",
|
| 37 |
f"Visualiza cómo tus pequeños se sentirán orgullosos al verte alcanzar esa promoción por hablar en otro idioma."
|
| 38 |
]
|
|
|
|
| 39 |
|
| 40 |
+
"Metafórica": [
|
| 41 |
+
f"Aprender inglés es como lanzarse a la piscina, al principio puede dar un poco de miedo, en el webinar te enseñare como sumergirte para descubrir un mundo nuevo lleno de oportunidades que antes parecían inaccesibles.",
|
| 42 |
+
f"Hablar inglés es tu brújula en el océano laboral para navegar hacia esas rutas que solo parecían estar disponibles para bilingües.",
|
| 43 |
+
f"Dominar el inglés es encender una luz en la oscuridad que te permite ver otras oportunidades laborales."
|
|
|
|
| 44 |
]
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
return f"{mention_descriptions[product_mention]} Ejemplos: {', '.join(examples[product_mention])}"
|
| 48 |
+
|
| 49 |
# Function to get a random mention instruction
|
| 50 |
def get_random_mention_instruction():
|
| 51 |
mention_type = get_random_product_mention() # Get random mention type
|
|
|
|
| 55 |
# Función para obtener una cantidad de bullets
|
| 56 |
def generate_bullets(number_of_bullets, target_audience, product, temperature):
|
| 57 |
product_mention = get_random_product_mention()
|
| 58 |
+
mention_instruction = get_mention_instruction(product_mention, product) # Get mention instruction
|
| 59 |
model_choice = "gemini-1.5-flash" # Modelo por defecto
|
| 60 |
|
| 61 |
model = genai.GenerativeModel(model_choice)
|
|
|
|
| 97 |
return generated_bullets
|
| 98 |
except Exception as e:
|
| 99 |
raise ValueError(f"Tuvimos este error al generar los bullets: {str(e)}")
|
| 100 |
+
|
| 101 |
# Example usage
|
| 102 |
if __name__ == "__main__":
|
| 103 |
bullets = generate_bullets(5, "target audience", "product name", 0.7)
|