AIdeaText commited on
Commit
713569b
·
verified ·
1 Parent(s): 76e552d

Update modules/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui.py +12 -5
modules/ui.py CHANGED
@@ -438,12 +438,19 @@ def display_chatbot_interface(lang_code):
438
 
439
  with st.chat_message("assistant"):
440
  message_placeholder = st.empty()
441
- full_response = ""
442
- for response in get_chatbot_response(st.session_state.chatbot, prompt, lang_code):
443
- full_response += response + " "
444
- message_placeholder.markdown(full_response + "▌")
 
 
445
  message_placeholder.markdown(full_response)
 
446
  st.session_state.messages.append({"role": "assistant", "content": full_response})
447
 
448
  # Guardar la conversación en la base de datos
449
- store_chat_history(st.session_state.username, st.session_state.messages)
 
 
 
 
 
438
 
439
  with st.chat_message("assistant"):
440
  message_placeholder = st.empty()
441
+ full_response = get_chatbot_response(st.session_state.chatbot, prompt, lang_code)
442
+
443
+ # Simular escritura gradual
444
+ for i in range(len(full_response)):
445
+ message_placeholder.markdown(full_response[:i+1] + "▌")
446
+ time.sleep(0.01)
447
  message_placeholder.markdown(full_response)
448
+
449
  st.session_state.messages.append({"role": "assistant", "content": full_response})
450
 
451
  # Guardar la conversación en la base de datos
452
+ store_chat_history(st.session_state.username, st.session_state.messages)
453
+
454
+ # Mostrar el número de llamadas a la API restantes
455
+ remaining_calls = 50 - st.session_state.get('api_calls', 0)
456
+ st.sidebar.write(f"Llamadas a la API restantes: {remaining_calls}")