@ai-sdk/openai 3.0.6 → 3.0.8

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.
@@ -1778,11 +1778,16 @@ var modelMaxImagesPerCall = {
1778
1778
  "gpt-image-1-mini": 10,
1779
1779
  "gpt-image-1.5": 10
1780
1780
  };
1781
- var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
1782
- "gpt-image-1",
1781
+ var defaultResponseFormatPrefixes = [
1783
1782
  "gpt-image-1-mini",
1784
- "gpt-image-1.5"
1785
- ]);
1783
+ "gpt-image-1.5",
1784
+ "gpt-image-1"
1785
+ ];
1786
+ function hasDefaultResponseFormat(modelId) {
1787
+ return defaultResponseFormatPrefixes.some(
1788
+ (prefix) => modelId.startsWith(prefix)
1789
+ );
1790
+ }
1786
1791
 
1787
1792
  // src/image/openai-image-model.ts
1788
1793
  var OpenAIImageModel = class {
@@ -1901,7 +1906,7 @@ var OpenAIImageModel = class {
1901
1906
  n,
1902
1907
  size,
1903
1908
  ...(_h = providerOptions.openai) != null ? _h : {},
1904
- ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1909
+ ...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
1905
1910
  },
1906
1911
  failedResponseHandler: openaiFailedResponseHandler,
1907
1912
  successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
@@ -3222,25 +3227,21 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
3222
3227
  import_v416.z.object({
3223
3228
  type: import_v416.z.literal("file_citation"),
3224
3229
  file_id: import_v416.z.string(),
3225
- filename: import_v416.z.string().nullish(),
3226
- index: import_v416.z.number().nullish(),
3227
- start_index: import_v416.z.number().nullish(),
3228
- end_index: import_v416.z.number().nullish(),
3229
- quote: import_v416.z.string().nullish()
3230
+ filename: import_v416.z.string(),
3231
+ index: import_v416.z.number()
3230
3232
  }),
3231
3233
  import_v416.z.object({
3232
3234
  type: import_v416.z.literal("container_file_citation"),
3233
3235
  container_id: import_v416.z.string(),
3234
3236
  file_id: import_v416.z.string(),
3235
- filename: import_v416.z.string().nullish(),
3236
- start_index: import_v416.z.number().nullish(),
3237
- end_index: import_v416.z.number().nullish(),
3238
- index: import_v416.z.number().nullish()
3237
+ filename: import_v416.z.string(),
3238
+ start_index: import_v416.z.number(),
3239
+ end_index: import_v416.z.number()
3239
3240
  }),
3240
3241
  import_v416.z.object({
3241
3242
  type: import_v416.z.literal("file_path"),
3242
3243
  file_id: import_v416.z.string(),
3243
- index: import_v416.z.number().nullish()
3244
+ index: import_v416.z.number()
3244
3245
  })
3245
3246
  ])
3246
3247
  }),
@@ -3337,25 +3338,21 @@ var openaiResponsesResponseSchema = (0, import_provider_utils23.lazySchema)(
3337
3338
  import_v416.z.object({
3338
3339
  type: import_v416.z.literal("file_citation"),
3339
3340
  file_id: import_v416.z.string(),
3340
- filename: import_v416.z.string().nullish(),
3341
- index: import_v416.z.number().nullish(),
3342
- start_index: import_v416.z.number().nullish(),
3343
- end_index: import_v416.z.number().nullish(),
3344
- quote: import_v416.z.string().nullish()
3341
+ filename: import_v416.z.string(),
3342
+ index: import_v416.z.number()
3345
3343
  }),
3346
3344
  import_v416.z.object({
3347
3345
  type: import_v416.z.literal("container_file_citation"),
3348
3346
  container_id: import_v416.z.string(),
3349
3347
  file_id: import_v416.z.string(),
3350
- filename: import_v416.z.string().nullish(),
3351
- start_index: import_v416.z.number().nullish(),
3352
- end_index: import_v416.z.number().nullish(),
3353
- index: import_v416.z.number().nullish()
3348
+ filename: import_v416.z.string(),
3349
+ start_index: import_v416.z.number(),
3350
+ end_index: import_v416.z.number()
3354
3351
  }),
3355
3352
  import_v416.z.object({
3356
3353
  type: import_v416.z.literal("file_path"),
3357
3354
  file_id: import_v416.z.string(),
3358
- index: import_v416.z.number().nullish()
3355
+ index: import_v416.z.number()
3359
3356
  })
3360
3357
  ])
