Update command_classifier.py
Browse files- command_classifier.py +40 -5
command_classifier.py
CHANGED
|
@@ -1,11 +1,46 @@
|
|
| 1 |
def classify_command(command: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
command = command.lower()
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
return "open_app"
|
| 5 |
-
elif "
|
| 6 |
-
return "
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
return "create_file"
|
| 9 |
-
elif "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return "web_search"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
return "chat"
|
|
|
|
| 1 |
def classify_command(command: str) -> str:
|
| 2 |
+
"""
|
| 3 |
+
Classifies a user's command into categories for action or AI response.
|
| 4 |
+
|
| 5 |
+
Args:
|
| 6 |
+
command (str): User's input text.
|
| 7 |
+
|
| 8 |
+
Returns:
|
| 9 |
+
str: Command type (e.g. 'open_app', 'screenshot', 'create_file', etc.)
|
| 10 |
+
"""
|
| 11 |
command = command.lower()
|
| 12 |
+
|
| 13 |
+
# --- Application control ---
|
| 14 |
+
if "open" in command and any(app in command for app in ["chrome", "firefox", "notepad", "calculator", "edge", "terminal", "vscode"]):
|
| 15 |
return "open_app"
|
| 16 |
+
elif "close" in command and any(app in command for app in ["chrome", "firefox", "notepad", "calculator", "edge", "terminal", "vscode"]):
|
| 17 |
+
return "close_app"
|
| 18 |
+
|
| 19 |
+
# --- File system operations ---
|
| 20 |
+
if "create" in command and "file" in command:
|
| 21 |
return "create_file"
|
| 22 |
+
elif "delete" in command and "file" in command:
|
| 23 |
+
return "delete_file"
|
| 24 |
+
elif "read" in command and "file" in command:
|
| 25 |
+
return "read_file"
|
| 26 |
+
elif "write" in command and "file" in command:
|
| 27 |
+
return "write_file"
|
| 28 |
+
|
| 29 |
+
# --- System commands ---
|
| 30 |
+
if "screenshot" in command or "screen shot" in command:
|
| 31 |
+
return "screenshot"
|
| 32 |
+
if "shutdown" in command:
|
| 33 |
+
return "shutdown"
|
| 34 |
+
if "restart" in command:
|
| 35 |
+
return "restart"
|
| 36 |
+
if "lock" in command:
|
| 37 |
+
return "lock_computer"
|
| 38 |
+
|
| 39 |
+
# --- Internet-related ---
|
| 40 |
+
if "search" in command or "what is" in command or "who is" in command:
|
| 41 |
return "web_search"
|
| 42 |
+
if "open" in command and ".com" in command:
|
| 43 |
+
return "open_website"
|
| 44 |
+
|
| 45 |
+
# --- AI Assistant Query ---
|
| 46 |
return "chat"
|