Nelly-43 commited on
Commit
0fd3783
Β·
verified Β·
1 Parent(s): 37b09af

Update app_web.py

Browse files
Files changed (1) hide show
  1. app_web.py +17 -9
app_web.py CHANGED
@@ -244,7 +244,6 @@ def render_chat():
244
  Please let me know if there's anything else I can assist you with today.")
245
  return
246
 
247
- # print("stata: ",qcat_result.get("sub-action"))
248
  if qcat_result.get("category") == "stata" and (qcat_result.get("sub-action")=="unresolved" or st.session_state.stata_options is None):
249
  # Ask clarification β€” store original query and question for context
250
  st.session_state.unresolved_category = original_query_cat
@@ -286,12 +285,11 @@ def render_chat():
286
  with st.chat_message("assistant"):
287
  st.markdown(resolution_msg)
288
  return
289
-
290
- selection = qcat_result.get("sub-action", "unresolved")
291
- # print("selection: ", selection)
292
- if selection != "unresolved" or isinstance(selection, list):
293
  qu_enabled = False
294
- selected_options = [st.session_state.stata_options.get(s) for s in selection]
295
  opts = {
296
  "rewrite": True if "rewrite" in selected_options else False,
297
  "explain": True if "explain" in selected_options else False,
@@ -300,9 +298,19 @@ def render_chat():
300
  # "verbose": True if "verbose" in selected_options else False,
301
  "lines": None#lines if "lines" in selected_options else None
302
  }
303
- result = explain_(qcat_result.get("action"), combined_cat, cfg, st.session_state.stata_file, opts)
304
- st.session_state.messages.append({"role": "assistant", "content": result})
305
- st.markdown(result)
 
 
 
 
 
 
 
 
 
 
306
 
307
  # ── Check if this is a clarification response ───────────────────
308
  pending = st.session_state.pending_clarification
 
244
  Please let me know if there's anything else I can assist you with today.")
245
  return
246
 
 
247
  if qcat_result.get("category") == "stata" and (qcat_result.get("sub-action")=="unresolved" or st.session_state.stata_options is None):
248
  # Ask clarification β€” store original query and question for context
249
  st.session_state.unresolved_category = original_query_cat
 
285
  with st.chat_message("assistant"):
286
  st.markdown(resolution_msg)
287
  return
288
+
289
+ print(qcat_result.get("sub-action"))
290
+ if qcat_result.get("sub-action", "unresolved") != "unresolved" or isinstance(qcat_result.get("sub-action", "unresolved"), list):
 
291
  qu_enabled = False
292
+ selected_options = [st.session_state.stata_options.get(s) for s in qcat_result.get("sub-action", "unresolved")]
293
  opts = {
294
  "rewrite": True if "rewrite" in selected_options else False,
295
  "explain": True if "explain" in selected_options else False,
 
298
  # "verbose": True if "verbose" in selected_options else False,
299
  "lines": None#lines if "lines" in selected_options else None
300
  }
301
+ explanation = explain_(qcat_result.get("action"), combined_cat, cfg, st.session_state.stata_file, opts)
302
+ st.session_state.unresolved_category_question = f"{explanation}\n Please let me know if this answer is helpful or if it requires further clarification."
303
+ st.session_state.resolution_rounds += 1
304
+ resolution_msg = f"{explanation}\n Please let me know if this answer is helpful or if it requires further clarification."
305
+ st.session_state.messages.append({"role": "assistant", "content": resolution_msg})
306
+
307
+ with st.chat_message("assistant"):
308
+ st.markdown(resolution_msg)
309
+ return
310
+
311
+ if qcat_result.get("sub-action", "unresolved") == "unresolved" and st.session_state.unresolved_category_question.contains("Please let me know if this answer is helpful or if it requires further clarification."):
312
+ st.session_state.pending_clarification = st.session_state.unresolved_category
313
+ # st.markdown(result)
314
 
315
  # ── Check if this is a clarification response ───────────────────
316
  pending = st.session_state.pending_clarification