Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
@@ -215,6 +215,64 @@ def display_discourse_comparison(analysis: dict, t: dict):
|
|
215 |
df2 = pd.DataFrame(analysis['key_concepts2'])
|
216 |
st.dataframe(df2)
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
'''
|
219 |
##########versi贸n 25-9-2024---02:30 ################ OK (username)####################
|
220 |
|
|
|
215 |
df2 = pd.DataFrame(analysis['key_concepts2'])
|
216 |
st.dataframe(df2)
|
217 |
|
218 |
+
#################################################################################
|
219 |
+
def display_chat_activities(username: str, t: dict):
|
220 |
+
"""
|
221 |
+
Muestra historial de conversaciones del chat
|
222 |
+
"""
|
223 |
+
try:
|
224 |
+
# Obtener historial del chat
|
225 |
+
chat_history = get_chat_history(
|
226 |
+
username=username,
|
227 |
+
analysis_type='sidebar',
|
228 |
+
limit=50
|
229 |
+
)
|
230 |
+
|
231 |
+
if not chat_history:
|
232 |
+
st.info(t.get('no_chat_history', 'No hay conversaciones registradas'))
|
233 |
+
return
|
234 |
+
|
235 |
+
for chat in reversed(chat_history): # Mostrar las m谩s recientes primero
|
236 |
+
try:
|
237 |
+
# Convertir timestamp a datetime para formato
|
238 |
+
timestamp = datetime.fromisoformat(chat['timestamp'].replace('Z', '+00:00'))
|
239 |
+
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
240 |
+
|
241 |
+
with st.expander(
|
242 |
+
f"{t.get('chat_date', 'Fecha de conversaci贸n')}: {formatted_date}",
|
243 |
+
expanded=False
|
244 |
+
):
|
245 |
+
if 'messages' in chat and chat['messages']:
|
246 |
+
# Mostrar cada mensaje en la conversaci贸n
|
247 |
+
for message in chat['messages']:
|
248 |
+
role = message.get('role', 'unknown')
|
249 |
+
content = message.get('content', '')
|
250 |
+
|
251 |
+
# Usar el componente de chat de Streamlit
|
252 |
+
with st.chat_message(role):
|
253 |
+
st.markdown(content)
|
254 |
+
|
255 |
+
# Agregar separador entre mensajes
|
256 |
+
st.divider()
|
257 |
+
else:
|
258 |
+
st.warning(t.get('invalid_chat_format', 'Formato de chat no v谩lido'))
|
259 |
+
|
260 |
+
except Exception as e:
|
261 |
+
logger.error(f"Error mostrando conversaci贸n: {str(e)}")
|
262 |
+
continue
|
263 |
+
|
264 |
+
except Exception as e:
|
265 |
+
logger.error(f"Error mostrando historial del chat: {str(e)}")
|
266 |
+
st.error(t.get('error_chat', 'Error al mostrar historial del chat'))
|
267 |
+
|
268 |
+
|
269 |
+
|
270 |
+
|
271 |
+
|
272 |
+
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
'''
|
277 |
##########versi贸n 25-9-2024---02:30 ################ OK (username)####################
|
278 |
|