@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
125 lines (124 loc) • 4.75 kB
TypeScript
import type { AIProviderName } from "../constants/enums.js";
import { BaseProvider } from "../core/baseProvider.js";
import type { NeuroLink } from "../neurolink.js";
import type { EnhancedGenerateResult, TextGenerationOptions, ValidationSchema, StreamOptions } from "../types/index.js";
import type { LanguageModel } from "../types/index.js";
/**
* Amazon SageMaker Provider extending BaseProvider
*/
export declare class AmazonSageMakerProvider extends BaseProvider {
private sagemakerModel;
private sagemakerConfig;
private modelConfig;
constructor(modelName?: string, endpointName?: string, region?: string, neurolink?: NeuroLink, credentials?: {
accessKeyId?: string;
secretAccessKey?: string;
sessionToken?: string;
region?: string;
endpoint?: string;
});
protected getProviderName(): AIProviderName;
protected getDefaultModel(): string;
protected getAISDKModel(): LanguageModel;
/**
* Native non-streaming generate.
*
* SageMaker's doGenerate makes one invokeEndpoint call and already returns
* toolCalls; no streaming is involved, so the wire hazard that reverted the
* first migration does not apply here. This supplies only the multi-step
* iteration the ai package used to.
*
* NOT EXERCISED LIVE. This machine has no SageMaker endpoint or credentials.
* The single-step shape is identical by construction — with no tool calls the
* loop breaks after exactly one doGenerate carrying the same options the ai
* loop passed. The multi-step branch is the new code and wants a real
* endpoint before it is trusted.
*/
generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
private executeNativeGenerate;
/**
* Streaming was previously an `executeStream` override that unconditionally
* threw "not yet fully implemented" — while `SageMakerLanguageModel.doStream`
* sat one property access away, complete and working, with its own fallback
* to a synthetic stream when the endpoint does not support true streaming.
*
* This adapts that AI-SDK-shaped result to `BaseProvider`'s `doStream` hook,
* and the inherited default supplies `executeStream`. The two shapes differ:
* the language model emits typed parts (`text-delta`, `finish`) on a
* `ReadableStream`, while the hook wants text chunks plus promises for how
* the turn ended. Those promises are resolved from the `finish` part by a
* detached pump, so they settle whether or not the caller reads a chunk.
*/
protected doStream(options: StreamOptions): Promise<{
stream: AsyncIterable<{
content: string;
}>;
finishReason: Promise<string>;
usage: Promise<{
inputTokens: number;
outputTokens: number;
}>;
warnings?: string[];
}>;
protected formatProviderError(error: unknown): Error;
/**
* Get SageMaker-specific provider information
*/
getSageMakerInfo(): {
endpointName: string;
modelType: string;
region: string;
configured: boolean;
};
/**
* Test basic configuration
*/
testConnection(): Promise<{
connected: boolean;
error?: string;
}>;
/**
* Public method to get the AI SDK model for CLI and external usage
*/
getModel(): Promise<LanguageModel>;
/**
* Test connectivity to the SageMaker endpoint
*/
testConnectivity(): Promise<{
success: boolean;
error?: string;
}>;
/**
* Get model capabilities and information
*/
getModelCapabilities(): {
capabilities: {
streaming: boolean;
toolCalling: boolean;
structuredOutput: boolean;
batchInference: boolean;
supportedResponseFormats: string[];
supportedToolTypes: string[];
maxBatchSize: number;
adaptiveConcurrency: boolean;
errorRecovery: boolean;
};
modelId: string;
provider: string;
specificationVersion: "v2";
endpointName: string;
modelType: "huggingface" | "mistral" | "custom" | "llama" | "claude" | "jumpstart" | undefined;
region: string;
} | {
capabilities: {
streaming: boolean;
toolCalling: boolean;
structuredOutput: boolean;
batchInference: boolean;
supportedResponseFormats: string[];
supportedToolTypes: string[];
maxBatchSize: number;
};
};
}
export default AmazonSageMakerProvider;