@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
76 lines (75 loc) • 3.85 kB
TypeScript
import type { LanguageModel } from "ai";
import type { AIProviderName } from "../constants/enums.js";
import { BaseProvider } from "../core/baseProvider.js";
import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
/**
* Replicate LLM Provider — predict-then-stream pattern.
*
* Replicate's prediction API is asynchronous: POST `/predictions`, poll
* until `succeeded`, fetch the output. Their streaming endpoint is SSE
* on a separate URL and not OpenAI-compatible.
*
* For a first pass we run the prediction synchronously (with the
* `Prefer: wait=60` hint baked into `predict()`) and synthesize a single-
* chunk stream. Future revisions can swap in true SSE streaming when
* the prediction lifecycle helper grows support for it.
*
* For image-gen models on Replicate (FLUX, SDXL, etc.) use Replicate via
* `output: { mode: "image" }` once the routing layer recognises the
* `flux` / `sdxl` prefixes (already in IMAGE_GENERATION_MODELS for
* direct Stability/Ideogram/Recraft; Replicate-hosted FLUX runs through
* `executeImageGeneration` overridden below when the model id matches).
*
* Tool calling is not supported (Replicate predictions are stateless and
* don't carry function-call metadata reliably).
*
* @see https://replicate.com/docs/reference/http
*/
export declare class ReplicateProvider extends BaseProvider {
private readonly apiToken;
private readonly baseURL?;
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["replicate"]);
protected getProviderName(): AIProviderName;
protected getDefaultModel(): string;
supportsTools(): boolean;
/**
* Replicate doesn't expose a chat-completions endpoint we can wrap as
* an AI SDK `LanguageModel`. This getter is consulted by `streamText`
* (which we intentionally bypass) and by middleware injection (which
* also bypasses to executeStream below). Throwing here keeps the
* contract honest.
*/
protected getAISDKModel(): LanguageModel;
/**
* Override generate() to bypass BaseProvider's AI-SDK path entirely.
*
* BaseProvider.runGenerateInActiveContext() calls prepareGenerationContext()
* which unconditionally invokes getAISDKModelWithMiddleware() → getAISDKModel().
* For Replicate that throws, because Replicate uses the predictions API, not
* the Vercel AI SDK chat-completions contract.
*
* Special modes (image, video, avatar, music) are handled exactly as in the
* base class. Plain text generation is routed through executeStream() and
* unwrapped into an EnhancedGenerateResult so callers get a consistent shape.
*/
generate(optionsOrPrompt: import("../types/index.js").TextGenerationOptions | string, _analysisSchema?: import("../types/index.js").ValidationSchema): Promise<EnhancedGenerateResult | null>;
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
/**
* Image-gen routing for Replicate-hosted image models (FLUX, SDXL, etc.).
*
* The dispatcher in baseProvider routes here when the `model` name
* matches an entry in `IMAGE_GENERATION_MODELS`. Replicate model ids
* use `owner/name(:version)?` format — image models route here as
* long as the caller passes the FQMN.
*/
protected executeImageGeneration(options: TextGenerationOptions): Promise<EnhancedGenerateResult>;
protected formatProviderError(error: unknown): Error;
validateConfiguration(): Promise<boolean>;
getConfiguration(): {
provider: AIProviderName;
model: string;
defaultModel: string;
baseURL: string | undefined;
};
}
export default ReplicateProvider;