Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
@@ -434,6 +434,24 @@ def display_chat_activities(username: str, t: dict):
|
|
434 |
except Exception as e:
|
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 |
|
|
|
434 |
except Exception as e:
|
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 |
+
# Aseg煤rate que no haya c贸digo suelto fuera de funciones que intente acceder a 'chat'
|
439 |
+
# Si necesitas procesar chats fuera de esta funci贸n, crea una nueva funci贸n:
|
440 |
+
|
441 |
+
def get_formatted_chats(username: str, limit: int = 50) -> list:
|
442 |
+
"""Obtiene chats formateados para uso externo"""
|
443 |
+
chat_history = get_chat_history(
|
444 |
+
username=username,
|
445 |
+
analysis_type='sidebar',
|
446 |
+
limit=limit
|
447 |
+
)
|
448 |
+
return [
|
449 |
+
{
|
450 |
+
'timestamp': chat['timestamp'],
|
451 |
+
'messages': chat.get('messages', [])
|
452 |
+
}
|
453 |
+
for chat in reversed(chat_history)
|
454 |
+
] if chat_history else []
|
455 |
|
456 |
#################################################################################
|
457 |
|