Thanks for helping build the open-source LLM router! 🚀
git clone https://github.com/Das-rebel/a3m-router.git
cd a3m-router
npm install
npm run build# All tests
npm test # or: npx vitest run tests/
# Routing engine tests
npx vitest run tests/routing/
# Jev engine tests
npx vitest run tests/routing/jev.test.ts
# Provider tests
node test/provider-test.js
# Quick smoke test
node test.jssrc/
├── routing/
│ ├── advancedRouter.ts # Main heuristic router (System 2)
│ ├── jev/ # Jev System One decision head
│ │ ├── jevRouter.ts # Entry point
│ │ ├── optionAttention.ts # Single-pass option-attention math
│ │ ├── weights/ # Trained weights (git-tracked dist/)
│ │ └── types.ts
│ └── routeQuery.ts # Provider scoring + selection
├── providers/
│ └── providerConfig.ts # 80+ provider configs + tier definitions
├── server/
│ ├── modelMapper.ts # model="auto" / model="jev-auto" dispatcher
│ └── proxyServer.ts # OpenAI-compatible proxy server
├── cache/
│ └── semanticCache.ts # Embedding-based deduplication
└── cli.ts # CLI entry point
tests/
├── routing/jev.test.ts # Jev engine unit tests
├── routing/advancedRouter.test.ts
└── integration/
-
Add the provider config to
src/providers/providerConfig.ts:export const MY_PROVIDER: Provider = { name: "my-provider", apiKeyEnvVar: "MY_PROVIDER_API_KEY", endpoint: "https://api.my-provider.ai/v1", supports: ["chat", "Completions"], tier: "cheap", // free | cheap | mid | premium region: "us-east", };
-
Add to the provider registry:
export const PROVIDERS: Record<string, Provider> = { // ...existing "my-provider": MY_PROVIDER, };
-
Run tests:
node test/provider-test.js # basic connectivity npx a3m-router providers list # verify it appears
- Create
src/routing/myEngine/ - Implement the engine interface:
export interface RouteResult { primary_model: string; // "provider/model-name" confidence: number; // 0–1 备选?: string; // fallback provider/model } export function routeQuery(prompt: string): RouteResult { ... }
- Wire it into
src/server/modelMapper.tsunder the new model name - Add tests in
tests/routing/myEngine.test.ts - Document in this README under "Two Routing Modes"
- TypeScript strict mode — no
any, full type coverage - ES2022 target, CommonJS output
- 2-space indent, single quotes
- Run
npx tsc --noEmitbefore committing
feat(provider): add Cloudflare Workers AI support
fix(jev): guard against empty option set
chore: bump vitest to 3.x
docs: rewrite Quick Start section
-
npm run buildpasses locally -
npx vitest run tests/— all tests green -
node test.js— smoke test passes - New provider/engine has tests
- README updated if adding new features
- 💬 GitHub Discussions
- 🐛 Issue Tracker
- 📖 docs/ for architecture and API reference