Create ui.py
Browse files- modules/ui.py +59 -0
modules/ui.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# modules/ui.py
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
from .database import get_student_data
|
| 5 |
+
from .morpho_analysis import get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
|
| 6 |
+
from .syntax_analysis import visualize_syntax
|
| 7 |
+
|
| 8 |
+
def display_chat_interface():
|
| 9 |
+
st.markdown("### Chat con AIdeaText")
|
| 10 |
+
|
| 11 |
+
# Initialize chat history if it doesn't exist
|
| 12 |
+
if 'chat_history' not in st.session_state:
|
| 13 |
+
st.session_state.chat_history = []
|
| 14 |
+
|
| 15 |
+
# Display chat history
|
| 16 |
+
for i, (role, text) in enumerate(st.session_state.chat_history):
|
| 17 |
+
if role == "user":
|
| 18 |
+
st.text_area(f"Tú:", value=text, height=50, key=f"user_message_{i}", disabled=True)
|
| 19 |
+
else:
|
| 20 |
+
st.text_area(f"AIdeaText:", value=text, height=50, key=f"bot_message_{i}", disabled=True)
|
| 21 |
+
|
| 22 |
+
# User input field
|
| 23 |
+
user_input = st.text_input("Escribe tu mensaje aquí:")
|
| 24 |
+
|
| 25 |
+
if st.button("Enviar"):
|
| 26 |
+
if user_input:
|
| 27 |
+
# Add user message to history
|
| 28 |
+
st.session_state.chat_history.append(("user", user_input))
|
| 29 |
+
|
| 30 |
+
# Get chatbot response (esta función debe estar definida en otro lugar)
|
| 31 |
+
response = get_chatbot_response(user_input)
|
| 32 |
+
|
| 33 |
+
# Add chatbot response to history
|
| 34 |
+
st.session_state.chat_history.append(("bot", response))
|
| 35 |
+
|
| 36 |
+
# Clear input field
|
| 37 |
+
st.experimental_rerun()
|
| 38 |
+
|
| 39 |
+
def display_student_progress(student_data):
|
| 40 |
+
st.success("Datos obtenidos exitosamente")
|
| 41 |
+
|
| 42 |
+
# Mostrar estadísticas generales
|
| 43 |
+
st.subheader("Estadísticas generales")
|
| 44 |
+
st.write(f"Total de entradas: {student_data['entries_count']}")
|
| 45 |
+
|
| 46 |
+
# Mostrar gráfico de conteo de palabras
|
| 47 |
+
st.subheader("Conteo de palabras por categoría")
|
| 48 |
+
st.bar_chart(student_data['word_count'])
|
| 49 |
+
|
| 50 |
+
# Mostrar entradas recientes
|
| 51 |
+
st.subheader("Entradas recientes")
|
| 52 |
+
for entry in student_data['entries'][:5]: # Mostrar las 5 entradas más recientes
|
| 53 |
+
st.text_area(f"Entrada del {entry['timestamp']}", entry['text'], height=100)
|
| 54 |
+
|
| 55 |
+
def display_text_analysis_interface(nlp_models, lang_code):
|
| 56 |
+
# Aquí va tu lógica actual para la interfaz de análisis de texto
|
| 57 |
+
# ...
|
| 58 |
+
|
| 59 |
+
# Puedes agregar más funciones de UI según sea necesario
|