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