@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
99 lines (98 loc) • 4.11 kB
TypeScript
import { type LanguageModel } from "ai";
import { AIProviderName } from "../constants/enums.js";
import { BaseProvider } from "../core/baseProvider.js";
import type { NeuroLink } from "../neurolink.js";
import type { EnhancedGenerateResult, TextGenerationOptions, ValidationSchema, StreamOptions, StreamResult } from "../types/index.js";
/**
* OpenAI Provider v2 - BaseProvider Implementation
* Migrated to use factory pattern with exact Google AI provider pattern
*/
export declare class OpenAIProvider extends BaseProvider {
private model;
private credentials?;
constructor(modelName?: string, neurolink?: NeuroLink, _region?: string, credentials?: {
apiKey?: string;
baseURL?: string;
});
/**
* Check if this provider supports tool/function calling
*/
supportsTools(): boolean;
getProviderName(): AIProviderName;
getDefaultModel(): string;
/**
* Get the default embedding model for OpenAI
* @returns The default OpenAI embedding model name
*/
protected getDefaultEmbeddingModel(): string;
/**
* Returns the Vercel AI SDK model instance for OpenAI
*/
getAISDKModel(): LanguageModel;
/**
* OpenAI-specific tool validation and filtering
* Filters out tools that might cause streaming issues
*/
private validateAndFilterToolsForOpenAI;
/**
* Validate Zod schema structure
*/
private validateZodSchema;
/**
* Validate tool structure for OpenAI compatibility
* More lenient validation to avoid filtering out valid tools
*/
/** Shared helper: mark a stream span as ERROR, record the exception, and end it. */
private endStreamSpanWithError;
private isValidToolStructure;
/**
* Validate tool parameters for OpenAI compatibility
* Ensures the tool has either valid Zod schema or valid JSON schema
*/
private isValidToolParameters;
formatProviderError(error: unknown): Error;
/**
* executeGenerate method removed - generation is now handled by BaseProvider.
* For details on the changes and migration steps, refer to the BaseProvider documentation
* and the migration guide in the project repository.
*/
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
private createOpenAITransformedStream;
private extractOpenAIChunkContent;
/**
* Generate embeddings for text using OpenAI text-embedding models
* @param text - The text to embed
* @param modelName - The embedding model to use (default: text-embedding-3-small)
* @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: text-embedding-3-small)
* @returns Promise resolving to an array of embedding vectors
*/
embedMany(texts: string[], modelName?: string): Promise<number[][]>;
/**
* Image generation via the OpenAI Images API (`/v1/images/generations`).
*
* Supports `gpt-image-1`, `dall-e-3`, and `dall-e-2`. The three models
* differ in which body params they accept:
*
* - `gpt-image-1` returns base64 by default; does NOT accept `response_format`.
* - `dall-e-3` / `dall-e-2` accept `response_format: "b64_json"` to get base64.
* - `dall-e-2` does NOT accept `quality` / `style`.
*
* The model is taken from `options.model || this.modelName`.
*
* @see https://platform.openai.com/docs/api-reference/images/create
*/
protected executeImageGeneration(options: TextGenerationOptions): Promise<EnhancedGenerateResult>;
/**
* Map a NeuroLink-style aspect ratio (e.g. "16:9") to the OpenAI
* `size` parameter accepted by the active image model. Falls back to
* the per-model square default when the ratio is unknown.
*/
private aspectRatioToOpenAISize;
}
export default OpenAIProvider;