3361
3358
  )
@@ -4513,7 +4510,7 @@ var OpenAIResponsesLanguageModel = class {
4513
4510
  };
4514
4511
  }
4515
4512
  async doGenerate(options) {
4516
- 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;
4513
+ 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;
4517
4514
  const {
4518
4515
  args: body,
4519
4516
  warnings,
@@ -4660,29 +4657,29 @@ var OpenAIResponsesLanguageModel = class {
4660
4657
  sourceType: "document",
4661
4658
  id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils32.generateId)(),
4662
4659
  mediaType: "text/plain",
4663
- title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
4664
- filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
4665
- ...annotation.file_id ? {
4666
- providerMetadata: {
4667
- [providerOptionsName]: {
4668
- fileId: annotation.file_id
4669
- }
4660
+ title: annotation.filename,
4661
+ filename: annotation.filename,
4662
+ providerMetadata: {
4663
+ [providerOptionsName]: {
4664
+ type: annotation.type,
4665
+ fileId: annotation.file_id,
4666
+ index: annotation.index
4670
4667
  }
4671
- } : {}
4668
+ }
4672
4669
  });
4673
4670
  } else if (annotation.type === "container_file_citation") {
4674
4671
  content.push({
4675
4672
  type: "source",
4676
4673
  sourceType: "document",
4677
- id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils32.generateId)(),
4674
+ id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils32.generateId)(),
4678
4675
  mediaType: "text/plain",
4679
- title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
4680
- filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
4676
+ title: annotation.filename,
4677
+ filename: annotation.filename,
4681
4678
  providerMetadata: {
4682
4679
  [providerOptionsName]: {
4680
+ type: annotation.type,
4683
4681
  fileId: annotation.file_id,
4684
- containerId: annotation.container_id,
4685
- ...annotation.index != null ? { index: annotation.index } : {}
4682
+ containerId: annotation.container_id
4686
4683
  }
4687
4684
  }
4688
4685
  });
@@ -4690,14 +4687,15 @@ var OpenAIResponsesLanguageModel = class {
4690
4687
  content.push({
4691
4688
  type: "source",
4692
4689
  sourceType: "document",
4693
- id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils32.generateId)(),
4690
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils32.generateId)(),
4694
4691
  mediaType: "application/octet-stream",
4695
4692
  title: annotation.file_id,
4696
4693
  filename: annotation.file_id,
4697
4694
  providerMetadata: {
4698
4695
  [providerOptionsName]: {
4696
+ type: annotation.type,
4699
4697
  fileId: annotation.file_id,
4700
- ...annotation.index != null ? { index: annotation.index } : {}
4698
+ index: annotation.index
4701
4699
  }
4702
4700
  }
4703
4701
  });
@@ -4742,7 +4740,7 @@ var OpenAIResponsesLanguageModel = class {
4742
4740
  break;
4743
4741
  }
