feat: Add natural language command system#9
Conversation
Implements command parser and execution for natural language commands like "move that idea to projects", "tag the last note with 'urgent'", and "archive that inbox item". Changes: **CommandParser** (`src/reflex/services/commands.py`): - New module for parsing natural language commands - Uses LLM (Tier 2 model) to extract structured data from commands - ParsedCommand dataclass: action, target, keywords, parameters - JSON schema-based prompt for reliable parsing **ReflexBot** (`src/reflex/services/bot.py`): - Initialize CommandParser in __init__ - execute_command() - main command execution flow - resolve_target() - find entry by recency + keywords - execute_move() - change entry category - execute_tag() - add tags to entry - execute_archive() - set status=archived - execute_show() - display entry details - All actions update DB + re-export markdown **Target Resolution**: - Query last 10 entries from channel - Filter by keywords if provided (title/category matching) - Return most recent match **Confirmation Messages**: - Clear success/error feedback - Show affected entry title - Specific error messages (not found, invalid category, etc.) Resolves: cortex-q0ca, cortex-pz1e Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary of ChangesHello @devonjones, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances user interaction with the knowledge base by introducing a natural language command system. This system allows users to manage their entries more intuitively through conversational commands, streamlining common tasks like organizing, categorizing, and retrieving information. The integration of an advanced LLM for command parsing and a structured execution flow aims to improve efficiency and user experience by making the system more accessible and responsive to natural language input. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a natural language command system, which is a great new feature. The implementation is solid, with a clear separation between parsing and execution. I've identified a few areas for improvement, primarily focusing on robustness, maintainability, and adherence to asynchronous programming best practices. My main points include a logical bug in how command targets are resolved, suggestions to make the command parser more robust and async-native, and a few refactoring opportunities to improve code structure and maintainability. Addressing these points will make the new command system more reliable and easier to extend in the future.
…ON prompt 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a natural language command system, which is a significant feature. The implementation is well-structured, with a clear separation between parsing (CommandParser) and execution (ReflexBot). The use of an LLM for parsing with a JSON schema is a solid approach.
My review focuses on improving robustness, maintainability, and adherence to async best practices. Key suggestions include:
- Refactoring the synchronous
CommandParserto be fully asynchronous usinghttpx.AsyncClient. - Improving data modeling by using
frozensetfor constant collections,Literaltypes for specific string values, and suggestingEnumfor statuses to avoid magic strings. - Enhancing code clarity with list comprehensions and making the JSON extraction from LLM responses more robust with regular expressions.
Overall, this is a great addition. Addressing these points will make the new command system more efficient and easier to maintain.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-architected natural language command system. The separation of concerns into parsing, target resolution, and execution is clean and logical. The use of an LLM with a JSON schema for command parsing is a robust approach.
My review focuses on improving the robustness of the command parser, particularly in handling malformed LLM responses, and suggests adopting more idiomatic asynchronous patterns for network requests to improve efficiency. I've also included some minor refactoring suggestions to enhance maintainability. Overall, this is a solid implementation of a complex feature.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a natural language command system, which is a significant and well-implemented feature. The code is generally clean and follows a good structure with command parsing and execution separated into different services.
My review focuses on a few key areas for improvement:
- Adopting asynchronous patterns for network requests to improve performance.
- Enhancing the robustness of the LLM response parsing.
- Refactoring some logic to improve maintainability and readability, such as using dispatch tables and list comprehensions.
Overall, this is a solid contribution. The suggested changes are aimed at refining the implementation and ensuring it's robust and scalable.
Summary
Implements natural language command parsing and execution, allowing users to interact with their knowledge base using commands like:
This completes both the command parser (cortex-q0ca) and command execution (cortex-pz1e) tickets.
Architecture
Command Parser (
src/reflex/services/commands.py)Command Execution Flow
Target Resolution Strategy
Supported Actions
new_category(person, project, idea, admin, inbox)tags(list of strings)All actions:
Examples
Input: "move that idea about Foo into my projects"
Output: ✅ Moved entry from idea to project
Input: "tag the last note with 'urgent'"
Output: ✅ Added tags: urgent
Input: "archive that inbox item"
Output: ✅ Archived entry
Input: "show the last entry"
Output: Entry details (category, tags, status, captured date, ID)
Error Handling
Test Plan
mypy)pytest)Future Enhancements
Resolves
Closes cortex-q0ca (Natural language command parser)
Closes cortex-pz1e (Command execution)
🤖 Generated with Claude Code