UNPKG

ai-platform-converter

Version:

Lossless API parameter conversion between multiple AI platforms (OpenAI, Anthropic, Gemini, DeepSeek, Wenwen, Vertex AI, Huawei, BigModel)

130 lines 2.97 kB
/** * Supported AI platforms */ export declare enum Platform { OpenAI = "openai", DeepSeek = "deepseek", Wenwen = "wenwen", VertexAI = "vertex-ai", Huawei = "huawei", BigModel = "bigmodel", Anthropic = "anthropic", Gemini = "gemini", RapidAPI = "rapidapi" } /** * Conversion options */ export interface ConvertOptions { /** * Strict mode - throw error on unknown parameters */ strict?: boolean; /** * Preserve platform-specific extension fields */ preserveExtensions?: boolean; /** * Enable debug logging */ debug?: boolean; /** * Whether this is a streaming response/event */ stream?: boolean; } /** * Common message role types */ export type MessageRole = 'system' | 'user' | 'assistant' | 'function' | 'tool'; /** * Common content types */ export interface TextContent { type: 'text'; text: string; } export interface ImageContent { type: 'image' | 'image_url'; image_url?: { url: string; detail?: 'auto' | 'low' | 'high'; }; source?: { type: 'base64' | 'url'; media_type?: string; data?: string; url?: string; }; } export type ContentPart = TextContent | ImageContent | Record<string, any>; /** * Common message structure */ export interface Message { role: MessageRole; content: string | ContentPart[] | null; name?: string; function_call?: any; tool_calls?: any[]; tool_call_id?: string; } /** * Common function/tool definition */ export interface FunctionDefinition { name: string; description?: string; parameters?: Record<string, any>; } export interface ToolDefinition { type: 'function'; function: FunctionDefinition; } /** * Common streaming chunk types */ export interface StreamChunk { id?: string; object?: string; created?: number; model?: string; choices?: any[]; usage?: any; } /** * Common usage statistics */ export interface Usage { prompt_tokens: number; completion_tokens: number; total_tokens: number; } /** * Common finish reasons */ export type FinishReason = 'stop' | 'length' | 'content_filter' | 'tool_calls' | 'function_call' | null; /** * Extension metadata for preserving platform-specific parameters */ export interface ExtensionMetadata { platform: Platform; originalParams?: Record<string, any>; customFields?: Record<string, any>; } /** * Base converter interface */ export interface Converter<TInput, TOutput> { convert(input: TInput, options?: ConvertOptions): TOutput; } /** * Conversion error */ export declare class ConversionError extends Error { readonly fromPlatform: Platform; readonly toPlatform: Platform; readonly originalError?: Error | undefined; constructor(message: string, fromPlatform: Platform, toPlatform: Platform, originalError?: Error | undefined); } //# sourceMappingURL=common.d.ts.map