Chatbot / app.py
AkashKhatri's picture
Rename streamlit_app.py to app.py
6a4abe3 verified
raw
history blame contribute delete
No virus
922 Bytes
# streamlit_app.py
import streamlit as st
from chatbot import generate_response
st.title("Chatbot with Hugging Face and Streamlit")
user_id = st.text_input("User ID", value="user1")
user_input = st.text_input("Your message:")
if "chat_history" not in st.session_state:
st.session_state.chat_history = {}
if user_id not in st.session_state.chat_history:
st.session_state.chat_history[user_id] = []
if st.button("Send"):
if user_input:
response, st.session_state.chat_history[user_id] = generate_response(
user_input, st.session_state.chat_history[user_id]
)
st.session_state.chat_history[user_id].append((user_input, response))
st.write("## Chat History")
if user_id in st.session_state.chat_history:
for user_message, bot_response in st.session_state.chat_history[user_id]:
st.write(f"**You:** {user_message}")
st.write(f"**Bot:** {bot_response}")