UNPKG

@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

78 lines (77 loc) 3.28 kB
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime"; import type { AIProviderName } from "../constants/enums.js"; import { BaseProvider } from "../core/baseProvider.js"; import type { NeuroLink } from "../neurolink.js"; import type { StreamOptions, StreamResult, EnhancedGenerateResult, TextGenerationOptions } from "../types/index.js"; export declare class AmazonBedrockProvider extends BaseProvider { private bedrockClient; private conversationHistory; private region; /** * Parse the region segment from a Bedrock ARN. * Returns null when the input is not an ARN. * * Supports all AWS partitions: * - `arn:aws:bedrock:…` (commercial) * - `arn:aws-cn:bedrock:…` (China) * - `arn:aws-us-gov:bedrock:…` (GovCloud) */ private static extractRegionFromArn; constructor(modelName?: string, neurolink?: NeuroLink, region?: string, credentials?: { accessKeyId?: string; secretAccessKey?: string; sessionToken?: string; region?: string; }); /** * Perform initial health check to catch credential/connectivity issues early * This prevents the health check failure we saw in production logs */ private performInitialHealthCheck; getAISDKModel(): never; getProviderName(): AIProviderName; getDefaultModel(): string; /** * Get the default embedding model for Amazon Bedrock * @returns The default Bedrock embedding model name */ protected getDefaultEmbeddingModel(): string; generate(optionsOrPrompt: TextGenerationOptions | string): Promise<EnhancedGenerateResult | null>; private conversationLoop; private callBedrock; private handleBedrockResponse; private convertToAWSMessages; private executeSingleTool; private convertAISDKToolsToToolDefinitions; private formatToolsForBedrock; private convertToBedrockMessages; getBedrockClient(): BedrockRuntimeClient; protected executeStream(options: StreamOptions): Promise<StreamResult>; private streamingConversationLoop; private convertToAsyncIterable; private prepareStreamCommand; private processStreamResponse; private handleStreamStopReason; private executeStreamTools; /** * Health check for Amazon Bedrock service * Uses ListFoundationModels API to validate connectivity and permissions */ checkBedrockHealth(): Promise<void>; protected formatProviderError(error: unknown): Error; /** * Generate embeddings for text using Amazon Bedrock embedding models * Uses the native AWS SDK InvokeModel command for Titan embeddings * @param text - The text to embed * @param modelName - The embedding model to use (default: amazon.titan-embed-text-v2:0) * @returns Promise resolving to the embedding vector */ embed(text: string, modelName?: string): Promise<number[]>; /** * Generate embeddings for multiple texts in a single batch * @param texts - The texts to embed * @param modelName - The embedding model to use (default: amazon.titan-embed-text-v2:0) * @returns Promise resolving to an array of embedding vectors */ embedMany(texts: string[], modelName?: string): Promise<number[][]>; }