Spaces:
Sleeping
Sleeping
Update services/kb_creation.py
Browse files- services/kb_creation.py +14 -0
services/kb_creation.py
CHANGED
|
@@ -394,12 +394,26 @@ def _detect_user_intent(query: str) -> str:
|
|
| 394 |
return 'purpose'
|
| 395 |
return 'neutral'
|
| 396 |
|
|
|
|
| 397 |
def _extract_actions(query: str) -> List[str]:
|
| 398 |
q = (query or "").lower()
|
| 399 |
found = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
for act, syns in ACTION_SYNONYMS.items():
|
| 401 |
if any(s in q for s in syns):
|
| 402 |
found.append(act)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
return sorted(set(found)) or []
|
| 404 |
|
| 405 |
def _extract_modules_from_query(query: str) -> List[str]:
|
|
|
|
| 394 |
return 'purpose'
|
| 395 |
return 'neutral'
|
| 396 |
|
| 397 |
+
|
| 398 |
def _extract_actions(query: str) -> List[str]:
|
| 399 |
q = (query or "").lower()
|
| 400 |
found = []
|
| 401 |
+
ACTION_SYNONYMS = {
|
| 402 |
+
"create": ("create", "creation", "add", "new", "generate", "setup", "set up", "register"),
|
| 403 |
+
"update": ("update", "modify", "change", "edit", "amend"),
|
| 404 |
+
"delete": ("delete", "remove", "cancel", "void"),
|
| 405 |
+
"navigate": ("navigate", "go to", "open"),
|
| 406 |
+
}
|
| 407 |
+
# direct synonyms
|
| 408 |
for act, syns in ACTION_SYNONYMS.items():
|
| 409 |
if any(s in q for s in syns):
|
| 410 |
found.append(act)
|
| 411 |
+
# extra cues
|
| 412 |
+
if "steps for" in q or "procedure for" in q or "how to" in q:
|
| 413 |
+
# pick the action that follows these cues
|
| 414 |
+
for act, syns in ACTION_SYNONYMS.items():
|
| 415 |
+
if any(("steps for " + s) in q for s in syns) or any(("procedure for " + s) in q for s in syns):
|
| 416 |
+
found.append(act)
|
| 417 |
return sorted(set(found)) or []
|
| 418 |
|
| 419 |
def _extract_modules_from_query(query: str) -> List[str]:
|