Update modules/ui.py
Browse files- modules/ui.py +44 -6
modules/ui.py
CHANGED
@@ -13,11 +13,11 @@ from spacy import displacy
|
|
13 |
from .auth import authenticate_user, register_user, get_user_role
|
14 |
from .database import get_student_data, store_morphosyntax_result, store_semantic_result
|
15 |
|
16 |
-
#
|
17 |
from .morpho_analysis import generate_arc_diagram, get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
|
18 |
from .semantic_analysis import visualize_semantic_relations, perform_semantic_analysis
|
19 |
from .discourse_analysis import compare_semantic_analysis, perform_discourse_analysis
|
20 |
-
|
21 |
|
22 |
##################################################################################################
|
23 |
def login_register_page():
|
@@ -392,7 +392,45 @@ def display_discourse_analysis_interface(nlp_models, lang_code):
|
|
392 |
st.pyplot(graph2)
|
393 |
|
394 |
##################################################################################################
|
395 |
-
def
|
396 |
-
|
397 |
-
|
398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
from .auth import authenticate_user, register_user, get_user_role
|
14 |
from .database import get_student_data, store_morphosyntax_result, store_semantic_result
|
15 |
|
16 |
+
#Importaciones locales funciones de an谩lisis
|
17 |
from .morpho_analysis import generate_arc_diagram, get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
|
18 |
from .semantic_analysis import visualize_semantic_relations, perform_semantic_analysis
|
19 |
from .discourse_analysis import compare_semantic_analysis, perform_discourse_analysis
|
20 |
+
from .chatbot import initialize_chatbot, get_chatbot_response
|
21 |
|
22 |
##################################################################################################
|
23 |
def login_register_page():
|
|
|
392 |
st.pyplot(graph2)
|
393 |
|
394 |
##################################################################################################
|
395 |
+
def display_chatbot_interface(lang_code):
|
396 |
+
translations = {
|
397 |
+
'es': {
|
398 |
+
'title': "AIdeaText - Chatbot Llama 2",
|
399 |
+
'input_placeholder': "Escribe tu mensaje aqu铆...",
|
400 |
+
'send_button': "Enviar",
|
401 |
+
},
|
402 |
+
'en': {
|
403 |
+
'title': "AIdeaText - Llama 2 Chatbot",
|
404 |
+
'input_placeholder': "Type your message here...",
|
405 |
+
'send_button': "Send",
|
406 |
+
},
|
407 |
+
'fr': {
|
408 |
+
'title': "AIdeaText - Chatbot Llama 2",
|
409 |
+
'input_placeholder': "脡crivez votre message ici...",
|
410 |
+
'send_button': "Envoyer",
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
t = translations[lang_code]
|
415 |
+
|
416 |
+
st.header(t['title'])
|
417 |
+
|
418 |
+
if 'chatbot' not in st.session_state:
|
419 |
+
st.session_state.chatbot = initialize_chatbot()
|
420 |
+
|
421 |
+
if 'messages' not in st.session_state:
|
422 |
+
st.session_state.messages = []
|
423 |
+
|
424 |
+
for message in st.session_state.messages:
|
425 |
+
with st.chat_message(message["role"]):
|
426 |
+
st.markdown(message["content"])
|
427 |
+
|
428 |
+
if prompt := st.chat_input(t['input_placeholder']):
|
429 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
430 |
+
with st.chat_message("user"):
|
431 |
+
st.markdown(prompt)
|
432 |
+
|
433 |
+
with st.chat_message("assistant"):
|
434 |
+
response = get_chatbot_response(st.session_state.chatbot, prompt)
|
435 |
+
st.markdown(response)
|
436 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|