LlamaIndex RouterQueryEngine
FreeIntelligent query routing for LLM applications
About LlamaIndex RouterQueryEngine
LlamaIndex RouterQueryEngine is a component of the LlamaIndex framework that intelligently routes user queries to the most appropriate data source or query engine. It acts as a selector module, taking a user query and a set of 'choices' defined by metadata, and returns one or more selected choices. The router leverages LLMs for decision-making, supporting both LLM selectors (text completion) and Pydantic selectors (function calling with Pydantic schemas). It can be used as a standalone selector, a query engine, or a retriever, and is composable on top of other query engines as tools. The RouterQueryEngine enables use cases such as selecting the right data source among diverse sources, deciding between summarization and semantic search, and multi-routing to combine results from multiple choices. Note: this feature is currently in beta.
Key Features
Pros & Cons
- Leverages LLMs for intelligent and flexible routing decisions
- Supports both LLM text completion and Pydantic function calling selectors for different use cases
- Enables multi-routing for combining results from multiple sources
- Composable with any existing query engine as a tool, making it easy to integrate into existing pipelines
- Part of the comprehensive LlamaIndex framework, providing data connectors, indexes, and observability
- Relies on LLMs for routing decisions, which can introduce latency and additional costs
- Currently a beta feature, so may have instability or changes in future releases
- Requires setting up and managing multiple query engine tools upfront
- Routing accuracy depends on the quality of tool descriptions and LLM capability