@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
47 lines (46 loc) • 2.28 kB
TypeScript
/**
* Replicate Prediction Lifecycle
*
* Shared async-job helpers used by every Replicate-backed handler. Submits
* a prediction, polls until terminal status, downloads the binary output.
*
* Usage pattern (for handlers — LLM, video, avatar, music):
*
* const auth = getReplicateAuth(credentials);
* if (!auth) throw new XxxError({ code: PROVIDER_NOT_CONFIGURED, ... });
* const prediction = await predict(auth, { model, input });
* const buffer = await downloadPredictionOutput(prediction);
*
* @module adapters/replicate/predictionLifecycle
*/
import type { ReplicateAuth, ReplicateCreatePredictionInput, ReplicatePollOptions, ReplicatePrediction } from "../../types/index.js";
/**
* Submit a Replicate prediction. Uses `Prefer: wait=60` so quick
* predictions complete in the initial POST and skip polling entirely.
*/
export declare function createPrediction(auth: ReplicateAuth, input: ReplicateCreatePredictionInput): Promise<ReplicatePrediction>;
/**
* Poll a Replicate prediction until it reaches a terminal status
* (succeeded / failed / canceled) or the total timeout elapses.
*/
export declare function pollPrediction(auth: ReplicateAuth, predictionId: string, options?: ReplicatePollOptions): Promise<ReplicatePrediction>;
/**
* Submit + poll. Combines `createPrediction` + `pollPrediction`.
*
* Uses `Prefer: wait=60` in the submit call so short jobs complete in the
* initial POST and bypass polling entirely.
*/
export declare function predict(auth: ReplicateAuth, input: ReplicateCreatePredictionInput, options?: ReplicatePollOptions): Promise<ReplicatePrediction>;
/**
* Download a Replicate prediction's binary output.
*
* Replicate models return either a single URL string or an array of URL
* strings (multi-output models). For models that return base64 directly,
* use a model-specific helper instead.
*
* @param prediction The completed prediction to download.
* @param maxBytes Maximum bytes allowed. Defaults to {@link MAX_VIDEO_BYTES}
* (256 MiB). Pass {@link MAX_AUDIO_BYTES} for music/TTS
* outputs or {@link MAX_IMAGE_BYTES} for image outputs.
*/
export declare function downloadPredictionOutput(prediction: ReplicatePrediction, maxBytes?: number): Promise<Buffer>;