Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -46,16 +46,10 @@ def generate_buyer_persona(product, skills, target_audience, temperature):
|
|
46 |
response = model.generate_content([instruction], generation_config={"temperature": temperature})
|
47 |
return response.parts[0].text if response and response.parts else "Error generando el perfil de cliente ideal."
|
48 |
|
49 |
-
#
|
50 |
def update_profile():
|
51 |
-
#
|
52 |
-
|
53 |
-
st.session_state.perfil_cliente = generate_buyer_persona(
|
54 |
-
st.session_state.producto,
|
55 |
-
st.session_state.habilidades,
|
56 |
-
st.session_state.publico_objetivo,
|
57 |
-
st.session_state.creatividad
|
58 |
-
)
|
59 |
|
60 |
# Configurar la interfaz de usuario con Streamlit
|
61 |
st.set_page_config(page_title="Generador de Cliente Ideal", page_icon="馃懁", layout="wide")
|
@@ -125,25 +119,55 @@ with col1:
|
|
125 |
|
126 |
# Columna de resultados
|
127 |
with col2:
|
128 |
-
#
|
129 |
-
if st.session_state.
|
130 |
-
if
|
131 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
else:
|
133 |
-
st.
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
46 |
response = model.generate_content([instruction], generation_config={"temperature": temperature})
|
47 |
return response.parts[0].text if response and response.parts else "Error generando el perfil de cliente ideal."
|
48 |
|
49 |
+
# Modificar la funci贸n update_profile para que no use spinner
|
50 |
def update_profile():
|
51 |
+
# Solo actualizar la variable de sesi贸n
|
52 |
+
st.session_state.submitted = True
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
# Configurar la interfaz de usuario con Streamlit
|
55 |
st.set_page_config(page_title="Generador de Cliente Ideal", page_icon="馃懁", layout="wide")
|
|
|
119 |
|
120 |
# Columna de resultados
|
121 |
with col2:
|
122 |
+
# Verificar si se ha enviado el formulario
|
123 |
+
if 'submitted' in st.session_state and st.session_state.submitted:
|
124 |
+
if st.session_state.producto and st.session_state.habilidades:
|
125 |
+
with st.spinner("Creando tu Cliente Ideal So帽ado..."):
|
126 |
+
# Generar el perfil del cliente
|
127 |
+
perfil_cliente = generate_buyer_persona(
|
128 |
+
st.session_state.producto,
|
129 |
+
st.session_state.habilidades,
|
130 |
+
st.session_state.publico_objetivo,
|
131 |
+
st.session_state.creatividad
|
132 |
+
)
|
133 |
+
# Guardar en session_state
|
134 |
+
st.session_state.perfil_cliente = perfil_cliente
|
135 |
+
# Resetear el estado de env铆o
|
136 |
+
st.session_state.submitted = False
|
137 |
+
|
138 |
+
# Mostrar resultados
|
139 |
+
if not isinstance(st.session_state.perfil_cliente, str):
|
140 |
+
st.error("Error al generar el perfil de cliente ideal")
|
141 |
+
else:
|
142 |
+
st.markdown(f"""
|
143 |
+
<div style="{styles['results_container']}">
|
144 |
+
<h3>Tu Cliente Ideal</h3>
|
145 |
+
{st.session_state.perfil_cliente}
|
146 |
+
</div>
|
147 |
+
""", unsafe_allow_html=True)
|
148 |
+
|
149 |
+
# Opci贸n para descargar
|
150 |
+
st.download_button(
|
151 |
+
label="Descargar Perfil",
|
152 |
+
data=st.session_state.perfil_cliente,
|
153 |
+
file_name="cliente_ideal.md",
|
154 |
+
mime="text/markdown"
|
155 |
+
)
|
156 |
else:
|
157 |
+
st.warning("Por favor, completa los campos de producto y habilidades antes de generar el perfil.")
|
158 |
+
# Mostrar resultados anteriores si existen
|
159 |
+
elif st.session_state.perfil_cliente:
|
160 |
+
st.markdown(f"""
|
161 |
+
<div style="{styles['results_container']}">
|
162 |
+
<h3>Tu Cliente Ideal</h3>
|
163 |
+
{st.session_state.perfil_cliente}
|
164 |
+
</div>
|
165 |
+
""", unsafe_allow_html=True)
|
166 |
+
|
167 |
+
# Opci贸n para descargar
|
168 |
+
st.download_button(
|
169 |
+
label="Descargar Perfil",
|
170 |
+
data=st.session_state.perfil_cliente,
|
171 |
+
file_name="cliente_ideal.md",
|
172 |
+
mime="text/markdown"
|
173 |
+
)
|