AkashKhatri commited on
Commit
59e351b
1 Parent(s): 28aa259

Create streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +27 -0
streamlit_app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # streamlit_app.py
2
+ import streamlit as st
3
+ from chatbot import generate_response
4
+
5
+ st.title("Chatbot with Hugging Face and Streamlit")
6
+
7
+ user_id = st.text_input("User ID", value="user1")
8
+ user_input = st.text_input("Your message:")
9
+
10
+ if "chat_history" not in st.session_state:
11
+ st.session_state.chat_history = {}
12
+
13
+ if user_id not in st.session_state.chat_history:
14
+ st.session_state.chat_history[user_id] = []
15
+
16
+ if st.button("Send"):
17
+ if user_input:
18
+ response, st.session_state.chat_history[user_id] = generate_response(
19
+ user_input, st.session_state.chat_history[user_id]
20
+ )
21
+ st.session_state.chat_history[user_id].append((user_input, response))
22
+
23
+ st.write("## Chat History")
24
+ if user_id in st.session_state.chat_history:
25
+ for user_message, bot_response in st.session_state.chat_history[user_id]:
26
+ st.write(f"**You:** {user_message}")
27
+ st.write(f"**Bot:** {bot_response}")