File size: 842 Bytes
77d6f24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# chatbot/chat_interface.py
import streamlit as st
from .chatbot import AIdeaTextChatbot

def display_chat_interface(lang_code: str, chat_translations: Dict):
    """
    Muestra la interfaz del chat
    """
    # Inicializar chatbot si no existe
    if 'chatbot' not in st.session_state:
        st.session_state.chatbot = AIdeaTextChatbot(lang_code)

    # Mostrar historial
    for msg in st.session_state.chatbot.get_conversation_history():
        with st.chat_message(msg[0]):
            st.write(msg[1])

    # Input del usuario
    if prompt := st.chat_input(chat_translations.get('chat_placeholder', 'Escribe tu mensaje...')):
        # Procesar mensaje
        response = st.session_state.chatbot.process_message(prompt)
        
        # Mostrar respuesta
        with st.chat_message("assistant"):
            st.write(response)