mathslearn commited on
Commit
5ea2f5b
1 Parent(s): c0e52f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -13,16 +13,20 @@ st.title("Nexus TCM Chatbot")
13
  #query = st.text_input("Query: ", key="input")
14
 
15
  #https://discuss.streamlit.io/t/clear-input-box-after-hitting-enter/33824/2
16
- if 'something' not in st.session_state:
17
- st.session_state.something = ''
 
 
18
 
19
  def submit():
20
- st.session_state.something = st.session_state.widget
21
- st.session_state.widget = ''
22
 
23
- query = st.text_input('Something', key='widget', on_change=submit)
24
 
25
- st.write(f'Last submission: {st.session_state.something}')
 
 
26
 
27
  # Set the logo URL
28
  #logo_url = "https://huggingface.co/spaces/mathslearn/chatbot_test_streamlit/blob/main/logo.jpeg"
 
13
  #query = st.text_input("Query: ", key="input")
14
 
15
  #https://discuss.streamlit.io/t/clear-input-box-after-hitting-enter/33824/2
16
+ #https://discuss.streamlit.io/t/how-do-you-clear-the-input-box-after-hitting-enter/45691/4
17
+ #https://stackoverflow.com/questions/77093266/how-to-clear-input-field-after-hitting-enter-in-streamlit
18
+ if "my_text" not in st.session_state:
19
+ st.session_state.my_text = ""
20
 
21
  def submit():
22
+ st.session_state.my_text = st.session_state.widget
23
+ st.session_state.widget = ""
24
 
25
+ st.text_input("Enter text here", key="widget", on_change=submit)
26
 
27
+ query = st.session_state.my_text
28
+
29
+ st.write(query)
30
 
31
  # Set the logo URL
32
  #logo_url = "https://huggingface.co/spaces/mathslearn/chatbot_test_streamlit/blob/main/logo.jpeg"