@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
60 lines (59 loc) • 3.29 kB
TypeScript
import type { GenerateOptions, MultimodalChatMessage, StreamOptions, TextGenerationOptions, VisionImageOutputFormat } from "../types/index.js";
import type { ModelMessage } from "../types/index.js";
/**
* Type-safe conversion from MultimodalChatMessage[] to ModelMessage[]
* Filters out invalid content and ensures strict ModelMessage contract compliance
*/
export declare function convertToModelMessages(messages: MultimodalChatMessage[]): ModelMessage[];
/**
* Build a properly formatted message array for AI providers
* Combines system prompt, conversation history, and current user prompt
* Supports both TextGenerationOptions and StreamOptions
* Enhanced with CSV file processing support
*/
export declare function buildMessagesArray(options: TextGenerationOptions | StreamOptions): Promise<ModelMessage[]>;
/**
* Fold the `audioFiles` / `videoFiles` aliases into the unified `files` array.
*
* #284 gave audio and video their own input fields, but neither has a
* dedicated processor — both are meant to travel through the same
* auto-detecting `files` pipeline that already understands "audio"/"video"
* FileDetector results (see `appendDetectedFileResult`). The fold used to live
* inline in `buildMultimodalMessagesArray`, which meant any path that bypassed
* that builder never performed it and dropped the files silently: the model
* received the prompt alone and answered as though nothing were attached
* (#1259). GoogleVertex's native SDK path and `buildMultimodalOptions`
* (Bedrock) are both such paths, so the fold has to be callable from them.
*
* The aliases are cleared once merged, which makes the call idempotent: a
* provider override and the shared builder can both call this on the same
* options object without attaching every file twice.
*
* Mutates in place, matching `processUnifiedFilesArray` below — downstream
* stages all read `options.input.files`.
*/
export declare function mergeMediaFileAliases<TFile>(input: {
files?: Array<TFile | Buffer | string>;
audioFiles?: Array<Buffer | string>;
videoFiles?: Array<Buffer | string>;
}): void;
export declare function processUnifiedFilesArray(options: GenerateOptions, maxSize: number, provider: string): Promise<void>;
/**
* Build multimodal message array with image support
* Detects when images are present and routes through provider adapter
*/
export declare function buildMultimodalMessagesArray(options: GenerateOptions, provider: string, model: string): Promise<MultimodalChatMessage[]>;
/**
* Transcode any image in `input.images` that no vision provider accepts,
* rewriting the entry in place as a PNG data URI.
*
* Mutates in place and is idempotent, matching `processUnifiedFilesArray` and
* `foldMediaAliasesIntoFiles`: the shared multimodal builder and the providers
* that bypass it (Google AI Studio's and Vertex's native SDK paths, Bedrock's
* Converse path) can all call it on the same options object without converting
* anything twice.
*
* Entries that are `http(s)` URLs are left alone — they have no bytes yet, and
* `processImageToBase64` converts them once they are downloaded.
*/
export declare function normalizeVisionImageFormats(input: GenerateOptions["input"], outputFormat?: VisionImageOutputFormat): Promise<void>;