test2 / modules /ui.py
AIdeaText's picture
Create ui.py
c863052 verified
raw
history blame
No virus
2.25 kB
# modules/ui.py
import streamlit as st
from .database import get_student_data
from .morpho_analysis import get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
from .syntax_analysis import visualize_syntax
def display_chat_interface():
st.markdown("### Chat con AIdeaText")
# Initialize chat history if it doesn't exist
if 'chat_history' not in st.session_state:
st.session_state.chat_history = []
# Display chat history
for i, (role, text) in enumerate(st.session_state.chat_history):
if role == "user":
st.text_area(f"Tú:", value=text, height=50, key=f"user_message_{i}", disabled=True)
else:
st.text_area(f"AIdeaText:", value=text, height=50, key=f"bot_message_{i}", disabled=True)
# User input field
user_input = st.text_input("Escribe tu mensaje aquí:")
if st.button("Enviar"):
if user_input:
# Add user message to history
st.session_state.chat_history.append(("user", user_input))
# Get chatbot response (esta función debe estar definida en otro lugar)
response = get_chatbot_response(user_input)
# Add chatbot response to history
st.session_state.chat_history.append(("bot", response))
# Clear input field
st.experimental_rerun()
def display_student_progress(student_data):
st.success("Datos obtenidos exitosamente")
# Mostrar estadísticas generales
st.subheader("Estadísticas generales")
st.write(f"Total de entradas: {student_data['entries_count']}")
# Mostrar gráfico de conteo de palabras
st.subheader("Conteo de palabras por categoría")
st.bar_chart(student_data['word_count'])
# Mostrar entradas recientes
st.subheader("Entradas recientes")
for entry in student_data['entries'][:5]: # Mostrar las 5 entradas más recientes
st.text_area(f"Entrada del {entry['timestamp']}", entry['text'], height=100)
def display_text_analysis_interface(nlp_models, lang_code):
# Aquí va tu lógica actual para la interfaz de análisis de texto
# ...
# Puedes agregar más funciones de UI según sea necesario