Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -248,8 +248,27 @@ if prompt := st.chat_input('¿En qué puedo ayudarte hoy?'):
|
|
248 |
for chunk in response:
|
249 |
full_text += chunk.text
|
250 |
|
251 |
-
#
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
# Añadir respuesta al historial
|
255 |
st.session_state.messages.append({
|
|
|
248 |
for chunk in response:
|
249 |
full_text += chunk.text
|
250 |
|
251 |
+
# Función para mostrar texto con efecto de escritura
|
252 |
+
def mostrar_con_efecto_escritura(mensaje, velocidad=0.1):
|
253 |
+
with st.chat_message(name=MODEL_ROLE, avatar=AI_AVATAR_ICON):
|
254 |
+
message_placeholder = st.empty()
|
255 |
+
full_response = ''
|
256 |
+
|
257 |
+
# Indicador de escritura
|
258 |
+
typing_indicator = st.empty()
|
259 |
+
typing_indicator.markdown("*Estoy analizando tu información...*")
|
260 |
+
|
261 |
+
# Mostrar respuesta por fragmentos
|
262 |
+
for palabra in mensaje.split(' '):
|
263 |
+
full_response += palabra + ' '
|
264 |
+
time.sleep(velocidad)
|
265 |
+
message_placeholder.write(full_response + '▌')
|
266 |
+
|
267 |
+
# Eliminar indicador y mostrar respuesta completa
|
268 |
+
typing_indicator.empty()
|
269 |
+
message_placeholder.write(mensaje)
|
270 |
+
|
271 |
+
return mensaje
|
272 |
|
273 |
# Añadir respuesta al historial
|
274 |
st.session_state.messages.append({
|