Mpavan45 commited on
Commit
5e1ad3d
·
verified ·
1 Parent(s): a1bfbea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -99,7 +99,7 @@ with chat_container:
99
  st.markdown(content)
100
 
101
  # User input stays at the bottom
102
- user_input = st.text_input("Type your message here:", "", key="user_input")
103
 
104
  if user_input:
105
  save_message(session_id, "user", user_input)
@@ -112,10 +112,10 @@ if user_input:
112
  save_message(session_id, "assistant", response)
113
  st.session_state.messages.append(("assistant", response))
114
 
115
- # Refresh the chat container but keep history sticky
116
  with chat_container:
117
  with st.chat_message("assistant"):
118
  st.markdown(response)
119
 
120
- # Clear input field
121
- st.session_state.user_input = ""
 
99
  st.markdown(content)
100
 
101
  # User input stays at the bottom
102
+ user_input = st.text_input("Type your message here:", key="user_message")
103
 
104
  if user_input:
105
  save_message(session_id, "user", user_input)
 
112
  save_message(session_id, "assistant", response)
113
  st.session_state.messages.append(("assistant", response))
114
 
115
+ # Refresh chat UI
116
  with chat_container:
117
  with st.chat_message("assistant"):
118
  st.markdown(response)
119
 
120
+ # Clear input field after message submission
121
+ st.session_state.pop("user_message")