@ai-sdk/openai 2.0.0-beta.6 → 2.0.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.0-beta.8
4
+
5
+ ### Patch Changes
6
+
7
+ - db64cbe: fix (provider/openai): multi-step reasoning with tool calls
8
+ - Updated dependencies [05d2819]
9
+ - @ai-sdk/provider-utils@3.0.0-beta.3
10
+
11
+ ## 2.0.0-beta.7
12
+
13
+ ### Patch Changes
14
+
15
+ - 209256d: Add missing file_search tool support to OpenAI Responses API
16
+
3
17
  ## 2.0.0-beta.6
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1879,7 +1879,7 @@ async function convertToOpenAIResponsesMessages({
1879
1879
  prompt,
1880
1880
  systemMessageMode
1881
1881
  }) {
1882
- var _a, _b;
1882
+ var _a, _b, _c, _d, _e;
1883
1883
  const messages = [];
1884
1884
  const warnings = [];
1885
1885
  for (const { role, content } of prompt) {
@@ -1914,7 +1914,7 @@ async function convertToOpenAIResponsesMessages({
1914
1914
  messages.push({
1915
1915
  role: "user",
1916
1916
  content: content.map((part, index) => {
1917
- var _a2, _b2, _c;
1917
+ var _a2, _b2, _c2;
1918
1918
  switch (part.type) {
1919
1919
  case "text": {
1920
1920
  return { type: "input_text", text: part.text };
@@ -1936,7 +1936,7 @@ async function convertToOpenAIResponsesMessages({
1936
1936
  }
1937
1937
  return {
1938
1938
  type: "input_file",
1939
- filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
1939
+ filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
1940
1940
  file_data: `data:application/pdf;base64,${part.data}`
1941
1941
  };
1942
1942
  } else {
@@ -1969,7 +1969,8 @@ async function convertToOpenAIResponsesMessages({
1969
1969
  type: "function_call",
1970
1970
  call_id: part.toolCallId,
1971
1971
  name: part.toolName,
1972
- arguments: JSON.stringify(part.input)
1972
+ arguments: JSON.stringify(part.input),
1973
+ id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
1973
1974
  });
1974
1975
  break;
1975
1976
  }
@@ -1986,7 +1987,7 @@ async function convertToOpenAIResponsesMessages({
1986
1987
  providerOptions: part.providerOptions,
1987
1988
  schema: openaiResponsesReasoningProviderOptionsSchema
1988
1989
  });
1989
- const reasoningId = (_a = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _a.id;
1990
+ const reasoningId = (_d = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _d.id;
1990
1991
  if (reasoningId != null) {
1991
1992
  const existingReasoningMessage = reasoningMessages[reasoningId];
1992
1993
  const summaryParts = [];
@@ -2002,7 +2003,7 @@ async function convertToOpenAIResponsesMessages({
2002
2003
  reasoningMessages[reasoningId] = {
2003
2004
  type: "reasoning",
2004
2005
  id: reasoningId,
2005
- encrypted_content: (_b = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _b.encryptedContent,
2006
+ encrypted_content: (_e = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _e.encryptedContent,
2006
2007
  summary: summaryParts
2007
2008
  };
2008
2009
  messages.push(reasoningMessages[reasoningId]);
@@ -2103,6 +2104,16 @@ function prepareResponsesTools({
2103
2104
  break;
2104
2105
  case "provider-defined":
2105
2106
  switch (tool.id) {
2107
+ case "openai.file_search": {
2108
+ const args = fileSearchArgsSchema.parse(tool.args);
2109
+ openaiTools2.push({
2110
+ type: "file_search",
2111
+ vector_store_ids: args.vectorStoreIds,
2112
+ max_results: args.maxResults,
2113
+ search_type: args.searchType
2114
+ });
2115
+ break;
2116
+ }
2106
2117
  case "openai.web_search_preview":
2107
2118
  openaiTools2.push({
2108
2119
  type: "web_search_preview",
@@ -2132,7 +2143,7 @@ function prepareResponsesTools({
2132
2143
  case "tool":
2133
2144
  return {
2134
2145
  tools: openaiTools2,
2135
- toolChoice: toolChoice.toolName === "web_search_preview" ? { type: "web_search_preview" } : { type: "function", name: toolChoice.toolName },
2146
+ toolChoice: toolChoice.toolName === "file_search" ? { type: "file_search" } : toolChoice.toolName === "web_search_preview" ? { type: "web_search_preview" } : { type: "function", name: toolChoice.toolName },
2136
2147
  toolWarnings
2137
2148
  };
2138
2149
  default: {
@@ -2357,7 +2368,8 @@ var OpenAIResponsesLanguageModel = class {
2357
2368
  type: import_v414.z.literal("function_call"),
2358
2369
  call_id: import_v414.z.string(),
2359
2370
  name: import_v414.z.string(),
2360
- arguments: import_v414.z.string()
2371
+ arguments: import_v414.z.string(),
2372
+ id: import_v414.z.string()
2361
2373
  }),
2362
2374
  import_v414.z.object({
2363
2375
  type: import_v414.z.literal("web_search_call"),
@@ -2446,7 +2458,12 @@ var OpenAIResponsesLanguageModel = class {
2446
2458
  type: "tool-call",
2447
2459
  toolCallId: part.call_id,
2448
2460
  toolName: part.name,
2449
- input: part.arguments
2461
+ input: part.arguments,
2462
+ providerMetadata: {
2463
+ openai: {
2464
+ itemId: part.id
2465
+ }
2466
+ }
2450
2467
  });
2451
2468
  break;
2452
2469
  }
@@ -2631,7 +2648,12 @@ var OpenAIResponsesLanguageModel = class {
2631
2648
  type: "tool-call",
2632
2649
  toolCallId: value.item.call_id,
2633
2650
  toolName: value.item.name,
2634
- input: value.item.arguments
2651
+ input: value.item.arguments,
2652
+ providerMetadata: {
2653
+ openai: {
2654
+ itemId: value.item.id
2655
+ }
2656
+ }
2635
2657
  });
2636
2658
  } else if (value.item.type === "web_search_call") {
2637
2659
  ongoingToolCalls[value.output_index] = void 0;