import { type ModelPool } from "./modelPool.js"; import { type LogOptions } from "./serveLog.js"; /** mlx_lm's own name for whatever a server was started with. A client * that cannot spell a repo id (Harbor allows a self-hosted model name one * slash) can ask for this instead. It names the one model a single-model * server serves, and nothing when several are served, since it would be * a guess which. */ export declare const DEFAULT_MODEL_ALIAS = "default_model"; /** The served model a request for `requested` goes to: itself when it is * served, the one served model for `default_model`, and undefined * otherwise. */ export declare function servedModelFor(models: string[], requested: string): string | undefined; export type FrontDoor = { port: number; /** Ends every request in progress on a model, and restarts its process * when a cancelled request would otherwise keep running. Returns how * many requests were ended. */ cancel: (model: string) => Promise; /** From now on, every request gets a 503. */ refuseNew: () => void; close: () => Promise; }; /** Where the door prints what it saw, and how much of it. Absent for a door * that logs nothing, which is what the tests of the forwarding itself use. */ export type DoorLogging = LogOptions & { log: (line: string) => void; }; /** The request with its reply length held to `limit`, the server's * --max-tokens. mlx_lm.server reads a request's own `max_tokens` over its * flag, so the flag alone only caps requests that name no length. Capping * here makes it the ceiling the flag promises. A request that names no * length is left alone, since the process then applies the flag itself. */ export declare function capMaxTokens(body: Record, limit: number | undefined): Record; /** Listen on `port` (0 for any) and forward each request to the process of * the model its body names. A request for a model that is not served gets * a 404 and reaches no process. With `logging`, every request is printed * as it ends. With `maxTokens`, a request asking for a longer reply is * held to it. */ export declare function startFrontDoor(port: number, pool: ModelPool, logging?: DoorLogging, maxTokens?: number, onShutdown?: () => void): Promise;