Harsh2001 commited on
Commit
3158180
·
verified ·
1 Parent(s): a060be9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Placeholder for the chatbot's response function
4
+ def get_bot_response(user_input):
5
+ # Here, you would integrate your chatbot's backend
6
+ # For demonstration purposes, we'll use a simple echo response
7
+ return f"Bot: You said '{user_input}'"
8
+
9
+ # Streamlit app layout
10
+ st.title("Chatbot Interface")
11
+ st.write("Welcome to the chatbot. How can I assist you today?")
12
+
13
+ # Session state to store the conversation
14
+ if 'conversation' not in st.session_state:
15
+ st.session_state.conversation = []
16
+
17
+ # Input box for user
18
+ user_input = st.text_input("You:", "")
19
+
20
+ if st.button("Send"):
21
+ if user_input:
22
+ # Get bot response
23
+ bot_response = get_bot_response(user_input)
24
+
25
+ # Append both user input and bot response to conversation
26
+ st.session_state.conversation.append(f"You: {user_input}")
27
+ st.session_state.conversation.append(bot_response)
28
+
29
+ # Clear the input box
30
+ st.experimental_rerun()
31
+
32
+ # Display conversation
33
+ for line in st.session_state.conversation:
34
+ st.write(line)