Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
#AIdeaText
|
| 2 |
-
#app.py
|
| 3 |
import logging
|
| 4 |
import streamlit as st
|
| 5 |
import sys
|
|
@@ -13,7 +13,7 @@ st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")
|
|
| 13 |
|
| 14 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 15 |
|
| 16 |
-
|
| 17 |
from translations import get_translations
|
| 18 |
from session_state import initialize_session_state
|
| 19 |
from modules.ui.ui import main as ui_main
|
|
@@ -60,11 +60,6 @@ from modules.database.semantic_mongo_db import (
|
|
| 60 |
get_student_semantic_analysis
|
| 61 |
)
|
| 62 |
|
| 63 |
-
from modules.database.chat_db import (
|
| 64 |
-
store_chat_history,
|
| 65 |
-
get_chat_history
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
from modules.studentact.student_activities_v2 import display_student_progress
|
| 69 |
from modules.auth.auth import (
|
| 70 |
authenticate_student,
|
|
@@ -73,12 +68,6 @@ from modules.auth.auth import (
|
|
| 73 |
delete_student
|
| 74 |
)
|
| 75 |
from modules.admin.admin_ui import admin_page
|
| 76 |
-
from modules.chatbot.chatbot import (
|
| 77 |
-
initialize_chatbot,
|
| 78 |
-
process_chat_input
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
print("Configurando página")
|
| 82 |
|
| 83 |
logging.basicConfig(level=logging.INFO)
|
| 84 |
logger = logging.getLogger(__name__)
|
|
@@ -95,7 +84,9 @@ def app_main():
|
|
| 95 |
logger.info("Entrando en app_main()")
|
| 96 |
|
| 97 |
# Inicializar el estado de la sesión
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
|
| 100 |
# Inicializar conexiones a bases de datos si no se ha hecho
|
| 101 |
if 'db_initialized' not in st.session_state:
|
|
@@ -107,10 +98,6 @@ def app_main():
|
|
| 107 |
st.session_state.nlp_models = initialize_nlp_models()
|
| 108 |
logger.info("Modelos NLP inicializados y almacenados en la sesión")
|
| 109 |
|
| 110 |
-
# Inicializar contador de widgets si no existe
|
| 111 |
-
if 'widget_counter' not in st.session_state:
|
| 112 |
-
st.session_state.widget_counter = 0
|
| 113 |
-
|
| 114 |
# Inicializar estados de análisis si no existen
|
| 115 |
if 'morphosyntax_state' not in st.session_state:
|
| 116 |
st.session_state.morphosyntax_state = {
|
|
@@ -128,6 +115,10 @@ def app_main():
|
|
| 128 |
if 'page' not in st.session_state:
|
| 129 |
st.session_state.page = 'login'
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
logger.info(f"Página actual: {st.session_state.page}")
|
| 132 |
logger.info(f"Rol del usuario: {st.session_state.role}")
|
| 133 |
|
|
@@ -144,5 +135,4 @@ def app_main():
|
|
| 144 |
st.rerun()
|
| 145 |
|
| 146 |
if __name__ == "__main__":
|
| 147 |
-
print("Llamando a app_main()")
|
| 148 |
app_main()
|
|
|
|
| 1 |
+
# AIdeaText v3
|
| 2 |
+
# app.py
|
| 3 |
import logging
|
| 4 |
import streamlit as st
|
| 5 |
import sys
|
|
|
|
| 13 |
|
| 14 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 15 |
|
| 16 |
+
# Importaciones locales
|
| 17 |
from translations import get_translations
|
| 18 |
from session_state import initialize_session_state
|
| 19 |
from modules.ui.ui import main as ui_main
|
|
|
|
| 60 |
get_student_semantic_analysis
|
| 61 |
)
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
from modules.studentact.student_activities_v2 import display_student_progress
|
| 64 |
from modules.auth.auth import (
|
| 65 |
authenticate_student,
|
|
|
|
| 68 |
delete_student
|
| 69 |
)
|
| 70 |
from modules.admin.admin_ui import admin_page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
logging.basicConfig(level=logging.INFO)
|
| 73 |
logger = logging.getLogger(__name__)
|
|
|
|
| 84 |
logger.info("Entrando en app_main()")
|
| 85 |
|
| 86 |
# Inicializar el estado de la sesión
|
| 87 |
+
if 'initialized' not in st.session_state:
|
| 88 |
+
initialize_session_state()
|
| 89 |
+
st.session_state.initialized = True
|
| 90 |
|
| 91 |
# Inicializar conexiones a bases de datos si no se ha hecho
|
| 92 |
if 'db_initialized' not in st.session_state:
|
|
|
|
| 98 |
st.session_state.nlp_models = initialize_nlp_models()
|
| 99 |
logger.info("Modelos NLP inicializados y almacenados en la sesión")
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
# Inicializar estados de análisis si no existen
|
| 102 |
if 'morphosyntax_state' not in st.session_state:
|
| 103 |
st.session_state.morphosyntax_state = {
|
|
|
|
| 115 |
if 'page' not in st.session_state:
|
| 116 |
st.session_state.page = 'login'
|
| 117 |
|
| 118 |
+
# Prevenir reinicios innecesarios preservando el estado
|
| 119 |
+
if 'selected_tab' not in st.session_state:
|
| 120 |
+
st.session_state.selected_tab = 0
|
| 121 |
+
|
| 122 |
logger.info(f"Página actual: {st.session_state.page}")
|
| 123 |
logger.info(f"Rol del usuario: {st.session_state.role}")
|
| 124 |
|
|
|
|
| 135 |
st.rerun()
|
| 136 |
|
| 137 |
if __name__ == "__main__":
|
|
|
|
| 138 |
app_main()
|