Files
langflow/src
Rodrigo Nader c6a3bdbbab fix: Enhance SmartRouter component with route descriptions and fix imports (#10113)
* fix: Enhance SmartRouter component with route descriptions and fix imports

- Added Route Description field to help LLM understand when to use each route
- Renamed "Route/Category" to "Route Name" for clarity
- Renamed "Output Value" to "Route Message (Optional)" for better understanding
- Fixed imports from langflow to lfx to ensure proper type detection
- Updated prompt generation to include route descriptions for better categorization accuracy
- Added default descriptions for Positive/Negative routes

These changes improve the SmartRouter's ability to accurately categorize inputs by providing
context about each route, and fixes the issue where outputs were showing as Data instead of Message.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [autofix.ci] apply automated fixes

* feat: Add inline editing to SmartRouter table fields

- Route Name now uses inline editing for quick edits
- Route Description uses popover for longer text
- Route Message uses popover for optional longer messages
- Import EditMode from lfx.schema.table

This improves UX by allowing users to quickly edit route names directly
in the table without opening a modal dialog.

* [autofix.ci] apply automated fixes

* feat: Add ToolRouter component for LLM-based tool selection

- Created ToolRouter component similar to SmartRouter but for tools
- Uses HandleInput for tools (like Agent component does)
- Dynamically creates outputs based on connected tools
- LLM categorizes input and routes to appropriate tool
- Executes selected tool and returns result as Message
- Supports override output and else output options
- Added both SmartRouter and ToolRouter to logic module exports

The ToolRouter allows users to connect multiple tools and have the LLM
intelligently select which tool to use based on the input text, then
execute that tool and return the result.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [autofix.ci] apply automated fixes

* debug: Add debugging to ToolRouter update_outputs and use .to_dict()

- Add debug prints to understand when and how update_outputs is called
- Add .to_dict() to Output objects like other working components
- This will help identify why dynamic outputs aren't being created

* [autofix.ci] apply automated fixes

* debug: Try alternative approach for dynamic outputs

- Add _setup_dynamic_outputs method called in __init__ and process_tool
- Directly modify self.outputs instead of relying on update_outputs
- This might work better for HandleInput connections

If this doesn't work, we'll need to investigate how HandleInput
connections trigger component updates in Langflow.

* [autofix.ci] apply automated fixes

* fix: Replace HandleInput with ToolsInput for dynamic outputs

- ToolsInput has real_time_refresh=True hardcoded and is designed for tool selection
- This should properly trigger update_outputs when tools are added/removed
- ToolsInput is specifically built for dynamic tool behavior unlike HandleInput

* Revert "fix: Replace HandleInput with ToolsInput for dynamic outputs"

This reverts commit e2831e6415.

* Update tool_router.py

* Fix some files inadvertently added

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* chore: update component index

* Remove unneeded code

* Update llm_conditional_router.py

* chore: update component index

* Update llm_conditional_router.py

* chore: update component index

* Update llm_conditional_router.py

* Update __init__.py

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-10-14 20:10:30 +00:00
..