Nelly-43 commited on
Commit
e068675
·
verified ·
1 Parent(s): 6ad4ae2

Update app_web.py

Browse files
Files changed (1) hide show
  1. app_web.py +24 -22
app_web.py CHANGED
@@ -226,11 +226,11 @@ def render_chat():
226
  print("unresolved: ", unresolved)
227
  print("result: ", qcat_result)
228
  print("combined: ", combined_cat)
229
- if qcat_result.get("category") == "contact_and_info" and qcat_result.get("action") == "contact":
230
- with st.chat_message("assistant"):
231
- st.markdown("For additional assistance, please contact the WEAI Helpdesk at IFPRI-WEAI@cgiar.org.\
232
- Please let me know if there's anything else I can assist you with today.")
233
- return
234
  if qcat_result.get("category") == "contact_and_info" and qcat_result.get("action") == "upload":#st.session_state.clarification_rounds < max_clarifications:
235
 
236
  # Allow multiple file uploads
@@ -296,26 +296,28 @@ def render_chat():
296
  return
297
 
298
  print(qcat_result.get("sub-action"))
299
- if "unresolved" not in qcat_result.get("sub-action", "unresolved"):
300
- selected_options = [st.session_state.stata_options.get(s) for s in qcat_result.get("sub-action", "unresolved")]
301
- opts = {
302
- "rewrite": True if "rewrite" in selected_options else False,
303
- "explain": True if "explain" in selected_options else False,
304
- "suggestfix": True if "suggestfix" in selected_options else False,
305
- # "capture": True if "capture" in selected_options else False,
306
- # "verbose": True if "verbose" in selected_options else False,
307
- "lines": None#lines if "lines" in selected_options else None
308
- }
309
- explanation = explain_(qcat_result.get("action"), combined_cat, cfg, st.session_state.stata_file, opts)
310
  st.session_state.unresolved_category = original_query_cat
311
- st.session_state.unresolved_category_question = f"{explanation}\n\n Please let me know if this answer is helpful or if it requires further clarification."
312
  st.session_state.resolution_rounds += 1
313
- resolution_msg = f"{explanation}\n\n Please let me know if this answer is helpful or if it requires further clarification."
314
  st.session_state.messages.append({"role": "assistant", "content": resolution_msg})
315
-
316
- with st.chat_message("assistant"):
317
- st.markdown(resolution_msg)
318
- return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
 
320
  if "unresolved" in qcat_result.get("sub-action", "unresolved") and "Please let me know if this answer is helpful or if it requires further clarification." in unresolved_question:
321
  st.session_state.pending_clarification = unresolved
 
226
  print("unresolved: ", unresolved)
227
  print("result: ", qcat_result)
228
  print("combined: ", combined_cat)
229
+ # if qcat_result.get("category") == "contact_and_info" and qcat_result.get("action") == "contact":
230
+ # with st.chat_message("assistant"):
231
+ # st.markdown("For additional assistance, please contact the WEAI Helpdesk at IFPRI-WEAI@cgiar.org.\
232
+ # Please let me know if there's anything else I can assist you with today.")
233
+ # return
234
  if qcat_result.get("category") == "contact_and_info" and qcat_result.get("action") == "upload":#st.session_state.clarification_rounds < max_clarifications:
235
 
236
  # Allow multiple file uploads
 
296
  return
297
 
298
  print(qcat_result.get("sub-action"))
299
+ if "unresolved" not in qcat_result.get("sub-action", ["unresolved"]):
 
 
 
 
 
 
 
 
 
 
300
  st.session_state.unresolved_category = original_query_cat
 
301
  st.session_state.resolution_rounds += 1
 
302
  st.session_state.messages.append({"role": "assistant", "content": resolution_msg})
303
+
304
+ if qcat_result.get("category") == "stata":
305
+ selected_options = [st.session_state.stata_options.get(s) for s in qcat_result.get("sub-action", ["unresolved"])]
306
+ opts = {
307
+ "rewrite": True if "rewrite" in selected_options else False,
308
+ "explain": True if "explain" in selected_options else False,
309
+ "suggestfix": True if "suggestfix" in selected_options else False,
310
+ # "capture": True if "capture" in selected_options else False,
311
+ # "verbose": True if "verbose" in selected_options else False,
312
+ "lines": None#lines if "lines" in selected_options else None
313
+ }
314
+ explanation = explain_(qcat_result.get("action"), combined_cat, cfg, st.session_state.stata_file, opts)
315
+ st.session_state.unresolved_category_question = f"{explanation}\n\n Please let me know if this answer is helpful or if it requires further clarification."
316
+ resolution_msg = f"{explanation}\n\n Please let me know if this answer is helpful or if it requires further clarification."
317
+
318
+ with st.chat_message("assistant"):
319
+ st.markdown(resolution_msg)
320
+ return
321
 
322
  if "unresolved" in qcat_result.get("sub-action", "unresolved") and "Please let me know if this answer is helpful or if it requires further clarification." in unresolved_question:
323
  st.session_state.pending_clarification = unresolved