Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
@@ -383,6 +383,8 @@ def display_discourse_comparison(analysis: dict, t: dict):
|
|
383 |
st.info(t.get('no_concepts2', 'No hay conceptos disponibles para el Texto 2'))
|
384 |
|
385 |
|
|
|
|
|
386 |
#################################################################################
|
387 |
def display_chat_activities(username: str, t: dict):
|
388 |
"""
|
@@ -433,4 +435,29 @@ def display_chat_activities(username: str, t: dict):
|
|
433 |
logger.error(f"Error mostrando historial del chat: {str(e)}")
|
434 |
st.error(t.get('error_chat', 'Error al mostrar historial del chat'))
|
435 |
|
436 |
-
#################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
st.info(t.get('no_concepts2', 'No hay conceptos disponibles para el Texto 2'))
|
384 |
|
385 |
|
386 |
+
|
387 |
+
|
388 |
#################################################################################
|
389 |
def display_chat_activities(username: str, t: dict):
|
390 |
"""
|
|
|
435 |
logger.error(f"Error mostrando historial del chat: {str(e)}")
|
436 |
st.error(t.get('error_chat', 'Error al mostrar historial del chat'))
|
437 |
|
438 |
+
#################################################################################
|
439 |
+
|
440 |
+
def clean_chat_content(content: str) -> str:
|
441 |
+
"""Limpia caracteres especiales del contenido del chat"""
|
442 |
+
if not content:
|
443 |
+
return content
|
444 |
+
|
445 |
+
# Eliminar caracteres de bloque y otros especiales
|
446 |
+
special_chars = ["▌", "\u2588", "\u2580", "\u2584", "\u258C", "\u2590"]
|
447 |
+
for char in special_chars:
|
448 |
+
content = content.replace(char, "")
|
449 |
+
|
450 |
+
# Normalizar espacios y saltos de línea
|
451 |
+
content = re.sub(r'\s+', ' ', content).strip()
|
452 |
+
return content
|
453 |
+
|
454 |
+
# Modificar el loop de visualización en display_chat_activities:
|
455 |
+
for message in chat['messages']:
|
456 |
+
role = message.get('role', 'unknown')
|
457 |
+
content = clean_chat_content(message.get('content', ''))
|
458 |
+
|
459 |
+
with st.chat_message(role):
|
460 |
+
st.markdown(content)
|
461 |
+
|
462 |
+
st.divider()
|
463 |
+
|