@aeye/openai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +921 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/openai.d.ts +444 -0
- package/dist/openai.d.ts.map +1 -0
- package/dist/openai.js +1844 -0
- package/dist/openai.js.map +1 -0
- package/dist/retry.d.ts +117 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +224 -0
- package/dist/retry.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +129 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/openai.d.ts
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Provider
|
|
3
|
+
*
|
|
4
|
+
* Provider for OpenAI's GPT models, DALL-E, Whisper, and TTS.
|
|
5
|
+
* Also serves as base class for OpenAI-compatible providers.
|
|
6
|
+
*/
|
|
7
|
+
import type { AIContextAny, AIMetadataAny, EmbeddingRequest, ImageEditRequest, ImageGenerationRequest, ModelInfo, Provider, SpeechRequest, TranscriptionRequest } from '@aeye/ai';
|
|
8
|
+
import { BaseRequest, type Chunk, type Executor, type MessageContent, ModelInput, type Request, type Response, type Streamer, type ToolCall } from '@aeye/core';
|
|
9
|
+
import OpenAI, { Uploadable } from 'openai';
|
|
10
|
+
import { type RetryConfig, type RetryEvents } from './retry';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for the OpenAI provider.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const config: OpenAIConfig = {
|
|
17
|
+
* apiKey: process.env.OPENAI_API_KEY!,
|
|
18
|
+
* organization: 'org-123456', // Optional
|
|
19
|
+
* retry: {
|
|
20
|
+
* maxRetries: 3,
|
|
21
|
+
* initialDelay: 1000,
|
|
22
|
+
* retryableStatuses: [0, 429, 500, 503],
|
|
23
|
+
* },
|
|
24
|
+
* retryEvents: {
|
|
25
|
+
* onRetry: (attempt, error, delay, context) => {
|
|
26
|
+
* console.log(`Retry attempt ${attempt} for ${context.operation} after ${delay}ms`);
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface OpenAIConfig {
|
|
33
|
+
apiKey: string;
|
|
34
|
+
baseURL?: string;
|
|
35
|
+
organization?: string;
|
|
36
|
+
project?: string;
|
|
37
|
+
retry?: RetryConfig;
|
|
38
|
+
retryEvents?: RetryEvents;
|
|
39
|
+
defaultModels?: {
|
|
40
|
+
chat?: ModelInput;
|
|
41
|
+
imageGenerate?: ModelInput;
|
|
42
|
+
imageEdit?: ModelInput;
|
|
43
|
+
imageAnalyze?: ModelInput;
|
|
44
|
+
transcription?: ModelInput;
|
|
45
|
+
speech?: ModelInput;
|
|
46
|
+
embedding?: ModelInput;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare class OpenAIProvider<TConfig extends OpenAIConfig = OpenAIConfig> implements Provider<TConfig> {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly config: TConfig;
|
|
52
|
+
defaultMetadata?: Provider['defaultMetadata'];
|
|
53
|
+
constructor(config: TConfig);
|
|
54
|
+
/**
|
|
55
|
+
* Create OpenAI client from provider config.
|
|
56
|
+
*
|
|
57
|
+
* Subclasses can override this method to customize client initialization,
|
|
58
|
+
* such as setting a custom base URL for OpenAI-compatible APIs.
|
|
59
|
+
*
|
|
60
|
+
* @param config Provider configuration
|
|
61
|
+
* @returns Configured OpenAI client instance
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* protected createClient(config: OpenAIConfig): OpenAI {
|
|
66
|
+
* return new OpenAI({
|
|
67
|
+
* apiKey: config.apiKey,
|
|
68
|
+
* baseURL: 'https://custom-endpoint.example.com/v1',
|
|
69
|
+
* });
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
protected createClient(config: TConfig): OpenAI;
|
|
74
|
+
/**
|
|
75
|
+
* Convert OpenAI's model format to @aeye ModelInfo format.
|
|
76
|
+
*
|
|
77
|
+
* Subclasses can override this to enrich model metadata with
|
|
78
|
+
* provider-specific information.
|
|
79
|
+
*
|
|
80
|
+
* @param model OpenAI model object
|
|
81
|
+
* @returns Standardized ModelInfo object
|
|
82
|
+
*/
|
|
83
|
+
protected convertModel(model: OpenAI.Model): ModelInfo;
|
|
84
|
+
/**
|
|
85
|
+
* Customize image generation params before sending to API.
|
|
86
|
+
*
|
|
87
|
+
* @param params Image generation parameters
|
|
88
|
+
* @param config Provider configuration
|
|
89
|
+
* @returns Modified parameters
|
|
90
|
+
*/
|
|
91
|
+
protected augmentImageGenerateRequest?<TParams extends OpenAI.ImageGenerateParams>(params: TParams, request: ImageGenerationRequest, config: TConfig): void;
|
|
92
|
+
/**
|
|
93
|
+
* Customize image edit params before sending to API.
|
|
94
|
+
*
|
|
95
|
+
* @param params Image generation parameters
|
|
96
|
+
* @param config Provider configuration
|
|
97
|
+
* @returns Modified parameters
|
|
98
|
+
*/
|
|
99
|
+
protected augmentImageEditRequest?<TParams extends OpenAI.ImageEditParams>(params: TParams, request: ImageEditRequest, config: TConfig): void;
|
|
100
|
+
/**
|
|
101
|
+
* Customize transcription params before sending to API.
|
|
102
|
+
*
|
|
103
|
+
* @param params Transcription parameters
|
|
104
|
+
* @param config Provider configuration
|
|
105
|
+
* @returns Modified parameters
|
|
106
|
+
*/
|
|
107
|
+
protected augmentTranscriptionRequest?<TParams extends OpenAI.Audio.TranscriptionCreateParams>(params: TParams, request: TranscriptionRequest, config: TConfig): void;
|
|
108
|
+
/**
|
|
109
|
+
* Customize speech generation params before sending to API.
|
|
110
|
+
*
|
|
111
|
+
* @param params Speech synthesis parameters
|
|
112
|
+
* @param config Provider configuration
|
|
113
|
+
* @returns Modified parameters
|
|
114
|
+
*/
|
|
115
|
+
protected augmentSpeechRequest?<TParams extends OpenAI.Audio.SpeechCreateParams>(params: TParams, request: SpeechRequest, config: TConfig): void;
|
|
116
|
+
/**
|
|
117
|
+
* Customize embedding params before sending to API.
|
|
118
|
+
*
|
|
119
|
+
* @param params Embedding parameters
|
|
120
|
+
* @param config Provider configuration
|
|
121
|
+
* @returns Modified parameters
|
|
122
|
+
*/
|
|
123
|
+
protected augmentEmbeddingRequest?<TParams extends OpenAI.EmbeddingCreateParams>(params: TParams, request: EmbeddingRequest, config: TConfig): void;
|
|
124
|
+
/**
|
|
125
|
+
* Customize chat completion params before sending to API.
|
|
126
|
+
*
|
|
127
|
+
* Override this method to modify request parameters for custom providers
|
|
128
|
+
* or to add provider-specific features.
|
|
129
|
+
*
|
|
130
|
+
* @param params OpenAI chat completion parameters
|
|
131
|
+
* @param config Provider configuration
|
|
132
|
+
* @param request Original @aeye request
|
|
133
|
+
* @returns Modified parameters
|
|
134
|
+
*/
|
|
135
|
+
protected augmentChatRequest<TParams extends OpenAI.Chat.ChatCompletionCreateParams>(params: TParams, request: Request, config: TConfig): void;
|
|
136
|
+
/**
|
|
137
|
+
* Augment chat chunk with provider-specific data.
|
|
138
|
+
*
|
|
139
|
+
* @param expected
|
|
140
|
+
* @param chunk
|
|
141
|
+
*/
|
|
142
|
+
protected augmentChatChunk<TParams extends OpenAI.Chat.Completions.ChatCompletionChunk>(expected: TParams, chunk: Chunk, config: TConfig): void;
|
|
143
|
+
/**
|
|
144
|
+
* Augment chat response with provider-specific data.
|
|
145
|
+
*
|
|
146
|
+
* @param openai OpenAI chat completion response
|
|
147
|
+
* @param response @aeye response object to augment
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
protected augmentChatResponse<TParams extends OpenAI.Chat.Completions.ChatCompletion>(expected: TParams, response: Response, config: TConfig): void;
|
|
151
|
+
/**
|
|
152
|
+
* Convert @aeye MessageContent to OpenAI content string format.
|
|
153
|
+
* @param x
|
|
154
|
+
* @param from
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
protected convertContentString(x: MessageContent['content'], from: string): string;
|
|
158
|
+
/**
|
|
159
|
+
* Convert @aeye MessageContent to OpenAI text content format.
|
|
160
|
+
* @param x
|
|
161
|
+
* @param name
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
protected convertContentText(x: string | MessageContent[], name: string): string | OpenAI.Chat.Completions.ChatCompletionContentPartText[];
|
|
165
|
+
/**
|
|
166
|
+
* Convert @aeye MessageContent to OpenAI format.
|
|
167
|
+
* @param x
|
|
168
|
+
* @param name
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
protected convertContent(x: string | MessageContent[], name: string): string | OpenAI.Chat.Completions.ChatCompletionContentPart[];
|
|
172
|
+
/**
|
|
173
|
+
* Convert @aeye ToolCall to OpenAI format.
|
|
174
|
+
* @param x ToolCall object
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
protected convertToolCall(x: ToolCall): OpenAI.Chat.ChatCompletionMessageToolCall;
|
|
178
|
+
/**
|
|
179
|
+
* Converts a name on a message to conform to OpenAI's naming rules.
|
|
180
|
+
* Removes invalid characters and truncates to max length.
|
|
181
|
+
*
|
|
182
|
+
* @param name - Original name
|
|
183
|
+
* @returns Converted name or undefined
|
|
184
|
+
*/
|
|
185
|
+
protected convertName(name: string | undefined): string | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Convert @aeye Request messages to OpenAI format.
|
|
188
|
+
*
|
|
189
|
+
* Handles conversion of all message types (system, user, assistant, tool)
|
|
190
|
+
* and content types (text, image, audio, file).
|
|
191
|
+
*
|
|
192
|
+
* @param request @aeye request object
|
|
193
|
+
* @returns Array of OpenAI-formatted messages
|
|
194
|
+
*/
|
|
195
|
+
protected convertMessages(request: Request): OpenAI.Chat.ChatCompletionMessageParam[];
|
|
196
|
+
/**
|
|
197
|
+
* Convert @aeye tool definitions to OpenAI format.
|
|
198
|
+
*
|
|
199
|
+
* Transforms Zod schemas into JSON Schema format required by OpenAI.
|
|
200
|
+
*
|
|
201
|
+
* @param request @aeye request object
|
|
202
|
+
* @returns Array of OpenAI-formatted tools or undefined
|
|
203
|
+
*/
|
|
204
|
+
protected convertTools(request: Request): OpenAI.Chat.ChatCompletionTool[] | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Convert @aeye tool choice to OpenAI format.
|
|
207
|
+
*
|
|
208
|
+
* Supports auto, required, none, and specific tool selection.
|
|
209
|
+
*
|
|
210
|
+
* @param request @aeye request object
|
|
211
|
+
* @returns OpenAI-formatted tool choice option or undefined
|
|
212
|
+
*/
|
|
213
|
+
protected convertToolChoice(request: Request): OpenAI.Chat.ChatCompletionToolChoiceOption | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Convert @aeye response format to OpenAI format.
|
|
216
|
+
*
|
|
217
|
+
* Supports text, JSON object mode, and structured output with Zod schemas.
|
|
218
|
+
*
|
|
219
|
+
* @param request @aeye request object
|
|
220
|
+
* @returns OpenAI-formatted response format or undefined
|
|
221
|
+
*/
|
|
222
|
+
protected convertResponseFormat(request: Request): OpenAI.Chat.ChatCompletionCreateParams['response_format'] | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* List available models from OpenAI.
|
|
225
|
+
*
|
|
226
|
+
* @param config Optional configuration override
|
|
227
|
+
* @returns Array of available models with metadata
|
|
228
|
+
* @throws {ProviderError} If listing models fails
|
|
229
|
+
*/
|
|
230
|
+
listModels(config?: TConfig): Promise<ModelInfo[]>;
|
|
231
|
+
/**
|
|
232
|
+
* Check if the OpenAI API is accessible with the provided credentials.
|
|
233
|
+
*
|
|
234
|
+
* @param config Optional configuration override
|
|
235
|
+
* @returns true if API is accessible, false otherwise
|
|
236
|
+
*/
|
|
237
|
+
checkHealth(config?: TConfig): Promise<boolean>;
|
|
238
|
+
/**
|
|
239
|
+
* Get request data common to all request types.
|
|
240
|
+
*
|
|
241
|
+
* @param request - The request
|
|
242
|
+
* @param ctx - The context
|
|
243
|
+
* @param effectiveConfig - The effective configuration
|
|
244
|
+
* @param defaultModel - Optional default model
|
|
245
|
+
* @returns
|
|
246
|
+
*/
|
|
247
|
+
getRequestData<R>(request: BaseRequest, requestSignal: AbortSignal | undefined, ctx: AIContextAny, effectiveConfig: TConfig, operation: string, defaultModel?: ModelInput): {
|
|
248
|
+
model: import("@aeye/core").Model;
|
|
249
|
+
retry: (fn: (signal?: AbortSignal) => Promise<R>) => Promise<R>;
|
|
250
|
+
signal: AbortSignal | undefined;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Create an executor for chat completion requests.
|
|
254
|
+
*
|
|
255
|
+
* The executor handles non-streaming chat completions with support for:
|
|
256
|
+
* - Multi-turn conversations
|
|
257
|
+
* - Function calling
|
|
258
|
+
* - Structured outputs
|
|
259
|
+
* - Vision (images)
|
|
260
|
+
* - Audio inputs
|
|
261
|
+
*
|
|
262
|
+
* @param config Optional configuration override
|
|
263
|
+
* @returns Executor function for chat completions
|
|
264
|
+
* @throws {ProviderError} If request fails
|
|
265
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
266
|
+
*/
|
|
267
|
+
createExecutor(config?: TConfig): Executor<AIContextAny, AIMetadataAny>;
|
|
268
|
+
/**
|
|
269
|
+
* Create a streamer for streaming chat completion requests.
|
|
270
|
+
*
|
|
271
|
+
* The streamer yields chunks as they arrive from OpenAI, enabling
|
|
272
|
+
* real-time response rendering.
|
|
273
|
+
*
|
|
274
|
+
* @param config Optional configuration override
|
|
275
|
+
* @returns Streamer async generator function
|
|
276
|
+
* @throws {ProviderError} If request fails
|
|
277
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
278
|
+
*/
|
|
279
|
+
createStreamer(config?: TConfig): Streamer<AIContextAny, AIMetadataAny>;
|
|
280
|
+
/**
|
|
281
|
+
* Get image generation parameters based on model and request.
|
|
282
|
+
*
|
|
283
|
+
* @param request - Image generation request
|
|
284
|
+
* @param model - Model ID
|
|
285
|
+
* @returns
|
|
286
|
+
*/
|
|
287
|
+
getGenerateParameters(request: ImageGenerationRequest, model: string): OpenAI.Images.ImageGenerateParams;
|
|
288
|
+
/**
|
|
289
|
+
* Generate images.
|
|
290
|
+
*
|
|
291
|
+
* @param request Image generation request parameters
|
|
292
|
+
* @param ctx Context object (not used)
|
|
293
|
+
* @param config Optional configuration override
|
|
294
|
+
* @returns Generated image URLs or base64 data
|
|
295
|
+
* @throws {ProviderError} If generation fails
|
|
296
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
297
|
+
*/
|
|
298
|
+
generateImage: Provider['generateImage'];
|
|
299
|
+
/**
|
|
300
|
+
* Generate images with streaming progress updates.
|
|
301
|
+
*
|
|
302
|
+
* Note: OpenAI's API doesn't natively support streaming image generation,
|
|
303
|
+
* so this implementation polls for progress or returns the result immediately.
|
|
304
|
+
*
|
|
305
|
+
* @param request Image generation request parameters
|
|
306
|
+
* @param ctx Context object (not used)
|
|
307
|
+
* @param config Optional configuration override
|
|
308
|
+
* @returns Async generator yielding progress chunks
|
|
309
|
+
* @throws {ProviderError} If generation fails
|
|
310
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
311
|
+
*/
|
|
312
|
+
generateImageStream: Provider['generateImageStream'];
|
|
313
|
+
/**
|
|
314
|
+
* Get image generation parameters based on model and request.
|
|
315
|
+
*
|
|
316
|
+
* @param request - Image generation request
|
|
317
|
+
* @param model - Model ID
|
|
318
|
+
* @returns
|
|
319
|
+
*/
|
|
320
|
+
getEditParameters(request: ImageEditRequest, model: string): Omit<OpenAI.Images.ImageEditParams, 'image'>;
|
|
321
|
+
/**
|
|
322
|
+
* Edit images using DALL-E models.
|
|
323
|
+
*
|
|
324
|
+
* Supports image editing with text prompts and optional masks.
|
|
325
|
+
*
|
|
326
|
+
* @param request Image edit request parameters
|
|
327
|
+
* @param ctx Context object (not used)
|
|
328
|
+
* @param config Optional configuration override
|
|
329
|
+
* @returns Edited image URLs or base64 data
|
|
330
|
+
* @throws {ProviderError} If editing fails
|
|
331
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
332
|
+
*/
|
|
333
|
+
editImage: Provider['editImage'];
|
|
334
|
+
/**
|
|
335
|
+
* Edit images with streaming progress updates.
|
|
336
|
+
*
|
|
337
|
+
* Note: OpenAI's API doesn't natively support streaming image editing,
|
|
338
|
+
* so this implementation returns the result with progress indicators.
|
|
339
|
+
*
|
|
340
|
+
* @param request Image edit request parameters
|
|
341
|
+
* @param ctx Context object (not used)
|
|
342
|
+
* @param config Optional configuration override
|
|
343
|
+
* @returns Async generator yielding progress chunks
|
|
344
|
+
* @throws {ProviderError} If editing fails
|
|
345
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
346
|
+
*/
|
|
347
|
+
editImageStream: Provider['editImageStream'];
|
|
348
|
+
/**
|
|
349
|
+
* Convert various image input types to Uploadable format.
|
|
350
|
+
*
|
|
351
|
+
* @param data Image data in various formats
|
|
352
|
+
* @returns Uploadable image for OpenAI API
|
|
353
|
+
*/
|
|
354
|
+
protected toUploadableImage(data: Buffer | Uint8Array | string): Uploadable;
|
|
355
|
+
/**
|
|
356
|
+
* Convert various audio input types to Uploadable format.
|
|
357
|
+
*
|
|
358
|
+
* @param data Audio data in various formats
|
|
359
|
+
* @returns Uploadable audio for OpenAI API
|
|
360
|
+
*/
|
|
361
|
+
protected toUploadableAudio(data: TranscriptionRequest['audio']): Uploadable;
|
|
362
|
+
/**
|
|
363
|
+
* Transcribe audio to text using Whisper models.
|
|
364
|
+
*
|
|
365
|
+
* Supports multiple audio formats and optional timestamps.
|
|
366
|
+
*
|
|
367
|
+
* @param request Transcription request parameters
|
|
368
|
+
* @param ctx Context object (not used)
|
|
369
|
+
* @param config Optional configuration override
|
|
370
|
+
* @returns Transcription text and optional metadata
|
|
371
|
+
* @throws {ProviderError} If transcription fails
|
|
372
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
373
|
+
*/
|
|
374
|
+
transcribe: Provider['transcribe'];
|
|
375
|
+
/**
|
|
376
|
+
* Transcribe audio with streaming progress updates.
|
|
377
|
+
*
|
|
378
|
+
* Note: OpenAI's API doesn't natively support streaming transcription,
|
|
379
|
+
* so this implementation returns the result with progress indicators.
|
|
380
|
+
*
|
|
381
|
+
* @param request Transcription request parameters
|
|
382
|
+
* @param ctx Context object (not used)
|
|
383
|
+
* @param config Optional configuration override
|
|
384
|
+
* @returns Async generator yielding transcription chunks
|
|
385
|
+
* @throws {ProviderError} If transcription fails
|
|
386
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
387
|
+
*/
|
|
388
|
+
transcribeStream: Provider['transcribeStream'];
|
|
389
|
+
/**
|
|
390
|
+
* Generate speech from text using TTS models.
|
|
391
|
+
*
|
|
392
|
+
* Supports multiple voices and audio formats.
|
|
393
|
+
*
|
|
394
|
+
* @param request Speech synthesis request parameters
|
|
395
|
+
* @param ctx Context object (not used)
|
|
396
|
+
* @param config Optional configuration override
|
|
397
|
+
* @returns Audio buffer and content type
|
|
398
|
+
* @throws {ProviderError} If speech generation fails
|
|
399
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
400
|
+
*/
|
|
401
|
+
speech: Provider['speech'];
|
|
402
|
+
/**
|
|
403
|
+
* Generate text embeddings for semantic search and similarity.
|
|
404
|
+
*
|
|
405
|
+
* Supports text-embedding-3-small, text-embedding-3-large, and ada-002 models.
|
|
406
|
+
*
|
|
407
|
+
* @param request Embedding request parameters
|
|
408
|
+
* @param ctx Context object (not used)
|
|
409
|
+
* @param config Optional configuration override
|
|
410
|
+
* @returns Array of embeddings with usage information
|
|
411
|
+
* @throws {ProviderError} If embedding generation fails
|
|
412
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
413
|
+
*/
|
|
414
|
+
embed: Provider['embed'];
|
|
415
|
+
/**
|
|
416
|
+
* Analyze images using vision-capable models.
|
|
417
|
+
*
|
|
418
|
+
* This method converts the image analysis request into a chat request
|
|
419
|
+
* with image content and calls the chat API internally.
|
|
420
|
+
*
|
|
421
|
+
* @param request Image analysis request parameters
|
|
422
|
+
* @param ctx Context object (not used)
|
|
423
|
+
* @param config Optional configuration override
|
|
424
|
+
* @returns Analysis response with text content
|
|
425
|
+
* @throws {ProviderError} If analysis fails
|
|
426
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
427
|
+
*/
|
|
428
|
+
analyzeImage: Provider['analyzeImage'];
|
|
429
|
+
/**
|
|
430
|
+
* Analyze images with streaming response.
|
|
431
|
+
*
|
|
432
|
+
* This method converts the image analysis request into a chat request
|
|
433
|
+
* with image content and calls the streaming chat API internally.
|
|
434
|
+
*
|
|
435
|
+
* @param request Image analysis request parameters
|
|
436
|
+
* @param ctx Context object (not used)
|
|
437
|
+
* @param config Optional configuration override
|
|
438
|
+
* @returns Async generator yielding response chunks
|
|
439
|
+
* @throws {ProviderError} If analysis fails
|
|
440
|
+
* @throws {RateLimitError} If rate limit is exceeded
|
|
441
|
+
*/
|
|
442
|
+
analyzeImageStream: Provider['analyzeImageStream'];
|
|
443
|
+
}
|
|
444
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAGhB,gBAAgB,EAEhB,sBAAsB,EAEtB,SAAS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