JeCabrera commited on
Commit
cab9349
verified
1 Parent(s): 04f0d0a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -115,6 +115,24 @@ def stream_response(response, message_placeholder, typing_indicator):
115
  message_placeholder.markdown(full_response)
116
  return full_response
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  # Funci贸n para cargar CSS personalizado
119
  def load_css(file_path):
120
  with open(file_path) as f:
@@ -281,21 +299,3 @@ if state.has_prompt():
281
  process_message(prompt, is_example=True)
282
  # Limpiar el prompt
283
  state.clear_prompt()
284
-
285
- def stream_response_with_fade(response, message_placeholder, typing_indicator):
286
- """Maneja el streaming de la respuesta con efecto de desvanecimiento"""
287
- full_response = ''
288
- try:
289
- for chunk in response:
290
- if chunk.text:
291
- full_response += chunk.text
292
- typing_indicator.markdown("*Generando respuesta...*")
293
- message_placeholder.markdown(f'<div class="fade-in-text">{full_response}</div>', unsafe_allow_html=True)
294
- time.sleep(0.3)
295
-
296
- typing_indicator.empty()
297
- message_placeholder.markdown(f'<div class="fade-in-text">{full_response}</div>', unsafe_allow_html=True)
298
- return full_response
299
- except Exception as e:
300
- st.error(f"Error en el streaming: {str(e)}")
301
- return ''
 
115
  message_placeholder.markdown(full_response)
116
  return full_response
117
 
118
+ def stream_response_with_fade(response, message_placeholder, typing_indicator):
119
+ """Maneja el streaming de la respuesta con efecto de desvanecimiento"""
120
+ full_response = ''
121
+ try:
122
+ for chunk in response:
123
+ if chunk.text:
124
+ full_response += chunk.text
125
+ typing_indicator.markdown("*Generando respuesta...*")
126
+ message_placeholder.markdown(f'<div class="fade-in-text">{full_response}</div>', unsafe_allow_html=True)
127
+ time.sleep(0.3)
128
+
129
+ typing_indicator.empty()
130
+ message_placeholder.markdown(f'<div class="fade-in-text">{full_response}</div>', unsafe_allow_html=True)
131
+ return full_response
132
+ except Exception as e:
133
+ st.error(f"Error en el streaming: {str(e)}")
134
+ return ''
135
+
136
  # Funci贸n para cargar CSS personalizado
137
  def load_css(file_path):
138
  with open(file_path) as f:
 
299
  process_message(prompt, is_example=True)
300
  # Limpiar el prompt
301
  state.clear_prompt()