ngcanh commited on
Commit
371f703
·
verified ·
1 Parent(s): 9a4c66f

Update pages/chatbot.py

Browse files
Files changed (1) hide show
  1. pages/chatbot.py +12 -12
pages/chatbot.py CHANGED
@@ -12,16 +12,16 @@ if "messages" not in st.session_state:
12
  for i, message in enumerate(st.session_state.messages):
13
  with st.chat_message(message["role"]):
14
  st.markdown(message["content"])
15
- # if message["role"] == "assistant":
16
- # col1, col2 = st.columns([1,15])
17
- # with col1:
18
- # if st.button("👍", key=f"thumbs_up_{i}"):
19
- # process_feedback(st.session_state.messages[i-1]["content"], message["content"], True)
20
- # with col2:
21
- # if st.button("👎", key=f"thumbs_down_{i}"):
22
- # process_feedback(st.session_state.messages[i-1]["content"], message["content"], False)
23
- # # st.session_state.messages.pop() # Remove the last assistant message
24
- # #st.rerun() # Rerun the app to regenerate the response
25
 
26
  # React to user input
27
  if prompt := st.chat_input("Bạn cần tư vấn về điều gì? Hãy chia sẻ nhu cầu và thông tin của bạn nhé!"):
@@ -38,8 +38,8 @@ if prompt := st.chat_input("Bạn cần tư vấn về điều gì? Hãy chia s
38
  # Add assistant response to chat history
39
  st.session_state.messages.append({"role": "assistant", "content": response})
40
 
41
- # # Rerun the app to display the feedback buttons
42
- # st.rerun()
43
 
44
  # Sidebar for additional controls
45
  with st.sidebar:
 
12
  for i, message in enumerate(st.session_state.messages):
13
  with st.chat_message(message["role"]):
14
  st.markdown(message["content"])
15
+ if message["role"] == "assistant":
16
+ col1, col2 = st.columns([1,15])
17
+ with col1:
18
+ if st.button("👍", key=f"thumbs_up_{i}"):
19
+ process_feedback(st.session_state.messages[i-1]["content"], message["content"], True)
20
+ with col2:
21
+ if st.button("👎", key=f"thumbs_down_{i}"):
22
+ process_feedback(st.session_state.messages[i-1]["content"], message["content"], False)
23
+ # st.session_state.messages.pop() # Remove the last assistant message
24
+ #st.rerun() # Rerun the app to regenerate the response
25
 
26
  # React to user input
27
  if prompt := st.chat_input("Bạn cần tư vấn về điều gì? Hãy chia sẻ nhu cầu và thông tin của bạn nhé!"):
 
38
  # Add assistant response to chat history
39
  st.session_state.messages.append({"role": "assistant", "content": response})
40
 
41
+ # Rerun the app to display the feedback buttons
42
+ st.rerun()
43
 
44
  # Sidebar for additional controls
45
  with st.sidebar: