Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,3 @@
|
|
| 1 |
-
from dotenv import load_dotenv
|
| 2 |
-
import streamlit as st
|
| 3 |
-
import os
|
| 4 |
-
import google.generativeai as genai
|
| 5 |
-
|
| 6 |
-
# Cargar las variables de entorno
|
| 7 |
-
load_dotenv()
|
| 8 |
-
|
| 9 |
-
# Configurar la API de Google
|
| 10 |
-
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 11 |
-
|
| 12 |
-
# Generar el resultado utilizando el modelo con la instrucci贸n de bullets espec铆fica
|
| 13 |
def generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature):
|
| 14 |
# Configuraci贸n del modelo
|
| 15 |
generation_config = {
|
|
@@ -60,63 +48,4 @@ def generate_bullets(number_of_bullets, target_audience, product, call_to_action
|
|
| 60 |
|
| 61 |
except Exception as e:
|
| 62 |
st.error(f"Error al generar los bullets: {str(e)}")
|
| 63 |
-
|
| 64 |
-
# Configurar la interfaz de usuario con Streamlit
|
| 65 |
-
st.set_page_config(page_title="Impact Bullet Generator", layout="wide")
|
| 66 |
-
|
| 67 |
-
# Centrar el t铆tulo y el subt铆tulo
|
| 68 |
-
st.markdown("<h1 style='text-align: center;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)
|
| 69 |
-
st.markdown("<h4 style='text-align: center;'>Transforma los pensamientos de tu audiencia en balas persuasivas que inspiren a la acci贸n.</h4>", unsafe_allow_html=True)
|
| 70 |
-
|
| 71 |
-
# A帽adir CSS personalizado para el bot贸n
|
| 72 |
-
st.markdown("""
|
| 73 |
-
<style>
|
| 74 |
-
div.stButton > button {
|
| 75 |
-
background-color: #FFCC00;
|
| 76 |
-
color: black;
|
| 77 |
-
width: 90%;
|
| 78 |
-
height: 60px;
|
| 79 |
-
font-weight: bold;
|
| 80 |
-
font-size: 22px;
|
| 81 |
-
text-transform: uppercase;
|
| 82 |
-
border: 1px solid #000000;
|
| 83 |
-
border-radius: 8px;
|
| 84 |
-
display: block;
|
| 85 |
-
margin: 0 auto;
|
| 86 |
-
}
|
| 87 |
-
div.stButton > button:hover {
|
| 88 |
-
background-color: #FFD700;
|
| 89 |
-
color: black;
|
| 90 |
-
}
|
| 91 |
-
</style>
|
| 92 |
-
""", unsafe_allow_html=True)
|
| 93 |
-
|
| 94 |
-
# Crear columnas
|
| 95 |
-
col1, col2 = st.columns([1, 2])
|
| 96 |
-
|
| 97 |
-
# Columnas de entrada
|
| 98 |
-
with col1:
|
| 99 |
-
target_audience = st.text_input("驴Qui茅n es tu p煤blico objetivo?", placeholder="Ejemplo: Estudiantes Universitarios")
|
| 100 |
-
product = st.text_input("驴Qu茅 producto tienes en mente?", placeholder="Ejemplo: Curso de Ingl茅s")
|
| 101 |
-
call_to_action = st.text_input("驴Qu茅 acci贸n deseas que tomen?", placeholder="Ejemplo: Inscribirse al curso")
|
| 102 |
-
number_of_bullets = st.selectbox("N煤mero de bullets", options=list(range(1, 11)), index=4)
|
| 103 |
-
temperature = st.slider("Creatividad", min_value=0.0, max_value=1.0, value=0.5, step=0.1)
|
| 104 |
-
|
| 105 |
-
# Bot贸n de enviar
|
| 106 |
-
submit = st.button("Generar Beneficios")
|
| 107 |
-
|
| 108 |
-
# Mostrar los beneficios generados
|
| 109 |
-
if submit:
|
| 110 |
-
if target_audience and product and call_to_action:
|
| 111 |
-
generated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)
|
| 112 |
-
if generated_bullets:
|
| 113 |
-
col2.markdown(f"""
|
| 114 |
-
<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
|
| 115 |
-
<h4>Mira los bullets generados:</h4>
|
| 116 |
-
<p style="font-size: 22px;">{generated_bullets}</p>
|
| 117 |
-
</div>
|
| 118 |
-
""", unsafe_allow_html=True)
|
| 119 |
-
else:
|
| 120 |
-
st.error("No se generaron bullets.")
|
| 121 |
-
else:
|
| 122 |
-
st.error("Por favor, completa todos los campos.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature):
|
| 2 |
# Configuraci贸n del modelo
|
| 3 |
generation_config = {
|
|
|
|
| 48 |
|
| 49 |
except Exception as e:
|
| 50 |
st.error(f"Error al generar los bullets: {str(e)}")
|
| 51 |
+
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|