UNPKG

@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

48 lines (47 loc) • 2.34 kB
/** * Image format detection from magic bytes. * * The native Vertex+Anthropic image block needs the correct `mimeType` for * each inline image. Buffer and bare-base64 inputs (e.g. Slack / REST uploads) * carry no mime hint, so the format must be sniffed from the leading bytes — * otherwise a wrong default (historically `image/jpeg`) makes Anthropic reject * PNG/GIF/WebP with a media-type mismatch 400. */ /** * Detect an image's MIME type from its magic bytes, or `null` when the bytes * match no known signature. * * Use this when the answer "not an image" has to be distinguishable from a * default. `detectImageMimeType` collapses that distinction on purpose, which * is right for a caller that already knows it holds an image and wrong for one * deciding whether it does. */ export declare function sniffImageMimeType(buffer: Buffer): string | null; /** * Detect an image's MIME type from its magic bytes. Returns `image/png` for * buffers that match no known signature (the safest neutral default for the * Vertex image path). */ export declare function detectImageMimeType(buffer: Buffer): string; /** * Detect the MIME type of any raster image NeuroLink accepts as input, or `null` * when the bytes match none. * * {@link sniffImageMimeType} answers for the four formats every vision provider * takes as they are, and its callers depend on that set staying four. This is * the wider question for a caller deciding whether bytes are an image NeuroLink * can send at all: those four, plus HEIC, HEIF (Google takes both natively), * AVIF, BMP, TIFF, ICO and JPEG 2000, which the SDK tries to convert to PNG * before dispatch (`SUPPORTED_INPUT_IMAGE_MIME_TYPES`) and sends as detected * when no decoder can read them. Every type it returns is in that set, so a * caller that relabels bytes with the answer is never handing the SDK a type it * refuses. * * SVG is deliberately absent. It is markup with no byte signature, and no * provider accepts it; a caller that wants it has to look for it separately. * * Only the leading bytes are read (a few hundred cover every signature), so a * prefix of a large image is enough. A signature is a claim about the opening of * the file, not proof the rest decodes. */ export declare function sniffInputImageMimeType(buffer: Buffer): string | null;