Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -124,64 +124,27 @@ def process_feedback(query, response, feedback):
|
|
124 |
|
125 |
# Streamlit interface
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
import streamlit as st
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
if "
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
for i, message in enumerate(st.session_state.messages):
|
149 |
-
with st.chat_message(message["role"]):
|
150 |
-
st.markdown(message["content"])
|
151 |
-
if message["role"] == "assistant":
|
152 |
-
col1, col2 = st.columns([1, 15])
|
153 |
-
with col1:
|
154 |
-
if st.button("👍", key=f"thumbs_up_{i}"):
|
155 |
-
process_feedback(st.session_state.messages[i-1]["content"], message["content"], True)
|
156 |
-
with col2:
|
157 |
-
if st.button("👎", key=f"thumbs_down_{i}"):
|
158 |
-
process_feedback(st.session_state.messages[i-1]["content"], message["content"], False)
|
159 |
-
|
160 |
-
# Nhận input người dùng
|
161 |
-
if prompt := st.chat_input("Ask me any question related to MBAL"):
|
162 |
-
# Hiển thị tin nhắn người dùng
|
163 |
-
st.chat_message("user").markdown(prompt)
|
164 |
-
st.session_state.messages.append({"role": "user", "content": prompt})
|
165 |
-
memory.chat_memory.add_user_message(prompt)
|
166 |
-
|
167 |
-
# Gọi hàm RAG để trả lời
|
168 |
-
response = rag_query(prompt)
|
169 |
-
|
170 |
-
# Hiển thị tin nhắn chatbot
|
171 |
-
with st.chat_message("assistant"):
|
172 |
-
st.markdown(response)
|
173 |
-
st.session_state.messages.append({"role": "assistant", "content": response})
|
174 |
-
memory.chat_memory.add_ai_message(response)
|
175 |
-
|
176 |
-
st.rerun()
|
177 |
-
|
178 |
-
# Sidebar
|
179 |
-
# with st.sidebar:
|
180 |
-
# st.header("Lựa chọn khác")
|
181 |
-
# if st.button("Xóa lịch sử chat"):
|
182 |
-
# st.session_state.messages = []
|
183 |
-
# memory.clear()
|
184 |
-
# st.rerun()
|
185 |
|
186 |
|
187 |
st.markdown("<div style='text-align:center;'></div>", unsafe_allow_html=True)
|
|
|
124 |
|
125 |
# Streamlit interface
|
126 |
|
127 |
+
st.title("Chào mừng bạn đã đến với MBAL Chatbot")
|
128 |
+
st.markdown("***")
|
129 |
+
st.info('''
|
130 |
+
Tôi sẽ giải đáp các thắc mắc của bạn liên quan đến các sản phẩm bảo hiểm nhân thọ của MB Ageas Life''')
|
131 |
|
132 |
+
col1, col2 = st.columns(2)
|
133 |
|
134 |
+
with col1:
|
135 |
+
chat = st.button("Chat")
|
136 |
+
if chat:
|
137 |
+
st.switch_page("pages/chatbot.py")
|
138 |
import streamlit as st
|
139 |
+
|
140 |
+
|
141 |
+
Sidebar
|
142 |
+
with st.sidebar:
|
143 |
+
st.header("Lựa chọn khác")
|
144 |
+
if st.button("Xóa lịch sử chat"):
|
145 |
+
st.session_state.messages = []
|
146 |
+
memory.clear()
|
147 |
+
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
|
150 |
st.markdown("<div style='text-align:center;'></div>", unsafe_allow_html=True)
|