JirasakJo commited on
Commit
9d235fe
·
verified ·
1 Parent(s): 462065b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -277,7 +277,8 @@ def main():
277
  query = st.text_input(
278
  "",
279
  placeholder="เช่น: วันสุดท้ายของการสอบปากเปล่าในภาคเรียนที่ 1/2567 คือวันที่เท่าไร?",
280
- key="query_input"
 
281
  )
282
 
283
  # Button layout inside main() function
@@ -323,8 +324,8 @@ def main():
323
  with st.expander("🔍 รายละเอียดการวิเคราะห์คำถาม", expanded=False):
324
  st.json(result["query_info"])
325
 
326
- # Clear input box and rerun app
327
- st.session_state.query_input = ""
328
  st.rerun()
329
 
330
  except Exception as e:
 
277
  query = st.text_input(
278
  "",
279
  placeholder="เช่น: วันสุดท้ายของการสอบปากเปล่าในภาคเรียนที่ 1/2567 คือวันที่เท่าไร?",
280
+ key="query_input",
281
+ value="" if 'clear_input' in st.session_state and st.session_state.clear_input else st.session_state.get('query_input', '')
282
  )
283
 
284
  # Button layout inside main() function
 
324
  with st.expander("🔍 รายละเอียดการวิเคราะห์คำถาม", expanded=False):
325
  st.json(result["query_info"])
326
 
327
+ # Clear the input after successful submission
328
+ st.session_state.clear_input = True
329
  st.rerun()
330
 
331
  except Exception as e: