The desktop assistant now uses LangChain and LLM-based intelligent intent classification instead of regex pattern matching for command routing.
m_create_note = re.match(r'^\s*create\s+note\b(.*)$', user_input_lower)
m_send_email = re.match(r'^\s*send\s+email\b(.*)$', user_input_lower)
if m_create_note:
# handle create note
elif m_send_email:
# handle send emailclassification = command_router.classify_intent(user_input)
command = classification['command']
if command == 'create_note':
# handle create note
elif command == 'send_email':
# handle send email
elif command == 'conversation':
# handle general conversation-
Flexible Input: Users don't need to say exact command phrases
- "make a note about the meeting" →
create_note - "email john about the project" →
send_email - "do i have any meetings" →
check_gmail
- "make a note about the meeting" →
-
Intelligent Classification: LLM understands intent contextually
- Distinguishes between commands and conversations
- Extracts parameters automatically
- Provides confidence scores
-
Natural Conversations: The system knows when users want to chat vs execute commands
- "how are you" →
conversation - "tell me a joke" →
conversation - "create meeting tomorrow" →
create_event
- "how are you" →
- Uses LLM to classify user intent
- Returns structured classification with:
intent: "command" or "conversation"command: The specific command nameparameters: Extracted informationconfidence: Classification confidence (0-1)
- Fallback to regex if LLM fails
- Calls
command_router.classify_intent(user_input) - Routes to appropriate handler based on
command - Handles both specific commands and general conversation
| Command | Description | Examples |
|---|---|---|
create_note |
Create a new note | "create note meeting notes", "make a note" |
delete_note |
Delete a note | "delete note old tasks", "remove the note" |
list_notes |
List all notes | "list notes", "show my notes" |
send_email |
Send an email | "send email to john", "email sarah" |
check_gmail |
Check Gmail | "check gmail for meetings", "any emails" |
create_event |
Create calendar event | "create event tomorrow at 3pm" |
list_events |
List events | "list events for next week" |
search_event |
Search events | "search event about project" |
conversation |
General chat | "how are you", "tell me a joke" |
exit |
Exit application | "exit", "quit", "goodbye" |
Run the test script to verify the command router:
python test_command_router.pyThis will test various inputs and show how they're classified.
Added to requirements.txt:
langchain- Core LangChain librarylangchain-community- Community integrationssentence-transformers- Already included for Gmail similarity search
Install with:
pip install -r requirements.txtSimply run the main file:
python "main_with_langchain .py"The system will automatically classify your intent and route to the appropriate handler. No changes to voice commands needed - it's more flexible than before!
To add new commands:
- Add command to
CommandRouter.commandsdict incore/command_router.py - Add handler in main loop (
main_with_langchain.py) - Update this documentation
Example:
# In command_router.py
'open_app': {
'description': 'Open an application',
'examples': ['open chrome', 'launch spotify']
}
# In main_with_langchain.py
elif command == 'open_app':
# Handle app opening
pass