@effect/ai-openai 4.0.0-beta.65 → 4.0.0-beta.67

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 (47) hide show
  1. package/dist/Generated.d.ts +1 -1
  2. package/dist/Generated.js +1 -1
  3. package/dist/OpenAiClient.d.ts +18 -11
  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 +161 -10
  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 +108 -35
  25. package/dist/OpenAiSchema.d.ts.map +1 -1
  26. package/dist/OpenAiSchema.js +55 -18
  27. package/dist/OpenAiSchema.js.map +1 -1
  28. package/dist/OpenAiTelemetry.d.ts +13 -10
  29. package/dist/OpenAiTelemetry.d.ts.map +1 -1
  30. package/dist/OpenAiTelemetry.js +2 -2
  31. package/dist/OpenAiTelemetry.js.map +1 -1
  32. package/dist/OpenAiTool.d.ts +26 -26
  33. package/dist/OpenAiTool.js +10 -10
  34. package/dist/index.d.ts +11 -11
  35. package/dist/index.js +11 -11
  36. package/package.json +3 -3
  37. package/src/Generated.ts +1 -1
  38. package/src/OpenAiClient.ts +20 -13
  39. package/src/OpenAiClientGenerated.ts +6 -6
  40. package/src/OpenAiConfig.ts +43 -8
  41. package/src/OpenAiEmbeddingModel.ts +15 -11
  42. package/src/OpenAiError.ts +124 -3
  43. package/src/OpenAiLanguageModel.ts +163 -12
  44. package/src/OpenAiSchema.ts +109 -36
  45. package/src/OpenAiTelemetry.ts +14 -11
  46. package/src/OpenAiTool.ts +11 -11
  47. package/src/index.ts +11 -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,13 @@ 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
