@ai-sdk/openai 3.0.0-beta.50 → 3.0.0-beta.51

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/dist/index.mjs CHANGED
@@ -2691,6 +2691,20 @@ var openaiResponsesChunkSchema = lazySchema14(
2691
2691
  start_index: z16.number().nullish(),
2692
2692
  end_index: z16.number().nullish(),
2693
2693
  quote: z16.string().nullish()
2694
+ }),
2695
+ z16.object({
2696
+ type: z16.literal("container_file_citation"),
2697
+ container_id: z16.string(),
2698
+ file_id: z16.string(),
2699
+ filename: z16.string().nullish(),
2700
+ start_index: z16.number().nullish(),
2701
+ end_index: z16.number().nullish(),
2702
+ index: z16.number().nullish()
2703
+ }),
2704
+ z16.object({
2705
+ type: z16.literal("file_path"),
2706
+ file_id: z16.string(),
2707
+ index: z16.number().nullish()
2694
2708
  })
2695
2709
  ])
2696
2710
  }),
@@ -2776,7 +2790,18 @@ var openaiResponsesResponseSchema = lazySchema14(
2776
2790
  quote: z16.string().nullish()
2777
2791
  }),
2778
2792
  z16.object({
2779
- type: z16.literal("container_file_citation")
2793
+ type: z16.literal("container_file_citation"),
2794
+ container_id: z16.string(),
2795
+ file_id: z16.string(),
2796
+ filename: z16.string().nullish(),
2797
+ start_index: z16.number().nullish(),
2798
+ end_index: z16.number().nullish(),
2799
+ index: z16.number().nullish()
2800
+ }),
2801
+ z16.object({
2802
+ type: z16.literal("file_path"),
2803
+ file_id: z16.string(),
2804
+ index: z16.number().nullish()
2780
2805
  })
2781
2806
  ])
2782
2807
  )
@@ -3360,7 +3385,7 @@ var OpenAIResponsesLanguageModel = class {
3360
3385
  };
3361
3386
  }
3362
3387
  async doGenerate(options) {
3363
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3388
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
3364
3389
  const {
3365
3390
  args: body,
3366
3391
  warnings,
@@ -3458,13 +3483,17 @@ var OpenAIResponsesLanguageModel = class {
3458
3483
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
3459
3484
  logprobs.push(contentPart.logprobs);
3460
3485
  }
3486
+ const providerMetadata2 = {
3487
+ itemId: part.id,
3488
+ ...contentPart.annotations.length > 0 && {
3489
+ annotations: contentPart.annotations
3490
+ }
3491
+ };
3461
3492
  content.push({
3462
3493
  type: "text",
3463
3494
  text: contentPart.text,
3464
3495
  providerMetadata: {
3465
- openai: {
3466
- itemId: part.id
3467
- }
3496
+ openai: providerMetadata2
3468
3497
  }
3469
3498
  });
3470
3499
  for (const annotation of contentPart.annotations) {
@@ -3492,6 +3521,37 @@ var OpenAIResponsesLanguageModel = class {
3492
3521
  }
3493
3522
  } : {}
3494
3523
  });
3524
+ } else if (annotation.type === "container_file_citation") {
3525
+ content.push({
3526
+ type: "source",
3527
+ sourceType: "document",
3528
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
3529
+ mediaType: "text/plain",
3530
+ title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
3531
+ filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
3532
+ providerMetadata: {
3533
+ openai: {
3534
+ fileId: annotation.file_id,
3535
+ containerId: annotation.container_id,
3536
+ ...annotation.index != null ? { index: annotation.index } : {}
3537
+ }
3538
+ }
3539
+ });
3540
+ } else if (annotation.type === "file_path") {
3541
+ content.push({
3542
+ type: "source",
3543
+ sourceType: "document",
3544
+ id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
3545
+ mediaType: "application/octet-stream",
3546
+ title: annotation.file_id,
3547
+ filename: annotation.file_id,
3548
+ providerMetadata: {
3549
+ openai: {
3550
+ fileId: annotation.file_id,
3551
+ ...annotation.index != null ? { index: annotation.index } : {}
3552
+ }
3553
+ }
3554
+ });
3495
3555
  }
