Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ load_dotenv()
|
|
| 8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 9 |
|
| 10 |
# Funci贸n para generar los beneficios (bullets) basados en el enfoque
|
| 11 |
-
def generate_benefits(focus_points, product, target_audience):
|
| 12 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 13 |
|
| 14 |
# Base del prompt para generar los bullets persuasivos
|
|
@@ -40,12 +40,12 @@ def generate_benefits(focus_points, product, target_audience):
|
|
| 40 |
|
| 41 |
benefits = []
|
| 42 |
# Crear el prompt espec铆fico para cada enfoque y enviarlo al modelo
|
| 43 |
-
for point in focus_points:
|
| 44 |
# Crear el prompt para el enfoque seleccionado
|
| 45 |
specific_prompt = prompt_base + f"\n\nEnfoque: {point}\n"
|
| 46 |
|
| 47 |
-
# Generar los beneficios con la API de Google
|
| 48 |
-
response = model.generate_content([specific_prompt])
|
| 49 |
|
| 50 |
if response and response.parts:
|
| 51 |
benefits.append(response.parts[0].text.strip())
|
|
@@ -80,12 +80,19 @@ with col1:
|
|
| 80 |
)
|
| 81 |
product = st.text_input("Producto relacionado:", placeholder="Ejemplo: Curso de productividad")
|
| 82 |
target_audience = st.text_input("P煤blico objetivo:", placeholder="Ejemplo: Estudiantes universitarios")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
submit = st.button("Generar Beneficios")
|
| 84 |
|
| 85 |
# Mostrar los beneficios generados
|
| 86 |
if submit:
|
| 87 |
if focus_points and product and target_audience:
|
| 88 |
-
benefits = generate_benefits(focus_points, product, target_audience)
|
| 89 |
formatted_benefits = '<br style="line-height: 2;">'.join(benefits)
|
| 90 |
|
| 91 |
col2.markdown(f"""
|
|
|
|
| 8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 9 |
|
| 10 |
# Funci贸n para generar los beneficios (bullets) basados en el enfoque
|
| 11 |
+
def generate_benefits(focus_points, product, target_audience, creativity, num_bullets):
|
| 12 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 13 |
|
| 14 |
# Base del prompt para generar los bullets persuasivos
|
|
|
|
| 40 |
|
| 41 |
benefits = []
|
| 42 |
# Crear el prompt espec铆fico para cada enfoque y enviarlo al modelo
|
| 43 |
+
for point in focus_points[:num_bullets]: # Limitar a los bullets seleccionados
|
| 44 |
# Crear el prompt para el enfoque seleccionado
|
| 45 |
specific_prompt = prompt_base + f"\n\nEnfoque: {point}\n"
|
| 46 |
|
| 47 |
+
# Generar los beneficios con la API de Google, pasando la temperatura (creatividad)
|
| 48 |
+
response = model.generate_content([specific_prompt], temperature=creativity)
|
| 49 |
|
| 50 |
if response and response.parts:
|
| 51 |
benefits.append(response.parts[0].text.strip())
|
|
|
|
| 80 |
)
|
| 81 |
product = st.text_input("Producto relacionado:", placeholder="Ejemplo: Curso de productividad")
|
| 82 |
target_audience = st.text_input("P煤blico objetivo:", placeholder="Ejemplo: Estudiantes universitarios")
|
| 83 |
+
|
| 84 |
+
# Slider para la creatividad
|
| 85 |
+
creativity = st.slider("Creatividad (Temperatura)", min_value=0.0, max_value=1.0, value=0.7, step=0.1)
|
| 86 |
+
|
| 87 |
+
# Slider para el n煤mero de bullets
|
| 88 |
+
num_bullets = st.slider("N煤mero de Bullets", min_value=1, max_value=10, value=5, step=1)
|
| 89 |
+
|
| 90 |
submit = st.button("Generar Beneficios")
|
| 91 |
|
| 92 |
# Mostrar los beneficios generados
|
| 93 |
if submit:
|
| 94 |
if focus_points and product and target_audience:
|
| 95 |
+
benefits = generate_benefits(focus_points, product, target_audience, creativity, num_bullets)
|
| 96 |
formatted_benefits = '<br style="line-height: 2;">'.join(benefits)
|
| 97 |
|
| 98 |
col2.markdown(f"""
|