Download modules/chatbot/chat_interface.py from AIdeaText/v5Prod: direct link, hf CLI and curl.
- Browser
- Download file 866 Bytes
-
https://huggingface.co/spaces/AIdeaText/v5Prod/resolve/34d4eea9dff39293ff54e5aeaf85a695cbde6bfb/modules/chatbot/chat_interface.py
- Command line
-
hf download hf://spaces/AIdeaText/v5Prod@34d4eea9dff39293ff54e5aeaf85a695cbde6bfb/modules/chatbot/chat_interface.py
-
curl -L -o chat_interface.py https://huggingface.co/spaces/AIdeaText/v5Prod/resolve/34d4eea9dff39293ff54e5aeaf85a695cbde6bfb/modules/chatbot/chat_interface.py
866 Bytes
| # 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) |