import { type DeviceType, RawImage } from '@huggingface/transformers'; /** * Build the `from_pretrained` option objects (processor + model) with the * pinned dtype and resolved device. `RAG_DEVICE` passes through with no * allowlist (see `resolveDevice`) into a closed literal union. */ export declare function buildModelLoadOptions(resolvedDevice: string): { dtypeOpt: { dtype: 'q4'; }; modelOpt: { dtype: 'q4'; device: DeviceType; }; }; /** * `apply_chat_template` is declared to return TOKENIZED output by default, not * the string the profiles pass on. */ export type VlmProcessor = { apply_chat_template: (messages: unknown, options: { add_generation_prompt: boolean; }) => string; batch_decode: (tokens: unknown, options: { skip_special_tokens: boolean; }) => string[]; } & ((prompt: string, images: unknown) => Promise<{ input_ids: { dims: unknown[]; }; }>); /** Picks the tensor side of `generate`'s declared model-output-or-tensor union. */ export interface VlmModel { generate: (inputs: unknown) => Promise<{ slice: (axis: null, range: [number, number | null]) => unknown; }>; } /** * Not a guard: member existence says nothing about return values. The captioner * tests replace the library, so they prove these call sites are right GIVEN * this contract, not that the library still honors it — only `fast` runs * against the real one, in `visual-ingest-e2e.test.ts`. */ export declare function asVlmProcessor(processor: unknown): VlmProcessor; /** Present a loaded model as {@link VlmModel}. See {@link asVlmProcessor}. */ export declare function asVlmModel(model: unknown): VlmModel; /** The processor + model pair produced by a profile's load callback. */ export interface LoadedModel { processor: unknown; model: unknown; } /** * Lazy model loader shared by both profiles: owns the pending→ok/failed state * machine and the identical load-failure wrapping. A prior failure re-throws * the same wrapped error rather than retrying. The per-profile `load` callback * owns the model-class choice. */ export declare function createModelLoader(modelName: string, resolvedDevice: string, load: (opts: ReturnType) => Promise): { ensureLoaded: () => Promise; dispose: () => Promise; }; /** * Decode PNG bytes to a `RawImage`. `BlobPart` omits `Uint8Array` * (SharedArrayBuffer subtyping), so the bytes are copied into a view that is * definitely backed by a plain `ArrayBuffer`. Profiles needing a fixed input * size resize the result. */ export declare function decodePngToRawImage(pngBytes: Uint8Array): Promise; /** * Downscale so the long edge is at most `longEdge`, preserving the aspect * ratio, and widen a hairline crop until the processor accepts it. Alignment to * the model's patch grid is left to the image processor. Returns the image * untouched when it already satisfies both. */ export declare function capLongEdge(image: RawImage, longEdge: number): Promise; /** * Apply the post-generation processing rules. Returns the final caption or * `null` when the result is empty after stripping. */ export declare function postProcess(decoded: string): string | null; //# sourceMappingURL=shared.d.ts.map