4744
4742
  case "mcp_call": {
4745
- const toolCallId = part.approval_request_id != null ? (_v = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _v : part.id : part.id;
4743
+ const toolCallId = part.approval_request_id != null ? (_p = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _p : part.id : part.id;
4746
4744
  const toolName = `mcp.${part.name}`;
4747
4745
  content.push({
4748
4746
  type: "tool-call",
@@ -4776,8 +4774,8 @@ var OpenAIResponsesLanguageModel = class {
4776
4774
  break;
4777
4775
  }
4778
4776
  case "mcp_approval_request": {
4779
- const approvalRequestId = (_w = part.approval_request_id) != null ? _w : part.id;
4780
- const dummyToolCallId = (_z = (_y = (_x = this.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : (0, import_provider_utils32.generateId)();
4777
+ const approvalRequestId = (_q = part.approval_request_id) != null ? _q : part.id;
4778
+ const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils32.generateId)();
4781
4779
  const toolName = `mcp.${part.name}`;
4782
4780
  content.push({
4783
4781
  type: "tool-call",
@@ -4827,13 +4825,13 @@ var OpenAIResponsesLanguageModel = class {
4827
4825
  toolName: toolNameMapping.toCustomToolName("file_search"),
4828
4826
  result: {
4829
4827
  queries: part.queries,
4830
- results: (_B = (_A = part.results) == null ? void 0 : _A.map((result) => ({
4828
+ results: (_v = (_u = part.results) == null ? void 0 : _u.map((result) => ({
4831
4829
  attributes: result.attributes,
4832
4830
  fileId: result.file_id,
4833
4831
  filename: result.filename,
4834
4832
  score: result.score,
4835
4833
  text: result.text
4836
- }))) != null ? _B : null
4834
+ }))) != null ? _v : null
4837
4835
  }
4838
4836
  });
4839
4837
  break;
@@ -4892,10 +4890,10 @@ var OpenAIResponsesLanguageModel = class {
4892
4890
  content,
4893
4891
  finishReason: {
4894
4892
  unified: mapOpenAIResponseFinishReason({
4895
- finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
4893
+ finishReason: (_w = response.incomplete_details) == null ? void 0 : _w.reason,
4896
4894
  hasFunctionCall
4897
4895
  }),
4898
- raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
4896
+ raw: (_y = (_x = response.incomplete_details) == null ? void 0 : _x.reason) != null ? _y : void 0
4899
4897
  },
4900
4898
  usage: convertOpenAIResponsesUsage(usage),
4901
4899
  request: { body },
@@ -4958,7 +4956,7 @@ var OpenAIResponsesLanguageModel = class {
4958
4956
  controller.enqueue({ type: "stream-start", warnings });
4959
4957
  },
4960
4958
  transform(chunk, controller) {
4961
- 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, _F, _G, _H, _I, _J;
4959
+ 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;
4962
4960
  if (options.includeRawChunks) {
4963
4961
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
4964
4962
  }
@@ -5555,29 +5553,29 @@ var OpenAIResponsesLanguageModel = class {
5555
5553
  sourceType: "document",
5556
5554
  id: (_x = (_w = (_v = self.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : (0, import_provider_utils32.generateId)(),
5557
5555
  mediaType: "text/plain",
5558
- title: (_z = (_y = value.annotation.quote) != null ? _y : value.annotation.filename) != null ? _z : "Document",
5559
- filename: (_A = value.annotation.filename) != null ? _A : value.annotation.file_id,
5560
- ...value.annotation.file_id ? {
5561
- providerMetadata: {
5562
- [providerOptionsName]: {
5563
- fileId: value.annotation.file_id
5564
- }
5556
+ title: value.annotation.filename,
5557
+ filename: value.annotation.filename,
5558
+ providerMetadata: {
5559
+ [providerOptionsName]: {
5560
+ type: value.annotation.type,
5561
+ fileId: value.annotation.file_id,
5562
+ index: value.annotation.index
5565
5563
  }
5566
- } : {}
5564
+ }
5567
5565
  });
5568
5566
  } else if (value.annotation.type === "container_file_citation") {
5569
5567
  controller.enqueue({
5570
5568
  type: "source",
5571
5569
  sourceType: "document",
5572
- id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : (0, import_provider_utils32.generateId)(),
5570
+ id: (_A = (_z = (_y = self.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : (0, import_provider_utils32.generateId)(),
5573
5571
  mediaType: "text/plain",
5574
- title: (_F = (_E = value.annotation.filename) != null ? _E : value.annotation.file_id) != null ? _F : "Document",
5575
- filename: (_G = value.annotation.filename) != null ? _G : value.annotation.file_id,
5572
+ title: value.annotation.filename,
5573
+ filename: value.annotation.filename,
5576
5574
  providerMetadata: {
5577
5575
  [providerOptionsName]: {
5576
+ type: value.annotation.type,
5578
5577
  fileId: value.annotation.file_id,
5579
- containerId: value.annotation.container_id,
5580
- ...value.annotation.index != null ? { index: value.annotation.index } : {}
5578
+ containerId: value.annotation.container_id
5581
5579
  }
5582
5580
  }
5583
5581
  });
@@ -5585,14 +5583,15 @@ var OpenAIResponsesLanguageModel = class {
5585
5583
  controller.enqueue({
5586
5584
  type: "source",
5587
5585
  sourceType: "document",
5588
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils32.generateId)(),
5586
+ id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : (0, import_provider_utils32.generateId)(),
5589
5587
  mediaType: "application/octet-stream",
5590
5588
  title: value.annotation.file_id,
5591
5589
  filename: value.annotation.file_id,
5592
5590
  providerMetadata: {
5593
5591
  [providerOptionsName]: {
5592
+ type: value.annotation.type,
5594
5593
  fileId: value.annotation.file_id,
5595
- ...value.annotation.index != null ? { index: value.annotation.index } : {}
5594
+ index: value.annotation.index
5596
5595
  }
5597
5596
  }
5598
5597
  });