Update app.py
Browse files
app.py
CHANGED
@@ -3,61 +3,27 @@ from utils import get_answer
|
|
3 |
|
4 |
# Streamlit app layout
|
5 |
st.title("Know More About Israel Hamas War")
|
6 |
-
st.write("Welcome to the chatbot. Ask me anything regarding
|
7 |
|
8 |
# Session state to store the conversation
|
9 |
if 'conversation' not in st.session_state:
|
10 |
st.session_state.conversation = []
|
11 |
|
12 |
-
#
|
13 |
-
st.
|
14 |
-
<style>
|
15 |
-
.chat-history {
|
16 |
-
max-height: 400px;
|
17 |
-
overflow-y: scroll;
|
18 |
-
padding: 10px;
|
19 |
-
border: 1px solid #ccc;
|
20 |
-
border-radius: 5px;
|
21 |
-
background-color: #f9f9f9;
|
22 |
-
}
|
23 |
-
.chat-message {
|
24 |
-
padding: 5px;
|
25 |
-
margin-bottom: 10px;
|
26 |
-
border-radius: 5px;
|
27 |
-
}
|
28 |
-
.user-message {
|
29 |
-
background-color: #d1e7dd;
|
30 |
-
text-align: right;
|
31 |
-
}
|
32 |
-
.bot-message {
|
33 |
-
background-color: #f8d7da;
|
34 |
-
}
|
35 |
-
</style>
|
36 |
-
""", unsafe_allow_html=True)
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
# Get bot response
|
47 |
-
bot_response = get_answer(user_input)
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
st.session_state.conversation.append(("bot", bot_response))
|
52 |
-
|
53 |
-
# Clear the input box
|
54 |
-
st.session_state.input_box = ""
|
55 |
|
56 |
# Display conversation
|
57 |
-
st.
|
58 |
-
|
59 |
-
if sender == "user":
|
60 |
-
st.markdown(f'<div class="chat-message user-message">{message}</div>', unsafe_allow_html=True)
|
61 |
-
else:
|
62 |
-
st.markdown(f'<div class="chat-message bot-message">{message}</div>', unsafe_allow_html=True)
|
63 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
3 |
|
4 |
# Streamlit app layout
|
5 |
st.title("Know More About Israel Hamas War")
|
6 |
+
st.write("Welcome to the chatbot. Ask me anything regarding Israel Hamas War!!")
|
7 |
|
8 |
# Session state to store the conversation
|
9 |
if 'conversation' not in st.session_state:
|
10 |
st.session_state.conversation = []
|
11 |
|
12 |
+
# Input box for user
|
13 |
+
user_input = st.text_input("You:", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
if st.button("Send"):
|
16 |
+
if user_input:
|
17 |
+
# Get bot response
|
18 |
+
bot_response = get_answer(user_input)
|
19 |
|
20 |
+
# Append both user input and bot response to conversation
|
21 |
+
st.session_state.conversation.append(f"You: {user_input}")
|
22 |
+
st.session_state.conversation.append(bot_response)
|
|
|
|
|
23 |
|
24 |
+
# Clear the input box
|
25 |
+
st.experimental_rerun()
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Display conversation
|
28 |
+
for line in st.session_state.conversation:
|
29 |
+
st.write(line)
|
|
|
|
|
|
|
|
|
|