|
import streamlit as st |
|
from utils import get_bot_response |
|
|
|
|
|
st.set_page_config(page_title="Chatbot de Servicios Digitales", layout="centered") |
|
|
|
|
|
st.title("Chatbot de Servicios Digitales") |
|
st.write("隆Hola! Soy tu asistente virtual. Estoy aqu铆 para ayudarte con servicios de desarrollo web, apps m贸viles, ideas de IA y an谩lisis con Power BI.") |
|
|
|
|
|
if "chat_history" not in st.session_state: |
|
st.session_state.chat_history = [] |
|
|
|
|
|
def display_chat(): |
|
for chat in st.session_state.chat_history: |
|
if chat["role"] == "user": |
|
st.markdown(f"**T煤:** {chat['message']}") |
|
else: |
|
st.markdown(f"**Bot:** {chat['message']}") |
|
|
|
|
|
display_chat() |
|
|
|
|
|
with st.form(key="chat_form", clear_on_submit=True): |
|
user_input = st.text_input("Escribe tu mensaje aqu铆:") |
|
submit_button = st.form_submit_button(label="Enviar") |
|
|
|
if submit_button and user_input: |
|
|
|
st.session_state.chat_history.append({"role": "user", "message": user_input}) |
|
|
|
bot_response = get_bot_response(user_input) |
|
st.session_state.chat_history.append({"role": "bot", "message": bot_response}) |
|
|
|
st.experimental_rerun() |
|
|