Nelly-43 commited on
Commit
61cd493
·
verified ·
1 Parent(s): 12cafeb

Update app_web.py

Browse files
Files changed (1) hide show
  1. app_web.py +9 -4
app_web.py CHANGED
@@ -213,6 +213,9 @@ def render_chat():
213
  return
214
 
215
  if qcat_result.get("category") == "stata":
 
 
 
216
  file_path = ""
217
  if qcat_result.get("action") == "do":
218
  options = {"rewrite do-file":"rewrite",
@@ -238,13 +241,14 @@ def render_chat():
238
 
239
  if qcat_result.get("action") == "error":
240
  options = {"explain the error":"explain",
241
- "suggest fix(es) for the error":"suggestfix"}
242
-
243
  with st.chat_message("assistant"):
244
  selection = st.multiselect("Please let me know what you need help with:",
245
  options.keys())
 
246
 
247
- if st.button("Continue"):
248
  if selection:
249
  choice_text = f"Help me {'and '.join(selection)}"
250
  st.session_state.messages.append({"role": "user", "content": choice_text})
@@ -260,7 +264,8 @@ def render_chat():
260
  result = explain_(qcat_result.get("action"), prompt, cfg, file_path, opts)
261
  st.session_state.messages.append({"role": "assistant", "content": result})
262
  st.markdown(result)
263
- return
 
264
  else:
265
  st.warning("Please select at least one option you need help with.")
266
 
 
213
  return
214
 
215
  if qcat_result.get("category") == "stata":
216
+ if "awaiting_selection" not in st.session_state:
217
+ st.session_state.awaiting_selection = True
218
+
219
  file_path = ""
220
  if qcat_result.get("action") == "do":
221
  options = {"rewrite do-file":"rewrite",
 
241
 
242
  if qcat_result.get("action") == "error":
243
  options = {"explain the error":"explain",
244
+ "suggest fix(es) for the error":"suggestfix"}
245
+
246
  with st.chat_message("assistant"):
247
  selection = st.multiselect("Please let me know what you need help with:",
248
  options.keys())
249
+ nxt_btn = st.button("Continue")
250
 
251
+ if nxt_btn:
252
  if selection:
253
  choice_text = f"Help me {'and '.join(selection)}"
254
  st.session_state.messages.append({"role": "user", "content": choice_text})
 
264
  result = explain_(qcat_result.get("action"), prompt, cfg, file_path, opts)
265
  st.session_state.messages.append({"role": "assistant", "content": result})
266
  st.markdown(result)
267
+ if not st.session_state.awaiting_selection:
268
+ return
269
  else:
270
  st.warning("Please select at least one option you need help with.")
271