-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
57 lines (53 loc) · 1.93 KB
/
Copy pathindex.ts
File metadata and controls
57 lines (53 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Smart Router Entry Point
*
* Classifies requests and routes to the cheapest capable model.
* Delegates to pluggable RouterStrategy (default: RulesStrategy, <1ms).
*/
import type { RoutingDecision, RouterOptions } from "./types.js";
import { getStrategy, registerStrategy } from "./strategy.js";
import { PortfolioStrategy } from "./portfolio.js";
// Register here instead of strategy.ts so PortfolioStrategy can reuse the
// stable RulesStrategy without introducing a module cycle.
registerStrategy(new PortfolioStrategy());
/**
* Route a request to the cheapest capable model.
* Delegates to the configured strategy (PortfolioStrategy by default).
*/
export function route(
prompt: string,
systemPrompt: string | undefined,
maxOutputTokens: number,
options: RouterOptions,
): RoutingDecision {
const strategy = getStrategy(options.config.strategy ?? "portfolio");
return strategy.route(prompt, systemPrompt, maxOutputTokens, options);
}
export { getStrategy, registerStrategy, applyUnavailableModels } from "./strategy.js";
export { RulesStrategy } from "./strategy.js";
export { PortfolioStrategy } from "./portfolio.js";
export { classifyByRules } from "./rules.js";
export { inferToolRequirement } from "./tool-intent.js";
export {
getFallbackChain,
getFallbackChainFiltered,
filterByToolCalling,
filterByVision,
filterByExcludeList,
filterCandidatesByCapacity,
calculateModelCost,
} from "./selector.js";
export { DEFAULT_ROUTING_CONFIG } from "./config.js";
export { DEFAULT_MODEL_CAPABILITIES } from "./model-capabilities.js";
export { LIVE_MODEL_PROFILES, HISTORICAL_MODEL_PROFILES } from "./model-profiles.js";
export type {
RoutingDecision,
Tier,
TaskType,
RoutingConfig,
RouterOptions,
RouterStrategy,
} from "./types.js";
export type { ModelPricing } from "./selector.js";
export type { ModelCapabilities } from "./model-capabilities.js";
export type { ModelPerformanceProfile } from "./model-profiles.js";