@ai-sdk/openai 2.0.27 → 2.0.28

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
@@ -1817,11 +1817,14 @@ var codeInterpreterArgsSchema = z11.object({
1817
1817
  })
1818
1818
  ]).optional()
1819
1819
  });
1820
- var codeInterpreter = createProviderDefinedToolFactory3({
1820
+ var codeInterpreterToolFactory = createProviderDefinedToolFactory3({
1821
1821
  id: "openai.code_interpreter",
1822
1822
  name: "code_interpreter",
1823
1823
  inputSchema: z11.object({})
1824
1824
  });
1825
+ var codeInterpreter = (args = {}) => {
1826
+ return codeInterpreterToolFactory(args);
1827
+ };
1825
1828
 
1826
1829
  // src/tool/web-search.ts
1827
1830
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
@@ -1839,7 +1842,7 @@ var webSearchArgsSchema = z12.object({
1839
1842
  timezone: z12.string().optional()
1840
1843
  }).optional()
1841
1844
  });
1842
- var factory = createProviderDefinedToolFactory4({
1845
+ var webSearchToolFactory = createProviderDefinedToolFactory4({
1843
1846
  id: "openai.web_search",
1844
1847
  name: "web_search",
1845
1848
  inputSchema: z12.object({
@@ -1861,7 +1864,7 @@ var factory = createProviderDefinedToolFactory4({
1861
1864
  })
1862
1865
  });
1863
1866
  var webSearch = (args = {}) => {
1864
- return factory(args);
1867
+ return webSearchToolFactory(args);
1865
1868
  };
1866
1869
 
1867
1870
  // src/openai-tools.ts
@@ -2310,7 +2313,7 @@ var OpenAIResponsesLanguageModel = class {
2310
2313
  toolChoice,
2311
2314
  responseFormat
2312
2315
  }) {
2313
- var _a, _b;
2316
+ var _a, _b, _c;
2314
2317
  const warnings = [];
2315
2318
  const modelConfig = getResponsesModelConfig(this.modelId);
2316
2319
  if (topK != null) {
@@ -2346,8 +2349,13 @@ var OpenAIResponsesLanguageModel = class {
2346
2349
  schema: openaiResponsesProviderOptionsSchema
2347
2350
  });
2348
2351
  const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2352
+ let include = openaiOptions == null ? void 0 : openaiOptions.include;
2349
2353
  const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
2350
- const openaiOptionsInclude = topLogprobs ? Array.isArray(openaiOptions == null ? void 0 : openaiOptions.include) ? [...openaiOptions == null ? void 0 : openaiOptions.include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : openaiOptions == null ? void 0 : openaiOptions.include;
2354
+ include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2355
+ const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2356
+ (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2357
+ )) == null ? void 0 : _b.name;
2358
+ include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2351
2359
  const baseArgs = {
2352
2360
  model: this.modelId,
2353
2361
  input: messages,
@@ -2360,7 +2368,7 @@ var OpenAIResponsesLanguageModel = class {
2360
2368
  format: responseFormat.schema != null ? {
2361
2369
  type: "json_schema",
2362
2370
  strict: strictJsonSchema,
2363
- name: (_b = responseFormat.name) != null ? _b : "response",
2371
+ name: (_c = responseFormat.name) != null ? _c : "response",
2364
2372
  description: responseFormat.description,
2365
2373
  schema: responseFormat.schema
2366
2374
  } : { type: "json_object" }
@@ -2378,7 +2386,7 @@ var OpenAIResponsesLanguageModel = class {
2378
2386
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2379
2387
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2380
2388
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2381
- include: openaiOptionsInclude,
2389
+ include,
2382
2390
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
2383
2391
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
2384
2392
  top_logprobs: topLogprobs,
@@ -2456,6 +2464,7 @@ var OpenAIResponsesLanguageModel = class {
2456
2464
  strictJsonSchema
2457
2465
  });
2458
2466
  return {
2467
+ webSearchToolName,
2459
2468
  args: {
2460
2469
  ...baseArgs,
2461
2470
  tools: openaiTools2,
@@ -2466,7 +2475,11 @@ var OpenAIResponsesLanguageModel = class {
2466
2475
  }
2467
2476
  async doGenerate(options) {
2468
2477
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2469
- const { args: body, warnings } = await this.getArgs(options);
2478
+ const {
2479
+ args: body,
2480
+ warnings,
2481
+ webSearchToolName
2482
+ } = await this.getArgs(options);
2470
2483
  const url = this.config.url({
2471
2484
  path: "/responses",
2472
2485
  modelId: this.modelId
@@ -2517,12 +2530,18 @@ var OpenAIResponsesLanguageModel = class {
2517
2530
  start_index: z14.number().nullish(),
2518
2531
  end_index: z14.number().nullish(),
2519
2532
  quote: z14.string().nullish()
2533
+ }),
2534
+ z14.object({
2535
+ type: z14.literal("container_file_citation")
2520
2536
  })
2521
2537
  ])
2522
2538
  )
2523
2539
  })
2524
2540
  )
2525
2541
  }),
2542
+ z14.object({
2543
+ type: z14.literal("code_interpreter_call")
2544
+ }),
2526
2545
  z14.object({
2527
2546
  type: z14.literal("function_call"),
2528
2547
  call_id: z14.string(),
@@ -2663,14 +2682,14 @@ var OpenAIResponsesLanguageModel = class {
2663
2682
  content.push({
2664
2683
  type: "tool-call",
2665
2684
  toolCallId: part.id,
2666
- toolName: "web_search_preview",
2685
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2667
2686
  input: JSON.stringify({ action: part.action }),
2668
2687
  providerExecuted: true
2669
2688
  });
2670
2689
  content.push({
2671
2690
  type: "tool-result",
2672
2691
  toolCallId: part.id,
2673
- toolName: "web_search_preview",
2692
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2674
2693
  result: { status: part.status },
2675
2694
  providerExecuted: true
2676
2695
  });
@@ -2755,7 +2774,11 @@ var OpenAIResponsesLanguageModel = class {
2755
2774
  };
2756
2775
  }
2757
2776
  async doStream(options) {
2758
- const { args: body, warnings } = await this.getArgs(options);
2777
+ const {
2778
+ args: body,
2779
+ warnings,
2780
+ webSearchToolName
2781
+ } = await this.getArgs(options);
2759
2782
  const { responseHeaders, value: response } = await postJsonToApi5({
2760
2783
  url: this.config.url({
2761
2784
  path: "/responses",
@@ -2816,13 +2839,13 @@ var OpenAIResponsesLanguageModel = class {
2816
2839
  });
2817
2840
  } else if (value.item.type === "web_search_call") {
2818
2841
  ongoingToolCalls[value.output_index] = {
2819
- toolName: "web_search_preview",
2842
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2820
2843
  toolCallId: value.item.id
2821
2844
  };
2822
2845
  controller.enqueue({
2823
2846
  type: "tool-input-start",
2824
2847
  id: value.item.id,
2825
- toolName: "web_search_preview"
2848
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search"
2826
2849
  });
2827
2850
  } else if (value.item.type === "computer_call") {
2828
2851
  ongoingToolCalls[value.output_index] = {