|
| 1 | +/** |
| 2 | + * JevRouter — System One routing for A3M. |
| 3 | + * |
| 4 | + * Replaces the autoregressive/heuristic routing loop with a single-pass |
| 5 | + * calibrated decision (Jev interface pattern): |
| 6 | + * |
| 7 | + * prompt ──► OptionAttention engine ──► { provider choice, complexity score, |
| 8 | + * capability noul flags } |
| 9 | + * |
| 10 | + * The engine is distilled from A3M's own System 2 router (advancedRouter.ts): |
| 11 | + * tools/distill.mjs runs routeQuery over a synthetic prompt corpus and |
| 12 | + * tools/train_jev.py trains the ~25k-parameter option-attention weights. |
| 13 | + * |
| 14 | + * Confidence guard: if the top provider probability is below MIN_CONFIDENCE, |
| 15 | + * we fall back to the full heuristic router (System 2) — Jev decides the easy |
| 16 | + * 90%, the heavy router handles the hard 10%. |
| 17 | + */ |
| 18 | +import { type RouteDecision } from "../advancedRouter"; |
| 19 | +import { type OptionAttentionWeights } from "./optionAttention"; |
| 20 | +import type { JevResponse } from "./types"; |
| 21 | +/** Below this top-probability, defer to the System 2 heuristic router. */ |
| 22 | +export declare const MIN_CONFIDENCE = 0.22; |
| 23 | +export declare function loadWeights(): OptionAttentionWeights | null; |
| 24 | +/** For tests / hot-reload of retrained weights. */ |
| 25 | +export declare function resetWeightsCache(): void; |
| 26 | +/** |
| 27 | + * Build the option text for a model profile. Option text is what the engine |
| 28 | + * embeds — providers unseen at training time are still scored through their |
| 29 | + * strengths/tier description. |
| 30 | + */ |
| 31 | +export declare function optionTextForModel(model: string, profile: { |
| 32 | + providerName?: string; |
| 33 | + strengths?: string[]; |
| 34 | + quality_score?: number; |
| 35 | + cost_per_1k_input?: number; |
| 36 | + cost_per_1k_output?: number; |
| 37 | + type?: string; |
| 38 | +}): string; |
| 39 | +/** |
| 40 | + * Single-pass Jev routing decision. Returns a RouteDecision shaped exactly |
| 41 | + * like advancedRouter.routeQuery so it is a drop-in replacement. |
| 42 | + */ |
| 43 | +export declare function jevRoute(prompt: string, available_models?: string[], budget_multiplier?: number): RouteDecision & { |
| 44 | + jev?: JevResponse; |
| 45 | +}; |
| 46 | +/** Async variant with remote backend support. */ |
| 47 | +export declare function jevRouteAsync(prompt: string, available_models?: string[], budget_multiplier?: number): Promise<RouteDecision & { |
| 48 | + jev?: JevResponse; |
| 49 | +}>; |
0 commit comments