srilakshu012456 commited on
Commit
7762999
·
verified ·
1 Parent(s): 1af60a9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +23 -15
main.py CHANGED
@@ -857,24 +857,32 @@ async def chat_with_ai(input_data: ChatInput):
857
  raw_actions = set((kb_results.get("actions") or []))
858
  msg_low2 = (input_data.user_message or "").lower()
859
  if not raw_actions and ("creation" in msg_low2 or "create" in msg_low2 or "set up" in msg_low2 or "setup" in msg_low2):
860
- raw_actions = {"create"}
861
  elif not raw_actions and ("update" in msg_low2 or "modify" in msg_low2 or "edit" in msg_low2 or "change" in msg_low2):
862
- raw_actions = {"update"}
863
  elif not raw_actions and ("delete" in msg_low2 or "remove" in msg_low2 or "cancel" in msg_low2 or "void" in msg_low2):
864
- raw_actions = {"delete"}
865
-
 
 
 
 
 
 
 
 
866
  wanted, exclude = set(), set()
867
- if "create" in raw_actions and not ({"update", "delete"} & raw_actions):
868
- wanted, exclude = {"create"}, {"update", "delete"}
869
- elif "update" in raw_actions and not ({"create", "delete"} & raw_actions):
870
- wanted, exclude = {"update"}, {"create", "delete"}
871
- elif "delete" in raw_actions and not ({"create", "update"} & raw_actions):
872
- wanted, exclude = {"delete"}, {"create", "update"}
873
-
874
- if wanted or exclude:
875
- numbered_full = _filter_numbered_steps_by_actions(numbered_full, wanted=wanted, exclude=exclude)
876
-
877
- # --- NEW: keyword-free anchor-based next-step resolver ---
878
  next_only = _anchor_next_steps(input_data.user_message, numbered_full, max_next=6)
879
 
880
  if next_only is not None:
 
857
  raw_actions = set((kb_results.get("actions") or []))
858
  msg_low2 = (input_data.user_message or "").lower()
859
  if not raw_actions and ("creation" in msg_low2 or "create" in msg_low2 or "set up" in msg_low2 or "setup" in msg_low2):
860
+ raw_actions = {"create"}
861
  elif not raw_actions and ("update" in msg_low2 or "modify" in msg_low2 or "edit" in msg_low2 or "change" in msg_low2):
862
+ raw_actions = {"update"}
863
  elif not raw_actions and ("delete" in msg_low2 or "remove" in msg_low2 or "cancel" in msg_low2 or "void" in msg_low2):
864
+ raw_actions = {"delete"}
865
+ sec_title_low = ((top_meta or {}).get("section") or "").strip().lower()
866
+ section_is_create = any(k in sec_title_low for k in ("create", "creation"))
867
+ section_is_update = any(k in sec_title_low for k in ("update", "updation"))
868
+ section_is_delete = any(k in sec_title_low for k in ("delete", "removal", "cancellation"))
869
+ skip_action_filter = (
870
+ ("create" in raw_actions and section_is_create) or
871
+ ("update" in raw_actions and section_is_update) or
872
+ ("delete" in raw_actions and section_is_delete)
873
+ )
874
  wanted, exclude = set(), set()
875
+ if not skip_action_filter:
876
+ if "create" in raw_actions and not ({"update", "delete"} & raw_actions):
877
+ wanted, exclude = {"create"}, {"update", "delete"}
878
+ elif "update" in raw_actions and not ({"create", "delete"} & raw_actions):
879
+ wanted, exclude = {"update"}, {"create", "delete"}
880
+ elif "delete" in raw_actions and not ({"create", "update"} & raw_actions):
881
+ wanted, exclude = {"delete"}, {"create", "update"}
882
+ if (wanted or exclude) and not skip_action_filter:
883
+ numbered_full = _filter_numbered_steps_by_actions(numbered_full, wanted=wanted, exclude=exclude)
884
+
885
+ # --- NEW: keyword-free anchor-based next-step resolver ---
886
  next_only = _anchor_next_steps(input_data.user_message, numbered_full, max_next=6)
887
 
888
  if next_only is not None: