A lightweight, pluggable routing engine that converts classification uncertainty into intelligent decisions — route, clarify, or fallback.
This monorepo provides core types, a decision engine, pluggable classifiers, multi-language support, and evaluation tooling for building confidence-aware routing systems.
- Decision engine — threshold-based routing with ROUTE / CLARIFY / FALLBACK decision boundaries
- Pluggable classifiers — keyword matching, embedding similarity, and LLM-based (OpenAI/Anthropic) classifiers
- Multi-language support — 47 built-in locales with localized clarification prompt templates
- Threshold optimization — grid search evaluation harness with accuracy, precision, recall, and F1 metrics
- Fallback chains — automatic classifier chaining in priority order with robust error handling
- Zero external runtime dependencies — uses native
fetchfor LLM calls, no SDK bloat - Dual ESM/CJS output — works with
importandrequire
Packages are published under the @reaatech scope and can be installed individually:
# Main entry point (all batteries included)
pnpm add @reaatech/confidence-router
# Core types, config, errors, and DecisionEngine
pnpm add @reaatech/confidence-router-core
# Built-in classifier implementations
pnpm add @reaatech/confidence-router-classifiers
# Multi-language support (47 locales)
pnpm add @reaatech/confidence-router-languages
# Threshold optimization and evaluation
pnpm add @reaatech/confidence-router-evaluation# Clone the repository
git clone https://github.com/reaatech/confidence-router.git
cd confidence-router
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run the test suite
pnpm test
# Run linting
pnpm lintimport { ConfidenceRouter, KeywordClassifier } from "@reaatech/confidence-router";
const router = new ConfidenceRouter({
routeThreshold: 0.8,
fallbackThreshold: 0.3,
clarificationEnabled: true,
});
router.registerClassifier(new KeywordClassifier([
{ label: "book_flight", keywords: ["flight", "fly", "ticket"] },
{ label: "cancel_booking", keywords: ["cancel", "refund"] },
]));
const decision = await router.process("I want to book a flight to Paris");
console.log(decision.type); // "ROUTE"
console.log(decision.target); // "book_flight"See the examples/ directory for complete working samples, including built-in classifier usage, custom classifiers, multi-language prompts, and threshold optimization.
| Package | Description |
|---|---|
@reaatech/confidence-router |
Main entry point — routers, factory, barrel exports |
@reaatech/confidence-router-core |
Core types, errors, config, and DecisionEngine |
@reaatech/confidence-router-classifiers |
Pluggable classifier implementations (keyword, embedding, LLM) |
@reaatech/confidence-router-languages |
Multi-language support with 47 built-in locales |
@reaatech/confidence-router-evaluation |
Threshold optimization and evaluation harness |
ARCHITECTURE.md— System design, package relationships, and data flowsAGENTS.md— AI agent skills configuration and development guidelinesCONTRIBUTING.md— Contribution workflow and release process