Available components
AgenticRouter
LLM-based decision-making for agentic RAG pipelines
ContextCompressor
LLM-based context compression for token optimization
QueryEnhancer
Multi-query, HyDE, and step-back prompting
AgenticRouter
An LLM-based decision-making component for agentic RAG pipelines. UsesChatGroq and LangChain’s PromptTemplate for structured decision-making.
State machine
The router implements a three-state state machine:search: Retrieve more documents from the vector store. Selected when no documents have been retrieved yet or when reflection identified information gaps.reflect: Evaluate and improve the current answer. Selected when documents exist but the answer’s quality, completeness, or grounding is uncertain.generate: Produce the final answer. Selected when sufficient information has been gathered or whenmax_iterationsis reached (forced fallback).
Implementation
src/vectordb/langchain/components/agentic_router.py
Usage
QueryEnhancer
Generates improved retrieval queries from the user’s original input usingChatGroq and PromptTemplate.
Strategies
Multi-query generation
Multi-query generation
Generates 5 alternative phrasings of the original query. Returns a list of up to 5 query strings. The original query is NOT included.Best for: Simple factual queries where different phrasings might match different documents.
HyDE (Hypothetical Document Embeddings)
HyDE (Hypothetical Document Embeddings)
Generates a hypothetical 2-3 sentence document answer. Returns
[original_query, hypothetical_answer].Best for: Very short queries or when query/document distributions differ significantly.Step-back prompting
Step-back prompting
Generates 3 broader context questions. Returns
[step_back_1, step_back_2, step_back_3, original_query].Best for: Complex questions requiring background knowledge.Implementation
src/vectordb/langchain/components/query_enhancer.py
Usage
LLM configuration
All LangChain components useChatGroq from langchain-groq. Recommended settings:
GROQ_API_KEY environment variable or pass api_key directly to ChatGroq.
When to use components directly
- When building a custom pipeline that does not match the existing feature module templates
- When experimenting with one pipeline stage (testing different compression strategies with a fixed retriever)
- When combining components from different feature modules into a custom pipeline
Common pitfalls
Next steps
Agentic RAG
See AgenticRouter in action with the full agentic RAG pipeline
Semantic search
Build your first semantic search pipeline
Hybrid search
Combine dense and sparse retrieval with ResultMerger