@ai-sdk/openai 4.0.0-canary.57 → 4.0.0-canary.59

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.0-canary.59
4
+
5
+ ### Patch Changes
6
+
7
+ - 685cec7: feat(openai): add opt-in pass-through for unsupported file media types
8
+
9
+ ## 4.0.0-canary.58
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [28dfa06]
14
+ - Updated dependencies [e93fa91]
15
+ - @ai-sdk/provider-utils@5.0.0-canary.41
16
+
3
17
  ## 4.0.0-canary.57
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1057,6 +1057,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
1057
1057
  safetyIdentifier?: string | null | undefined;
1058
1058
  serviceTier?: "default" | "auto" | "flex" | "priority" | null | undefined;
1059
1059
  store?: boolean | null | undefined;
1060
+ passThroughUnsupportedFiles?: boolean | undefined;
1060
1061
  strictJsonSchema?: boolean | null | undefined;
1061
1062
  textVerbosity?: "low" | "medium" | "high" | null | undefined;
1062
1063
  truncation?: "auto" | "disabled" | null | undefined;
package/dist/index.js CHANGED
@@ -2953,6 +2953,7 @@ async function convertToOpenAIResponsesInput({
2953
2953
  systemMessageMode,
2954
2954
  providerOptionsName,
2955
2955
  fileIdPrefixes,
2956
+ passThroughUnsupportedFiles = false,
2956
2957
  store,
2957
2958
  hasConversation = false,
2958
2959
  hasLocalShellTool = false,
@@ -3044,7 +3045,7 @@ async function convertToOpenAIResponsesInput({
3044
3045
  };
3045
3046
  }
3046
3047
  const fullMediaType = resolveFullMediaType2({ part });
3047
- if (fullMediaType !== "application/pdf") {
3048
+ if (fullMediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
3048
3049
  throw new UnsupportedFunctionalityError4({
3049
3050
  functionality: `file part media type ${fullMediaType}`
3050
3051
  });
@@ -3052,8 +3053,8 @@ async function convertToOpenAIResponsesInput({
3052
3053
  return {
3053
3054
  type: "input_file",
3054
3055
  ...typeof part.data.data === "string" && isFileId(part.data.data, fileIdPrefixes) ? { file_id: part.data.data } : {
3055
- filename: (_e2 = part.filename) != null ? _e2 : `part-${index}.pdf`,
3056
- file_data: `data:application/pdf;base64,${convertToBase642(part.data.data)}`
3056
+ filename: (_e2 = part.filename) != null ? _e2 : fullMediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
3057
+ file_data: `data:${fullMediaType};base64,${convertToBase642(part.data.data)}`
3057
3058
  }
3058
3059
  };
3059
3060
  }
@@ -4696,6 +4697,14 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema23(
4696
4697
  * Whether to store the generation. Defaults to `true`.
4697
4698
  */
4698
4699
  store: z25.boolean().nullish(),
4700
+ /**
4701
+ * Whether to pass through non-image file types as generic input files.
4702
+ *
4703
+ * By default, inline file inputs are restricted to images and PDFs.
4704
+ * Enable this when the target OpenAI Responses model supports additional
4705
+ * file media types, such as text/csv.
4706
+ */
4707
+ passThroughUnsupportedFiles: z25.boolean().optional(),
4699
4708
  /**
4700
4709
  * Whether to use strict JSON schema validation.
4701
4710
  * Defaults to `true`.
@@ -5120,7 +5129,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5120
5129
  toolChoice,
5121
5130
  responseFormat
5122
5131
  }) {
5123
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5132
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
5124
5133
  const warnings = [];
5125
5134
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
5126
5135
  if (topK != null) {
@@ -5193,7 +5202,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5193
5202
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5194
5203
  providerOptionsName,
5195
5204
  fileIdPrefixes: this.config.fileIdPrefixes,
5196
- store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
5205
+ passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
5206
+ store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
5197
5207
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
5198
5208
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
5199
5209
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -5201,7 +5211,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5201
5211
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
5202
5212
  });
5203
5213
  warnings.push(...inputWarnings);
5204
- const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
5214
+ const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
5205
5215
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
5206
5216
  function addInclude(key) {
5207
5217
  if (include == null) {
@@ -5217,9 +5227,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5217
5227
  if (topLogprobs) {
5218
5228
  addInclude("message.output_text.logprobs");
5219
5229
  }
5220
- const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
5230
+ const webSearchToolName = (_h = tools == null ? void 0 : tools.find(
5221
5231
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
5222
- )) == null ? void 0 : _g.name;
5232
+ )) == null ? void 0 : _h.name;
5223
5233
  if (webSearchToolName) {
5224
5234
  addInclude("web_search_call.action.sources");
5225
5235
  }
@@ -5242,7 +5252,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5242
5252
  format: responseFormat.schema != null ? {
5243
5253
  type: "json_schema",
5244
5254
  strict: strictJsonSchema,
5245
- name: (_h = responseFormat.name) != null ? _h : "response",
5255
+ name: (_i = responseFormat.name) != null ? _i : "response",
5246
5256
  description: responseFormat.description,
5247
5257
  schema: responseFormat.schema
5248
5258
  } : { type: "json_object" }
@@ -5338,9 +5348,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5338
5348
  });
5339
5349
  delete baseArgs.service_tier;
5340
5350
  }
5341
- const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
5351
+ const shellToolEnvType = (_l = (_k = (_j = tools == null ? void 0 : tools.find(
5342
5352
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
5343
- )) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
5353
+ )) == null ? void 0 : _j.args) == null ? void 0 : _k.environment) == null ? void 0 : _l.type;
5344
5354
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
5345
5355
  return {
5346
5356
  webSearchToolName,
@@ -7292,7 +7302,7 @@ var OpenAISkills = class {
7292
7302
  };
7293
7303
 
7294
7304
  // src/version.ts
7295
- var VERSION = true ? "4.0.0-canary.57" : "0.0.0-test";
7305
+ var VERSION = true ? "4.0.0-canary.59" : "0.0.0-test";
7296
7306
 
7297
7307
  // src/openai-provider.ts
7298
7308
  function createOpenAI(options = {}) {