+ */
111
116
  export interface FilePartOptions extends ProviderOptions {
117
+ /**
118
+ * Provider-specific file options for the OpenAI Responses API.
119
+ */
112
120
  readonly openai?: {
113
121
  /**
114
122
  * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
@@ -117,7 +125,13 @@ declare module "effect/unstable/ai/Prompt" {
117
125
  } | null
118
126
  }
119
127
 
128
+ /**
129
+ * OpenAI-specific options for reasoning prompt parts.
130
+ */
120
131
  export interface ReasoningPartOptions extends ProviderOptions {
132
+ /**
133
+ * Provider-specific reasoning options for the OpenAI Responses API.
134
+ */
121
135
  readonly openai?: {
122
136
  /**
123
137
  * The ID of the item to reference.
@@ -132,7 +146,13 @@ declare module "effect/unstable/ai/Prompt" {
132
146
  } | null
133
147
  }
134
148
 
149
+ /**
150
+ * OpenAI-specific options for assistant tool-call prompt parts.
151
+ */
135
152
  export interface ToolCallPartOptions extends ProviderOptions {
153
+ /**
154
+ * Provider-specific tool-call options for the OpenAI Responses API.
155
+ */
136
156
  readonly openai?: {
137
157
  /**
138
158
  * The ID of the item to reference.
@@ -149,7 +169,13 @@ declare module "effect/unstable/ai/Prompt" {
149
169
  } | null
150
170
  }
151
171
 
172
+ /**
173
+ * OpenAI-specific options for tool-result prompt parts.
174
+ */
152
175
  export interface ToolResultPartOptions extends ProviderOptions {
176
+ /**
177
+ * Provider-specific tool-result options for the OpenAI Responses API.
178
+ */
153
179
  readonly openai?: {
154
180
  /**
155
181
  * The ID of the item to reference.
@@ -166,7 +192,13 @@ declare module "effect/unstable/ai/Prompt" {
166
192
  } | null
167
193
  }
168
194
 
195
+ /**
196
+ * OpenAI-specific options for text prompt parts.
197
+ */
169
198
  export interface TextPartOptions extends ProviderOptions {
199
+ /**
200
+ * Provider-specific text options for the OpenAI Responses API.
201
+ */
170
202
  readonly openai?: {
171
203
  /**
172
204
  * The ID of the item to reference.
@@ -185,8 +217,17 @@ declare module "effect/unstable/ai/Prompt" {
185
217
  }
186
218
 
187
219
  declare module "effect/unstable/ai/Response" {
220
+ /**
221
+ * OpenAI metadata attached to a complete text response part.
222
+ */
188
223
  export interface TextPartMetadata extends ProviderMetadata {
224
+ /**
225
+ * Provider-specific metadata returned for the text part.
226
+ */
189
227
  readonly openai?: {
228
+ /**
229
+ * The OpenAI item ID associated with the text part.
230
+ */
190
231
  readonly itemId?: string | null
191
232
  /**
192
233
  * If the model emits a refusal content part, the refusal explanation
@@ -205,55 +246,139 @@ declare module "effect/unstable/ai/Response" {
205
246
  }
206
247
  }
207
248
 
249
+ /**
250
+ * OpenAI metadata emitted when a streamed text part starts.
251
+ */
208
252
  export interface TextStartPartMetadata extends ProviderMetadata {
253
+ /**
254
+ * Provider-specific metadata returned for the streamed text start.
255
+ */
209
256
  readonly openai?: {
257
+ /**
258
+ * The OpenAI item ID associated with the streamed text part.
259
+ */
210
260
  readonly itemId?: string | null
211
261
  } | null
212
262
  }
213
263
 
264
+ /**
265
+ * OpenAI metadata emitted when a streamed text part ends.
266
+ */
214
267
  export interface TextEndPartMetadata extends ProviderMetadata {
268
+ /**
269
+ * Provider-specific metadata returned for the streamed text end.
270
+ */
215
271
  readonly openai?: {
272
+ /**
273
+ * The OpenAI item ID associated with the streamed text part.
274
+ */
216
275
  readonly itemId?: string | null
276
+ /**
277
+ * The annotations collected for the completed streamed text part.
278
+ */
217
279
  readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null
218
280
  } | null
219
281
  }
220
282
 
283
+ /**
284
+ * OpenAI metadata attached to a complete reasoning response part.
285
+ */
221
286
  export interface ReasoningPartMetadata extends ProviderMetadata {
287
+ /**
288
+ * Provider-specific metadata returned for the reasoning part.
289
+ */
222
290
  readonly openai?: {
291
+ /**
292
+ * The OpenAI item ID associated with the reasoning part.
293
+ */
223
294
  readonly itemId?: string | null
295
+ /**
296
+ * Encrypted reasoning content that can be sent back in later requests.
297
+ */
224
298
  readonly encryptedContent?: string | null
225
299
  } | null
226
300
  }
227
301
 
302
+ /**
303
+ * OpenAI metadata emitted when a streamed reasoning part starts.
304
+ */
228
305
  export interface ReasoningStartPartMetadata extends ProviderMetadata {
306
+ /**
307
+ * Provider-specific metadata returned for the streamed reasoning start.
308
+ */
229
309
  readonly openai?: {
310
+ /**
311
+ * The OpenAI item ID associated with the reasoning part.
312
+ */
230
313
  readonly itemId?: string | null
314
+ /**
315
+ * Encrypted reasoning content that can be sent back in later requests.
316
+ */
231
317
  readonly encryptedContent?: string | null
232
318
  } | null
233
319
  }
234
320
 
321
+ /**
322
+ * OpenAI metadata emitted for a streamed reasoning delta.
323
+ */
235
324
  export interface ReasoningDeltaPartMetadata extends ProviderMetadata {
325
+ /**
326
+ * Provider-specific metadata returned for the streamed reasoning delta.
327
+ */
236
328
  readonly openai?: {
329
+ /**
330
+ * The OpenAI item ID associated with the reasoning part.
331
+ */
237
332
  readonly itemId?: string | null
238
333
  } | null
239
334
  }
240
335
 
336
+ /**
337
+ * OpenAI metadata emitted when a streamed reasoning part ends.
338
+ */
241
339
  export interface ReasoningEndPartMetadata extends ProviderMetadata {
340
+ /**
341
+ * Provider-specific metadata returned for the streamed reasoning end.
342
+ */
242
343
  readonly openai?: {
344
+ /**
345
+ * The OpenAI item ID associated with the reasoning part.
346
+ */
243
347
  readonly itemId?: string | null
348
+ /**
349
+ * Encrypted reasoning content that can be sent back in later requests.
350
+ */
244
351
  readonly encryptedContent?: string
245
352
  } | null
246
353
  }
247
354
 
355
+ /**
356
+ * OpenAI metadata attached to tool-call response parts.
357
+ */
248
358
  export interface ToolCallPartMetadata extends ProviderMetadata {
359
+ /**
360
+ * Provider-specific metadata returned for the tool call.
361
+ */
249
362
  readonly openai?: {
363
+ /**
364
+ * The OpenAI item ID associated with the tool call.
365
+ */
250
366
  readonly itemId?: string | null
251
367
  } | null
252
368
  }
253
369
 
370
+ /**
371
+ * OpenAI metadata attached to document source citations.
372
+ */
254
373
  export interface DocumentSourcePartMetadata extends ProviderMetadata {
374
+ /**
375
+ * Provider-specific citation metadata for the OpenAI Responses API.
376
+ */
255
377
  readonly openai?:
256
378
  | {
379
+ /**
380
+ * Identifies a citation to an uploaded file.
381
+ */
257
382
  readonly type: "file_citation"
258
383
  /**
259
384
  * The index of the file in the list of files.
@@ -265,6 +390,9 @@ declare module "effect/unstable/ai/Response" {
265
390
  readonly fileId: string
266
391
  }
267
392
  | {
393
+ /**
394
+ * Identifies a citation to a generated file path.
395
+ */
268
396
  readonly type: "file_path"
269
397
  /**
270
398
  * The index of the file in the list of files.
@@ -276,6 +404,9 @@ declare module "effect/unstable/ai/Response" {
276
404
  readonly fileId: string
277
405
  }
278
406
  | {
407
+ /**
408
+ * Identifies a citation to a file inside a container.
409
+ */
279
410
  readonly type: "container_file_citation"
280
411
  /**
281
412
  * The ID of the file.
@@ -289,8 +420,17 @@ declare module "effect/unstable/ai/Response" {
289
420
  | null
290
421
  }
291
422
 
423
+ /**
424
+ * OpenAI metadata attached to URL source citations.
425
+ */
292
426
  export interface UrlSourcePartMetadata extends ProviderMetadata {
427
+ /**
428
+ * Provider-specific URL citation metadata for the OpenAI Responses API.
429
+ */
293
430
  readonly openai?: {
431
+ /**
432
+ * Identifies a citation to a URL.
433
+ */
294
434
  readonly type: "url_citation"
295
435
  /**
296
436
  * The index of the first character of the URL citation in the message.
@@ -303,8 +443,17 @@ declare module "effect/unstable/ai/Response" {
303
443
  } | null
304
444
  }
305
445
 
446
+ /**
447
+ * OpenAI metadata attached to finish response parts.
448
+ */
306
449
  export interface FinishPartMetadata extends ProviderMetadata {
450
+ /**
451
+ * Provider-specific metadata returned when generation finishes.
452
+ */
307
453
  readonly openai?: {
454
+ /**
455
+ * The service tier reported by OpenAI for the response.
456
+ */
308
457
  readonly serviceTier?: "default" | "auto" | "flex" | "scale" | "priority" | null
309
458
  } | null
310
459
  }
@@ -315,8 +464,10 @@ declare module "effect/unstable/ai/Response" {
315
464
  // =============================================================================
316
465
 
317
466
  /**
318
- * @since 1.0.0
467
+ * Creates an OpenAI language model that can be used with `AiModel.provide`.
468
+ *
319
469
  * @category constructors
470
+ * @since 4.0.0
320
471
  */
321
472
  export const model = (
322
473
  model: (string & {}) | Model,
@@ -326,7 +477,7 @@ export const model = (
326
477
 
327
478
  // TODO
328
479
  // /**
329
- // * @since 1.0.0
480
+ // * @since 4.0.0
330
481
  // * @category constructors
331
482
  // */
332
483
  // export const modelWithTokenizer = (
@@ -338,8 +489,8 @@ export const model = (
338
489
  /**
339
490
  * Creates an OpenAI language model service.
340
491
  *
341
- * @since 1.0.0
342
492
  * @category constructors
493
+ * @since 4.0.0
343
494
  */
344
495
  export const make = Effect.fnUntraced(function*({ model, config: providerConfig }: {
345
496
  readonly model: (string & {}) | Model
@@ -441,8 +592,8 @@ export const make = Effect.fnUntraced(function*({ model, config: providerConfig
441
592
  /**
442
593
  * Creates a layer for the OpenAI language model.
443
594
  *
444
- * @since 1.0.0
445
595
  * @category layers
596
+ * @since 4.0.0
446
597
  */
447
598
  export const layer = (options: {
448
599
  readonly model: (string & {}) | Model
@@ -453,37 +604,37 @@ export const layer = (options: {
453
604
  /**
454
605
  * Provides config overrides for OpenAI language model operations.
455
606
  *
456
- * @since 1.0.0
457
607
  * @category configuration
608
+ * @since 4.0.0
458
609
  */
459
610
  export const withConfigOverride: {
460
611
  /**
461
612
  * Provides config overrides for OpenAI language model operations.
462
613
  *
463
- * @since 1.0.0
464
614
  * @category configuration
615
+ * @since 4.0.0
465
616
  */
466
617
  (overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>
467
618
  /**
468
619
  * Provides config overrides for OpenAI language model operations.
469
620
  *
470
- * @since 1.0.0
471
621
  * @category configuration
622
+ * @since 4.0.0
472
623
  */
473
624
  <A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>
474
625
  } = dual<
475
626
  /**
476
627
  * Provides config overrides for OpenAI language model operations.
477
628
  *
478
- * @since 1.0.0
479
629
  * @category configuration
630
+ * @since 4.0.0
480
631
  */
481
632
  (overrides: typeof Config.Service) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>,
482
633
  /**
483
634
  * Provides config overrides for OpenAI language model operations.
484
635
  *
485
- * @since 1.0.0
486
636
  * @category configuration
637
+ * @since 4.0.0
487
638
  */
488
639
  <A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service) => Effect.Effect<A, E, Exclude<R, Config>>
489
640
  >(2, (self, overrides) =>