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

196 lines (195 loc) 5.65 kB
/** * Vercel AI SDK Compatibility Layer * * Provides compatibility with the Vercel AI SDK by implementing the * LanguageModelV1 interface. This allows NeuroLink to be used as a * drop-in replacement for other AI providers in AI SDK applications. * * @module @neurolink/ai-sdk */ import type { ClientLanguageModel, ClientLanguageModelCallOptions, ClientLanguageModelResponse, ClientLanguageModelStreamResponse, ClientModelOptions, NeuroLinkProviderOptions } from "../types/index.js"; import { NeuroLinkClient } from "./httpClient.js"; /** * NeuroLink Language Model implementation compatible with Vercel AI SDK * * Implements the LanguageModelV1 interface for drop-in compatibility. * * @example Using with AI SDK * ```typescript * import { generateText } from 'ai'; * import { createNeuroLinkModel } from '@neurolink/ai-sdk'; * * const model = createNeuroLinkModel({ * baseUrl: 'https://api.neurolink.example.com', * apiKey: 'your-api-key', * }); * * const result = await generateText({ * model: model('gpt-4o'), * prompt: 'Hello, world!', * }); * ``` */ export declare class NeuroLinkLanguageModel implements ClientLanguageModel { readonly modelId: string; readonly provider: string; private client; private options; constructor(client: NeuroLinkClient, modelId: string, provider: string, options?: ClientModelOptions); /** * Generate a non-streaming response */ doGenerate(options: ClientLanguageModelCallOptions): Promise<ClientLanguageModelResponse>; /** * Generate a streaming response * * Uses an async queue so that each text delta from the provider is yielded * to the consumer immediately, rather than buffering the entire response. */ doStream(options: ClientLanguageModelCallOptions): Promise<ClientLanguageModelStreamResponse>; /** * Map NeuroLink finish reasons to AI SDK finish reasons */ private mapFinishReason; } /** * NeuroLink Provider for Vercel AI SDK * * Creates model instances that are compatible with the Vercel AI SDK. * * @example * ```typescript * import { neurolink } from '@neurolink/ai-sdk'; * * const provider = neurolink({ * baseUrl: 'https://api.neurolink.example.com', * apiKey: 'your-api-key', * }); * * // Create a model * const model = provider('gpt-4o'); * * // Use with AI SDK * const result = await generateText({ * model, * prompt: 'Hello!', * }); * ``` */ export declare class NeuroLinkProvider { private client; private defaultProvider; private defaultModel; constructor(options: NeuroLinkProviderOptions); /** * Create a language model instance * * @param modelId - Model ID (e.g., 'gpt-4o', 'claude-3-opus') * @param options - Additional model options */ model(modelId?: string, options?: ClientModelOptions): NeuroLinkLanguageModel; /** * Alias for model() - makes the provider callable */ call(modelId?: string, options?: ClientModelOptions): NeuroLinkLanguageModel; /** * Infer provider from model ID */ private inferProvider; /** * Get the underlying client */ getClient(): NeuroLinkClient; } /** * Create a NeuroLink provider for Vercel AI SDK * * @example * ```typescript * import { createNeuroLinkProvider, generateText } from '@neurolink/ai-sdk'; * * const neurolink = createNeuroLinkProvider({ * baseUrl: 'https://api.neurolink.example.com', * apiKey: process.env.NEUROLINK_API_KEY, * }); * * const result = await generateText({ * model: neurolink('gpt-4o'), * prompt: 'Hello!', * }); * ``` */ export declare function createNeuroLinkProvider(options: NeuroLinkProviderOptions): NeuroLinkProvider & ((modelId?: string, modelOptions?: ClientModelOptions) => NeuroLinkLanguageModel); /** * Create a standalone NeuroLink model for Vercel AI SDK * * @example * ```typescript * import { createNeuroLinkModel, generateText } from '@neurolink/ai-sdk'; * * const model = createNeuroLinkModel({ * baseUrl: 'https://api.neurolink.example.com', * apiKey: process.env.NEUROLINK_API_KEY, * modelId: 'gpt-4o', * provider: 'openai', * }); * * const result = await generateText({ * model, * prompt: 'Hello!', * }); * ``` */ export declare function createNeuroLinkModel(options: NeuroLinkProviderOptions & { modelId: string; provider?: string; }): NeuroLinkLanguageModel; /** * Default export for easy provider creation * * @example * ```typescript * import { neurolink } from '@neurolink/ai-sdk'; * * const provider = neurolink({ * baseUrl: 'https://api.neurolink.example.com', * apiKey: 'your-key', * }); * * const model = provider('gpt-4o'); * ``` */ export declare const neurolink: typeof createNeuroLinkProvider; /** * Create an AI SDK compatible streaming response from NeuroLink stream * * @example * ```typescript * // In a Next.js API route or server action * import { createStreamingResponse } from '@neurolink/ai-sdk'; * * export async function POST(req: Request) { * const { prompt } = await req.json(); * * const stream = await createStreamingResponse({ * baseUrl: process.env.NEUROLINK_URL, * apiKey: process.env.NEUROLINK_API_KEY, * input: { text: prompt }, * provider: 'openai', * model: 'gpt-4o', * }); * * return stream; * } * ``` */ export declare function createStreamingResponse(options: NeuroLinkProviderOptions & { input: { text: string; }; model: string; provider?: string; temperature?: number; maxTokens?: number; systemPrompt?: string; }): Promise<Response>;