ankanghosh commited on
Commit
b273adc
·
verified ·
1 Parent(s): 5d4dde4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -122,9 +122,10 @@ form small {
122
 
123
  # Function to handle query selection
124
  def set_query(query):
125
- st.session_state.last_query = query
126
- st.session_state.submit_clicked = True
127
- st.rerun()
 
128
 
129
  # Function to group questions into rows based on length
130
  def group_buttons(questions, max_chars_per_row=100):
@@ -199,12 +200,12 @@ for row_idx, row in enumerate(question_rows):
199
  cols = st.columns(len(row))
200
  for i, (col, q) in enumerate(zip(cols, row)):
201
  with col:
202
- if st.button(q, key=f"r{row_idx}_q{i}", use_container_width=True):
203
  set_query(q)
204
 
205
  # Function to handle form submission
206
  def handle_form_submit():
207
- if st.session_state.query_input and st.session_state.query_input.strip():
208
  st.session_state.last_query = st.session_state.query_input.strip()
209
  st.session_state.submit_clicked = True
210
  # Increment the form key to force a reset
@@ -214,7 +215,7 @@ def handle_form_submit():
214
  with st.form(key=f"query_form_{st.session_state.form_key}"):
215
  query = st.text_input("Ask your question:", key="query_input",
216
  placeholder="Press enter to submit your question")
217
- submit_button = st.form_submit_button("Get Answer", on_click=handle_form_submit)
218
 
219
  # Display the current question if there is one
220
  if st.session_state.last_query:
 
122
 
123
  # Function to handle query selection
124
  def set_query(query):
125
+ if not st.session_state.processing:
126
+ st.session_state.last_query = query
127
+ st.session_state.submit_clicked = True
128
+ st.rerun()
129
 
130
  # Function to group questions into rows based on length
131
  def group_buttons(questions, max_chars_per_row=100):
 
200
  cols = st.columns(len(row))
201
  for i, (col, q) in enumerate(zip(cols, row)):
202
  with col:
203
+ if st.button(q, key=f"r{row_idx}_q{i}", use_container_width=True, disabled=st.session_state.processing):
204
  set_query(q)
205
 
206
  # Function to handle form submission
207
  def handle_form_submit():
208
+ if st.session_state.query_input and st.session_state.query_input.strip() and not st.session_state.processing:
209
  st.session_state.last_query = st.session_state.query_input.strip()
210
  st.session_state.submit_clicked = True
211
  # Increment the form key to force a reset
 
215
  with st.form(key=f"query_form_{st.session_state.form_key}"):
216
  query = st.text_input("Ask your question:", key="query_input",
217
  placeholder="Press enter to submit your question")
218
+ submit_button = st.form_submit_button("Get Answer", on_click=handle_form_submit, disabled=st.session_state.processing)
219
 
220
  # Display the current question if there is one
221
  if st.session_state.last_query: