AgenticRouter
Route queries to search, reflect, or generate actions using LLM reasoning for agentic RAG patterns.Constructor
ChatGroq
required
ChatGroq LLM instance for routing decisions. Should be configured with low temperature (0.0-0.3) for consistent routing
Methods
route
Route a query to the appropriate action based on current pipeline state.str
required
The user’s original query text
bool
default:"False"
Indicates whether documents have already been retrieved in previous iterations
str
The answer generated so far, if any. Used to assess whether reflection or generation is appropriate
int
default:"1"
Current iteration number (1-indexed). Used to track progress and enforce iteration limits
int
default:"3"
Maximum number of routing iterations allowed. Prevents infinite loops
str
One of ‘search’, ‘reflect’, or ‘generate’
str
Human-readable explanation of the routing decision
ContextCompressor
Compress retrieved context using reranking or LLM-based extraction to reduce token usage.Constructor
str
default:"reranking"
Compression mode: “reranking” or “llm_extraction”
ChatGroq
ChatGroq instance for LLM extraction mode. Required when mode is “llm_extraction”
HuggingFaceCrossEncoder
HuggingFaceCrossEncoder instance for reranking mode. Required when mode is “reranking”
Methods
compress
Compress documents using the configured compression strategy.str
required
The user’s query text. Used to determine relevance
list[Document]
required
List of LangChain Document objects to compress
int
default:"5"
Number of documents to return (only used in reranking mode)
list[Document]
Compressed list of documents. Structure depends on mode:
- reranking: List of top_k Document objects, sorted by relevance
- llm_extraction: List containing single synthesized Document
compress_reranking
Compress documents using cross-encoder reranking.str
required
Query text for relevance scoring
list[Document]
required
Documents to rerank
int
default:"5"
Number of top documents to return
list[Document]
Top-k documents sorted by relevance score (highest first)
compress_llm_extraction
Compress documents using LLM-based passage extraction.str
required
Query text to guide extraction
list[Document]
required
Documents to extract from
list[Document]
List containing a single Document with extracted passages. Metadata includes ‘source’: ‘compressed’ and ‘original_doc_count’
QueryEnhancer
Enhance queries using multi-query generation, HyDE (Hypothetical Document Embeddings), and step-back techniques.Constructor
ChatGroq
required
ChatGroq LLM instance for query enhancement
Methods
generate_multi_queries
Generate multiple query variations for better retrieval coverage.str
required
Original query
int
default:"3"
Number of query variations to generate
list[str]
List of query variations including the original query
generate_hyde_document
Generate a hypothetical document that would answer the query.str
required
Query to generate hypothetical document for
str
Hypothetical document text that can be embedded and used for retrieval
generate_step_back_query
Generate a step-back query that asks a more general question.str
required
Specific query to generalize
str
More general query useful for retrieving background context
MMRHelper
Maximal Marginal Relevance utilities for diversity-optimized retrieval.Methods
mmr_rerank
Rerank documents using MMR algorithm to balance relevance and diversity.list[Document]
required
Documents to rerank
list[list[float]]
required
Document embeddings corresponding to documents list
list[float]
required
Query embedding vector
int
default:"10"
Number of documents to return
float
default:"0.5"
Balance parameter between relevance (1.0) and diversity (0.0). Default 0.5 balances both
list[Document]
Reranked documents optimized for relevance and diversity