Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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 |
-
|
| 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 |
-
|
| 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 |
-
|
| 865 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 866 |
wanted, exclude = set(), set()
|
| 867 |
-
if
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
if wanted or exclude:
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 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:
|