@effect/ai-openai 4.0.0-beta.66 → 4.0.0-beta.68

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.
Files changed (49) hide show
  1. package/dist/Generated.d.ts +1 -1
  2. package/dist/Generated.js +1 -1
  3. package/dist/OpenAiClient.d.ts +19 -12
  4. package/dist/OpenAiClient.d.ts.map +1 -1
  5. package/dist/OpenAiClient.js +11 -9
  6. package/dist/OpenAiClient.js.map +1 -1
  7. package/dist/OpenAiClientGenerated.d.ts +5 -5
  8. package/dist/OpenAiClientGenerated.js +5 -5
  9. package/dist/OpenAiConfig.d.ts +43 -8
  10. package/dist/OpenAiConfig.d.ts.map +1 -1
  11. package/dist/OpenAiConfig.js +28 -4
  12. package/dist/OpenAiConfig.js.map +1 -1
  13. package/dist/OpenAiEmbeddingModel.d.ts +13 -9
  14. package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
  15. package/dist/OpenAiEmbeddingModel.js +8 -6
  16. package/dist/OpenAiEmbeddingModel.js.map +1 -1
  17. package/dist/OpenAiError.d.ts +124 -3
  18. package/dist/OpenAiError.d.ts.map +1 -1
  19. package/dist/OpenAiError.js +1 -1
  20. package/dist/OpenAiLanguageModel.d.ts +208 -9
  21. package/dist/OpenAiLanguageModel.d.ts.map +1 -1
  22. package/dist/OpenAiLanguageModel.js +9 -7
  23. package/dist/OpenAiLanguageModel.js.map +1 -1
  24. package/dist/OpenAiSchema.d.ts +143 -35
  25. package/dist/OpenAiSchema.d.ts.map +1 -1
  26. package/dist/OpenAiSchema.js +72 -18
  27. package/dist/OpenAiSchema.js.map +1 -1
  28. package/dist/OpenAiTelemetry.d.ts +17 -14
  29. package/dist/OpenAiTelemetry.d.ts.map +1 -1
  30. package/dist/OpenAiTelemetry.js +3 -3
  31. package/dist/OpenAiTelemetry.js.map +1 -1
  32. package/dist/OpenAiTool.d.ts +11 -11
  33. package/dist/OpenAiTool.js +10 -10
  34. package/dist/index.d.ts +27 -11
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +27 -11
  37. package/dist/index.js.map +1 -1
  38. package/package.json +3 -3
  39. package/src/Generated.ts +1 -1
  40. package/src/OpenAiClient.ts +20 -13
  41. package/src/OpenAiClientGenerated.ts +6 -6
  42. package/src/OpenAiConfig.ts +43 -8
  43. package/src/OpenAiEmbeddingModel.ts +15 -11
  44. package/src/OpenAiError.ts +124 -3
  45. package/src/OpenAiLanguageModel.ts +211 -12
  46. package/src/OpenAiSchema.ts +144 -36
  47. package/src/OpenAiTelemetry.ts +18 -15
  48. package/src/OpenAiTool.ts +11 -11
  49. package/src/index.ts +27 -11
@@ -4,7 +4,7 @@
4
4
  * Provides a LanguageModel implementation for OpenAI's responses API,
5
5
  * supporting text generation, structured output, tool calling, and streaming.
6
6
  *
7
- * @since 1.0.0
7
+ * @since 4.0.0
8
8
  */
9
9
  import * as Context from "effect/Context"
10
10
  import * as DateTime from "effect/DateTime"
@@ -41,8 +41,10 @@ const ResponseModelIds = Generated.ModelIdsResponses.members[1]
41
41
  const SharedModelIds = Generated.ModelIdsShared.members[1]
42
42
 
43
43
  /**
44
- * @since 1.0.0
44
+ * OpenAI model identifiers supported by the Responses API language model.
45
+ *
45
46
  * @category models
47
+ * @since 4.0.0
46
48
  */
47
49
  export type Model = typeof ResponseModelIds.Encoded | typeof SharedModelIds.Encoded
48
50
 
@@ -58,8 +60,8 @@ type ImageDetail = "auto" | "low" | "high"
58
60
  /**
59
61
  * Service definition for OpenAI language model configuration.
60
62
  *
61
- * @since 1.0.0
62
63
  * @category services
64
+ * @since 4.0.0
63
65
  */
64
66
  export class Config extends Context.Service<
65
67
  Config,
@@ -108,7 +110,16 @@ export class Config extends Context.Service<
108
110
  // =============================================================================
109
111
 
