Spaces:
Runtime error
Runtime error
File size: 3,152 Bytes
077865a | 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | import { type RoutingStrategy, type RoutingWeights } from './scoring.js';
import type { BaseProvider } from '../providers/base.js';
import type { Database } from 'better-sqlite3';
export interface RouteResult {
provider: BaseProvider;
modelId: string;
modelDbId: number;
apiKey: string;
keyId: number;
platform: string;
displayName: string;
rpdLimit: number | null;
tpdLimit: number | null;
}
/**
* Record a 429 for a model — increases its penalty so it sinks in priority.
*/
export declare function recordRateLimitHit(modelDbId: number): void;
/**
* Record a success for a model — reduces its penalty so it rises back up.
*/
export declare function recordSuccess(modelDbId: number): void;
/**
* Get current penalties for all models (for the API/dashboard).
*/
export declare function getAllPenalties(): Array<{
modelDbId: number;
count: number;
penalty: number;
}>;
export declare function getRoutingStrategy(): RoutingStrategy;
export declare function setRoutingStrategy(strategy: RoutingStrategy): void;
export declare function getCustomWeights(): RoutingWeights;
export declare function setCustomWeights(weights: RoutingWeights): void;
export declare function refreshStatsCache(db: Database, force?: boolean): void;
/**
* Route a request to the best available model.
*
* Ordering depends on the configured strategy (see orderChain). Everything
* downstream — key round-robin, cooldowns, token pre-checks, custom base_url
* resolution, vision filtering, sticky sessions — is strategy-independent.
*
* If preferredModelDbId is set, that model gets tried FIRST (sticky sessions).
* This prevents hallucination from model switching mid-conversation.
*
* @param estimatedTokens - estimated total tokens for rate limit check
* @param skipKeys - set of "platform:modelId:keyId" to skip (failed on this request)
* @param preferredModelDbId - try this model first (sticky session)
* @param requireVision - only consider models that accept image input (#118)
* @param requireTools - only consider models that emit structured tool_calls
*/
export declare function routeRequest(estimatedTokens?: number, skipKeys?: Set<string>, preferredModelDbId?: number, requireVision?: boolean, requireTools?: boolean, skipModels?: Set<number>): RouteResult;
/**
* Per-model routing scores for the dashboard. Deterministic (expected
* reliability, not sampled) so the table is stable between polls. Returns the
* axis breakdown plus the final score under the active strategy's weights.
*/
export interface RoutingScore {
modelDbId: number;
platform: string;
modelId: string;
displayName: string;
enabled: boolean;
reliability: number;
speed: number;
intelligence: number;
headroom: number;
rateLimit: number;
score: number;
totalRequests: number;
}
export declare function getRoutingScores(): {
strategy: RoutingStrategy;
weights: RoutingWeights | null;
scores: RoutingScore[];
};
export declare function hasEnabledVisionModel(): boolean;
export declare function hasEnabledToolsModel(): boolean;
//# sourceMappingURL=router.d.ts.map |