/** * @file OpenAI 兼容 LLM Provider * @description 使用原生 fetch 实现,支持任意 OpenAI 兼容端点(OpenAI / DeepSeek / Ollama / vLLM 等) * 额外实现 BatchProvider + FileProvider 接口(OpenAI Batch API + Files API) */ import type { LLMProvider, ModelConfig, ModelInfo, ChatParams, ChatResponse, ChatChunk, BatchProvider, BatchInfo, BatchResult, FileProvider, UploadedFileInfo } from './types.js'; import type { Message, ContentPart } from '../types.js'; import { type DebugContext } from './debug.js'; export declare class OpenAIProvider implements LLMProvider, BatchProvider, FileProvider { protected config: Required> & ModelConfig; constructor(config: ModelConfig); getModel(): ModelInfo; ping(): Promise; chat(params: ChatParams): Promise; chatStream(params: ChatParams): AsyncGenerator; /** 更新配置(如 API Key 变更后) */ updateConfig(updates: Partial): void; protected buildRequestBody(params: ChatParams, stream: boolean): Record; /** * 将内部 Message[] 转换为 OpenAI API 格式 * - string content 直接透传 * - ContentPart[] 转换为 OpenAI 多模态格式 */ protected convertMessagesForApi(messages: Message[]): Record[]; /** 将 ContentPart 转换为 OpenAI API 格式 */ protected convertContentPartForOpenAI(part: ContentPart): Record; protected doRequest(body: Record, signal?: AbortSignal, debugCtx?: DebugContext): Promise; uploadFile(filename: string, content: Buffer | string, purpose: 'assistants' | 'batch' | 'fine-tune' | 'vision'): Promise; getFile(fileId: string): Promise; listFiles(limit?: number, purpose?: string): Promise; deleteFile(fileId: string): Promise; downloadFile(fileId: string): Promise; getFileContent(fileId: string): Promise; createBatch(inputFileId: string, options?: { completionWindow?: '24h'; endpoint?: '/v1/chat/completions'; metadata?: Record; }): Promise; getBatch(batchId: string): Promise; listBatches(limit?: number): Promise; cancelBatch(batchId: string): Promise; getBatchResults(batchId: string): Promise; /** 认证 headers */ protected authHeaders(): Record; /** 原始 fetch 请求(不带 JSON Content-Type,用于 multipart/GET) */ protected doRawRequest(url: string, init: RequestInit & { proxy?: string; }): Promise; /** 解析文件信息 */ protected parseFileInfo(data: any): UploadedFileInfo; /** 解析批处理任务信息 */ protected parseBatchInfo(data: any): BatchInfo; /** 解析单条批处理结果 */ protected parseBatchResult(data: any): BatchResult; } //# sourceMappingURL=openai-provider.d.ts.map