3496
3556
  }
3497
3557
  }
@@ -3561,13 +3621,13 @@ var OpenAIResponsesLanguageModel = class {
3561
3621
  toolName: "file_search",
3562
3622
  result: {
3563
3623
  queries: part.queries,
3564
- results: (_n = (_m = part.results) == null ? void 0 : _m.map((result) => ({
3624
+ results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
3565
3625
  attributes: result.attributes,
3566
3626
  fileId: result.file_id,
3567
3627
  filename: result.filename,
3568
3628
  score: result.score,
3569
3629
  text: result.text
3570
- }))) != null ? _n : null
3630
+ }))) != null ? _w : null
3571
3631
  }
3572
3632
  });
3573
3633
  break;
@@ -3607,15 +3667,15 @@ var OpenAIResponsesLanguageModel = class {
3607
3667
  return {
3608
3668
  content,
3609
3669
  finishReason: mapOpenAIResponseFinishReason({
3610
- finishReason: (_o = response.incomplete_details) == null ? void 0 : _o.reason,
3670
+ finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
3611
3671
  hasFunctionCall
3612
3672
  }),
3613
3673
  usage: {
3614
3674
  inputTokens: response.usage.input_tokens,
3615
3675
  outputTokens: response.usage.output_tokens,
3616
3676
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
3617
- reasoningTokens: (_q = (_p = response.usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
3618
- cachedInputTokens: (_s = (_r = response.usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
3677
+ reasoningTokens: (_z = (_y = response.usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
3678
+ cachedInputTokens: (_B = (_A = response.usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
3619
3679
  },
3620
3680
  request: { body },
3621
3681
  response: {
@@ -3673,7 +3733,7 @@ var OpenAIResponsesLanguageModel = class {
3673
3733
  controller.enqueue({ type: "stream-start", warnings });
3674
3734
  },
3675
3735
  transform(chunk, controller) {
3676
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
3736
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
3677
3737
  if (options.includeRawChunks) {
3678
3738
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3679
3739
  }
@@ -4078,6 +4138,37 @@ var OpenAIResponsesLanguageModel = class {
4078
4138
  }
4079
4139
  } : {}
4080
4140
  });
4141
+ } else if (value.annotation.type === "container_file_citation") {
4142
+ controller.enqueue({
4143
+ type: "source",
4144
+ sourceType: "document",
4145
+ id: (_y = (_x = (_w = self.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : generateId2(),
4146
+ mediaType: "text/plain",
4147
+ title: (_A = (_z = value.annotation.filename) != null ? _z : value.annotation.file_id) != null ? _A : "Document",
4148
+ filename: (_B = value.annotation.filename) != null ? _B : value.annotation.file_id,
4149
+ providerMetadata: {
4150
+ openai: {
4151
+ fileId: value.annotation.file_id,
4152
+ containerId: value.annotation.container_id,
4153
+ ...value.annotation.index != null ? { index: value.annotation.index } : {}
4154
+ }
4155
+ }
4156
+ });
4157
+ } else if (value.annotation.type === "file_path") {
4158
+ controller.enqueue({
4159
+ type: "source",
4160
+ sourceType: "document",
4161
+ id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
4162
+ mediaType: "application/octet-stream",
4163
+ title: value.annotation.file_id,
4164
+ filename: value.annotation.file_id,
4165
+ providerMetadata: {
4166
+ openai: {
4167
+ fileId: value.annotation.file_id,
4168
+ ...value.annotation.index != null ? { index: value.annotation.index } : {}
4169
+ }
4170
+ }
4171
+ });
4081
4172
  }
4082
4173
  } else if (isErrorChunk(value)) {
4083
4174
  controller.enqueue({ type: "error", error: value });
@@ -4551,7 +4642,7 @@ var OpenAITranscriptionModel = class {
4551
4642
  };
4552
4643
 
4553
4644
  // src/version.ts
4554
- var VERSION = true ? "3.0.0-beta.50" : "0.0.0-test";
4645
+ var VERSION = true ? "3.0.0-beta.51" : "0.0.0-test";
4555
4646
 
4556
4647
  // src/openai-provider.ts
4557
4648
  function createOpenAI(options = {}) {