How fbr65/rag-router works
rag-router is a configurable Python RAG-routing library. Its principal workflow accepts a question, separates the skip decision from knowledge-base selection, retrieves from selected RAGs, then checks whether passages answer the question and reports a final state. It also supports document indexing, pluggable Laya/SLM/hybrid routes, and auto calibration. Relationships shown are limited to excerpted code and README statements; unsampled subsystems use exact enclosing directories where supported.
Main entry points: pipeline.py RagRouter pipeline · route.py Laya / SLM / hybrid routes · lancedb.py LanceDB retrieval and indexing · router.py Routing engine
Components 19
Public workflow
- RagRouter pipeline
src/rag_router/pipeline.py
Decision and calibration
- Routing engine
src/rag_router/router.py - Laya / SLM / hybrid routes
src/rag_router/decision/route.py - Legacy decision backend
src/rag_router/decision - Auto calibration
src/rag_router/calibration.py - Calibration cache and locking
src/rag_router/locking.py
Knowledge retrieval
- Embedding providers
src/rag_router/embedding.py - Backend contract and hits
src/rag_router/backends/base.py - LanceDB retrieval and indexing
src/rag_router/backends/lancedb.py
Answer verification
- Laya answer checker
src/rag_router/checking/laya.py - SLM answer checker
src/rag_router/checking/llm.py - Answer-check result contract
src/rag_router/checking/base.py
Configuration
- YAML configuration
src/rag_router/config.py - RAG definitions
src/rag_router/config.py
Other components
- Library / CLI caller
- Laya model
- OpenAI-compatible model endpoint
- LanceDB tables
- JSON document input
Connections 24
- Library / CLI caller → RagRouter pipeline: calls
src/rag_router/pipeline.py - RagRouter pipeline → YAML configuration: loads settings
src/rag_router/cli.py - RagRouter pipeline → Routing engine: routes question
src/rag_router/pipeline.py - RagRouter pipeline → Laya / SLM / hybrid routes: constructs route
src/rag_router/pipeline.py - RagRouter pipeline → Auto calibration: derives thresholds
src/rag_router/pipeline.py - RagRouter pipeline → Calibration cache and locking: locks calibration
src/rag_router/locking.py - Routing engine → Laya / SLM / hybrid routes: asks skip / choose
src/rag_router/router.py - RagRouter pipeline → LanceDB retrieval and indexing: searches selected RAGs
src/rag_router/pipeline.py - RagRouter pipeline → Laya answer checker: checks passages
src/rag_router/pipeline.py - RagRouter pipeline → SLM answer checker: checks passages
src/rag_router/pipeline.py - RagRouter pipeline → Embedding providers: creates embedder
src/rag_router/pipeline.py - RagRouter pipeline → RAG definitions: builds backends
src/rag_router/pipeline.py - LanceDB retrieval and indexing → Embedding providers: embeds text
src/rag_router/backends/lancedb.py - LanceDB retrieval and indexing → LanceDB tables: reads / writes
src/rag_router/backends/lancedb.py - RagRouter pipeline → LanceDB retrieval and indexing: indexes documents
src/rag_router/pipeline.py - JSON document input → RagRouter pipeline: provides JSON
src/rag_router/pipeline.py - Laya answer checker → Answer-check result contract: returns result
src/rag_router/checking/laya.py - SLM answer checker → Answer-check result contract: returns result
src/rag_router/checking/llm.py - Laya / SLM / hybrid routes → Laya model: predicts
src/rag_router/decision/route.py - Laya / SLM / hybrid routes → OpenAI-compatible model endpoint: requests logprobs
src/rag_router/decision/route.py - Laya answer checker → Laya model: predicts
src/rag_router/checking/laya.py - SLM answer checker → OpenAI-compatible model endpoint: requests completion
src/rag_router/checking/llm.py - Routing engine → Legacy decision backend: supports legacy backend
src/rag_router/router.py - Auto calibration → Laya / SLM / hybrid routes: measures routes
src/rag_router/pipeline.py