110
112
  declare module "effect/unstable/ai/Prompt" {
113
+ /**
114
+ * OpenAI-specific options for file prompt parts.
115
+ *
116
+ * @category request
117
+ * @since 4.0.0
118
+ */
111
119
  export interface FilePartOptions extends ProviderOptions {
120
+ /**
121
+ * Provider-specific file options for the OpenAI Responses API.
122
+ */
112
123
  readonly openai?: {
113
124
  /**
114
125
  * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
@@ -117,7 +128,16 @@ declare module "effect/unstable/ai/Prompt" {
117
128
  } | null
118
129
  }
119
130
 
131
+ /**
132
+ * OpenAI-specific options for reasoning prompt parts.
133
+ *
134
+ * @category request
135
+ * @since 4.0.0
136
+ */
120
137
  export interface ReasoningPartOptions extends ProviderOptions {
138
+ /**
139
+ * Provider-specific reasoning options for the OpenAI Responses API.
140
+ */
121
141
  readonly openai?: {
122
142
  /**
123
143
  * The ID of the item to reference.
@@ -132,7 +152,16 @@ declare module "effect/unstable/ai/Prompt" {
132
152
  } | null
133
153
  }
134
154
 
155
+ /**
156
+ * OpenAI-specific options for assistant tool-call prompt parts.
157
+ *
158
+ * @category request
159
+ * @since 4.0.0
160
+ */
135
161
  export interface ToolCallPartOptions extends ProviderOptions {
162
+ /**
163
+ * Provider-specific tool-call options for the OpenAI Responses API.
164
+ */
136
165
  readonly openai?: {
137
166
  /**
138
167
  * The ID of the item to reference.
@@ -149,7 +178,16 @@ declare module "effect/unstable/ai/Prompt" {
149
178
  } | null
150
179
  }
151
180
 
181
+ /**
182
+ * OpenAI-specific options for tool-result prompt parts.
183
+ *
184
+ * @category request
185
+ * @since 4.0.0
186
+ */
152
187
  export interface ToolResultPartOptions extends ProviderOptions {
188
+ /**
189
+ * Provider-specific tool-result options for the OpenAI Responses API.
190
+ */
153
191
  readonly openai?: {
154
192
  /**
155
193
  * The ID of the item to reference.
@@ -166,7 +204,16 @@ declare module "effect/unstable/ai/Prompt" {
166
204
  } | null
167
205
  }
168
206
 
207
+ /**
208
+ * OpenAI-specific options for text prompt parts.
209
+ *
210
+ * @category request
211
+ * @since 4.0.0
212
+ */
169
213
  export interface TextPartOptions extends ProviderOptions {
214
+ /**
215
+ * Provider-specific text options for the OpenAI Responses API.
216
+ */
170
217
  readonly openai?: {
171
218
  /**
172
219
  * The ID of the item to reference.
@@ -185,8 +232,20 @@ declare module "effect/unstable/ai/Prompt" {
185
232
  }
186
233
 
187
234
  declare module "effect/unstable/ai/Response" {
235
+ /**
236
+ * OpenAI metadata attached to a complete text response part.
237
+ *
238
+ * @category response
239
+ * @since 4.0.0
240
+ */
188
241
  export interface TextPartMetadata extends ProviderMetadata {
242
+ /**
243
+ * Provider-specific metadata returned for the text part.
244
+ */
189
245
  readonly openai?: {
246
+ /**
247
+ * The OpenAI item ID associated with the text part.
248
+ */
190
249
  readonly itemId?: string | null
191
250
  /**
192
251
  * If the model emits a refusal content part, the refusal explanation
@@ -205,55 +264,163 @@ declare module "effect/unstable/ai/Response" {
205
264
  }
206
265
  }
207
266
 
267
+ /**
268
+ * OpenAI metadata emitted when a streamed text part starts.
269
+ *
270
+ * @category response
271
+ * @since 4.0.0
272
+ */
208
273
  export interface TextStartPartMetadata extends ProviderMetadata {
274
+ /**
275
+ * Provider-specific metadata returned for the streamed text start.
276
+ */
209
277
  readonly openai?: {
278
+ /**
279
+ * The OpenAI item ID associated with the streamed text part.
280
+ */
210
281
  readonly itemId?: string | null
211
282
  } | null
212
283
  }
213
284
 
285
+ /**
286
+ * OpenAI metadata emitted when a streamed text part ends.
287
+ *
288
+ * @category response
289
+ * @since 4.0.0
290
+ */
214
291
  export interface TextEndPartMetadata extends ProviderMetadata {
292
+ /**
293
+ * Provider-specific metadata returned for the streamed text end.
294
+ */
215
295
  readonly openai?: {
296
+ /**
297
+ * The OpenAI item ID associated with the streamed text part.
298
+ */
216
299
  readonly itemId?: string | null
300
+ /**
301
+ * The annotations collected for the completed streamed text part.
302
+ */
217
303
  readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null
218
304
  } | null
219
305
  }
220
306
 
307
+ /**
308
+ * OpenAI metadata attached to a complete reasoning response part.
309
+ *
310
+ * @category response
311
+ * @since 4.0.0
312
+ */
221
313
  export interface ReasoningPartMetadata extends ProviderMetadata {
314
+ /**
315
+ * Provider-specific metadata returned for the reasoning part.
316
+ */
222
317
  readonly openai?: {
318
+ /**
319
+ * The OpenAI item ID associated with the reasoning part.
320
+ */
223
321
  readonly itemId?: string | null
322
+ /**
323
+ * Encrypted reasoning content that can be sent back in later requests.
324
+ */
224
325
  readonly encryptedContent?: string | null
225
326
  } | null
226
327
  }
227
328
 
329
+ /**
330
+ * OpenAI metadata emitted when a streamed reasoning part starts.
331
+ *
332
+ * @category response
333
+ * @since 4.0.0
334
+ */
228
335
  export interface ReasoningStartPartMetadata extends ProviderMetadata {
336
+ /**
337
+ * Provider-specific metadata returned for the streamed reasoning start.
338
+ */
229
339
  readonly openai?: {
340
+ /**
341
+ * The OpenAI item ID associated with the reasoning part.
342
+ */
230
343
  readonly itemId?: string | null
344
+ /**
345
+ * Encrypted reasoning content that can be sent back in later requests.
346
+ */
231
347
  readonly encryptedContent?: string | null
232
348
  } | null
233
349
  }
234
350
 
351
+ /**
352
+ * OpenAI metadata emitted for a streamed reasoning delta.
353
+ *
354
+ * @category response
355
+ * @since 4.0.0
356
+ */
235
357
  export interface ReasoningDeltaPartMetadata extends ProviderMetadata {
358
+ /**
359
+ * Provider-specific metadata returned for the streamed reasoning delta.
360
+ */
236
361
  readonly openai?: {
362
+ /**
363
+ * The OpenAI item ID associated with the reasoning part.
364
+ */
237
365
  readonly itemId?: string | null
238
366
  } | null
239
367
  }
240
368
 
369
+ /**
370
+ * OpenAI metadata emitted when a streamed reasoning part ends.
371
+ *
372
+ * @category response
373
+ * @since 4.0.0
374
+ */
241
375
  export interface ReasoningEndPartMetadata extends ProviderMetadata {
376
+ /**
377
+ * Provider-specific metadata returned for the streamed reasoning end.
378
+ */
242
379
  readonly openai?: {
380
+ /**
381
+ * The OpenAI item ID associated with the reasoning part.
382
+ */
243
383
  readonly itemId?: string | null
384
+ /**
385
+ * Encrypted reasoning content that can be sent back in later requests.
386
+ */
244
387
  readonly encryptedContent?: string
245
388
  } | null
246
389
  }
247
390
 
391
+ /**
392
+ * OpenAI metadata attached to tool-call response parts.
393
+ *
394
+ * @category response
395
+ * @since 4.0.0
396
+ */
248
397
  export interface ToolCallPartMetadata extends ProviderMetadata {
398
+ /**
399
+ * Provider-specific metadata returned for the tool call.
400
+ */
249
401
  readonly openai?: {
402
+ /**
403
+ * The OpenAI item ID associated with the tool call.
404
+ */
250
405
  readonly itemId?: string | null
251
406
  } | null
252
407
  }
253
408
 
409
+ /**
410
+ * OpenAI metadata attached to document source citations.
411
+ *
412
+ * @category response
413
+ * @since 4.0.0
414
+ */
254
415
  export interface DocumentSourcePartMetadata extends ProviderMetadata {
416
+ /**
417
+ * Provider-specific citation metadata for the OpenAI Responses API.
418
+ */
255
419
  readonly openai?:
256
420
  | {
421
+ /**
422
+ * Identifies a citation to an uploaded file.
423
+ */
257
424
  readonly type: "file_citation"
258
425
  /**
259
426
  * The index of the file in the list of files.
@@ -265,6 +432,9 @@ declare module "effect/unstable/ai/Response" {
265
432
  readonly fileId: string
266
433
  }
267
434
  | {
435
+ /**
436
+ * Identifies a citation to a generated file path.
437
+ */
268
438
  readonly type: "file_path"
269
439
  /**
270
440
  * The index of the file in the list of files.
@@ -276,6 +446,9 @@ declare module "effect/unstable/ai/Response" {
276
446
  readonly fileId: string
277
447
  }
278
448
  | {
449
+ /**
450
+ * Identifies a citation to a file inside a container.
451
+ */
279
452
  readonly type: "container_file_citation"
280
453
  /**
281
454
  * The ID of the file.
@@ -289,8 +462,20 @@ declare module "effect/unstable/ai/Response" {
289
462
  | null
290
463
  }
291
464
 
465
+ /**
466
+ * OpenAI metadata attached to URL source citations.
467
+ *
468
+ * @category response
469
+ * @since 4.0.0
470
+ */
292
471
  export interface UrlSourcePartMetadata extends ProviderMetadata {
472
+ /**
473
+ * Provider-specific URL citation metadata for the OpenAI Responses API.
474
+ */
293
475
  readonly openai?: {
476
+ /**
477
+ * Identifies a citation to a URL.
478
+ */
294
479
  readonly type: "url_citation"
295
480
  /**
296
481
  * The index of the first character of the URL citation in the message.
@@ -303,8 +488,20 @@ declare module "effect/unstable/ai/Response" {
303
488
  } | null
304
489
  }
305
490
 
491
+ /**
492
+ * OpenAI metadata attached to finish response parts.
493
+ *
494
+ * @category response
495
+ * @since 4.0.0
496
+ */
306
497
  export interface FinishPartMetadata extends ProviderMetadata {
498
+ /**
499
+ * Provider-specific metadata returned when generation finishes.
500
+ */
307
501
  readonly openai?: {
502
+ /**
503
+ * The service tier reported by OpenAI for the response.
504
+ */
308
505
  readonly serviceTier?: "default" | "auto" | "flex" | "scale" | "priority" | null
309
506
  } | null
310
507
  }
@@ -315,8 +512,10 @@ declare module "effect/unstable/ai/Response" {
315
512
  // =============================================================================
316
513
 
317
514
  /**
318
- * @since 1.0.0
515
+ * Creates an OpenAI language model that can be used with `AiModel.provide`.
516
+ *
319
517
  * @category constructors
518
+ * @since 4.0.0
320
519
  */
321
520
  export const model = (
322
521
  model: (string & {}) | Model,
@@ -326,7 +525,7 @@ export const model = (
326
525
 
327
526
  // TODO
328
527
  // /**
329
- // * @since 1.0.0
528
+ // * @since 4.0.0
330
529
  // * @category constructors
331
530
  // */
332
531
  // export const modelWithTokenizer = (
@@ -338,8 +537,8 @@ export const model = (
338
537
  /**
339
538
  * Creates an OpenAI language model service.
340
539
  *
341
- * @since 1.0.0
342
540
  * @category constructors
541
+ * @since 4.0.0
343
542
  */
344
543
  export const make = Effect.fnUntraced(function*({ model, config: providerConfig }: {
345
544
  readonly model: (string & {}) | Model
@@ -441,8 +640,8 @@ export const make = Effect.fnUntraced(function*({ model, config: providerConfig
441
640
  /**
442
641
  * Creates a layer for the OpenAI language model.
443
642
  *
444
- * @since 1.0.0
445
643
  * @category layers
644
+ * @since 4.0.0
446
645
  */
447
646
  export const layer = (options: {
448
647
  readonly model: (string & {}) | Model
@@ -453,37 +652,37 @@ export const layer = (options: {
453
652
  /**
454
653
  * Provides config overrides for OpenAI language model operations.
455
654
  *
456
- * @since 1.0.0
457
655
  * @category configuration
656
+ * @since 4.0.0
458
657
  */
459
658
  export const withConfigOverride: {
460
659
  /**
461
660
  * Provides config overrides for OpenAI language model operations.
462
661
  *
463
- * @since 1.0.0
464
662
  * @category configuration
663
+ * @since 4.0.0
465
664
  */
466
665
  (overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>
467
666
  /**
468
667
  * Provides config overrides for OpenAI language model operations.
469
668
  *
470
- * @since 1.0.0
471
669
  * @category configuration
670
+ * @since 4.0.0
472
671
  */
473
672
  <A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>
474
673
  } = dual<
475
674
  /**
476
675
  * Provides config overrides for OpenAI language model operations.
477
676
  *
478
- * @since 1.0.0
479
677
  * @category configuration
678
+ * @since 4.0.0
480
679
  */
481
680
  (overrides: typeof Config.Service) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>,
482
681
  /**
483
682
  * Provides config overrides for OpenAI language model operations.
484
683
  *
485
- * @since 1.0.0
486
684
  * @category configuration
685
+ * @since 4.0.0
487
686
  */
488
687
  <A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service) => Effect.Effect<A, E, Exclude<R, Config>>
489
688
  >(2, (self, overrides) =>