@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
31 lines (30 loc) • 1.47 kB
TypeScript
/**
* Default heuristic request router.
*
* `createDefaultRequestRouter` produces a `RequestRouter` function that maps
* lightweight request characteristics to a provider/model/region override.
* It is entirely optional — hosts may supply their own `RequestRouter` function
* instead, or disable routing entirely by not passing either.
*
* This PR adds `requestRouter` (and `modelPool`) as NeuroLink constructor
* options. The router is skipped only when BOTH options.provider AND
* options.model are explicitly set by the caller — a partial pin (e.g. only
* provider) still allows the router to run.
*
* Decision logic (checked in order):
* 1. Vision request → visionTier
* 2. Large input or tools → largeTier
* 3. Default → smallTier (only when config.smallTier is provided)
*
* When none of the configured tiers matches (or when the tier is not
* configured), the router returns `{}` which is a no-op — the caller keeps
* whatever provider/model was set by the user.
*/
import type { DefaultRequestRouterConfig, RequestRouter } from "../types/index.js";
/**
* Creates a heuristic `RequestRouter` from a `DefaultRequestRouterConfig`.
*
* @param config — optional tier overrides; built-in defaults apply when omitted.
* @returns a synchronous `RequestRouter` function (satisfies the async signature).
*/
export declare function createDefaultRequestRouter(config?: DefaultRequestRouterConfig): RequestRouter;