@ai-sdk/openai 3.0.68 → 3.0.70

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,18 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.70
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [942f2f8]
8
+ - @ai-sdk/provider-utils@4.0.28
9
+
10
+ ## 3.0.69
11
+
12
+ ### Patch Changes
13
+
14
+ - 9a55f6d: feat(openai): add namespaces for tool definitions
15
+
3
16
  ## 3.0.68
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -4479,20 +4479,37 @@ async function prepareResponsesTools({
4479
4479
  return { tools: void 0, toolChoice: void 0, toolWarnings };
4480
4480
  }
4481
4481
  const openaiTools2 = [];
4482
+ const namespaceTools = /* @__PURE__ */ new Map();
4482
4483
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4483
4484
  for (const tool of tools) {
4484
4485
  switch (tool.type) {
4485
4486
  case "function": {
4486
4487
  const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4487
- const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4488
- openaiTools2.push({
4489
- type: "function",
4490
- name: tool.name,
4491
- description: tool.description,
4492
- parameters: tool.inputSchema,
4493
- ...tool.strict != null ? { strict: tool.strict } : {},
4494
- ...deferLoading != null ? { defer_loading: deferLoading } : {}
4488
+ const openaiFunctionTool = prepareFunctionTool({
4489
+ tool,
4490
+ options: openaiOptions
4495
4491
  });
4492
+ const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
4493
+ if (namespace == null) {
4494
+ openaiTools2.push(openaiFunctionTool);
4495
+ } else {
4496
+ let namespaceTool = namespaceTools.get(namespace.name);
4497
+ if (namespaceTool == null) {
4498
+ namespaceTool = {
4499
+ type: "namespace",
4500
+ name: namespace.name,
4501
+ description: namespace.description,
4502
+ tools: []
4503
+ };
4504
+ namespaceTools.set(namespace.name, namespaceTool);
4505
+ openaiTools2.push(namespaceTool);
4506
+ } else if (namespaceTool.description !== namespace.description) {
4507
+ throw new import_provider7.UnsupportedFunctionalityError({
4508
+ functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
4509
+ });
4510
+ }
4511
+ namespaceTool.tools.push(openaiFunctionTool);
4512
+ }
4496
4513
  break;
4497
4514
  }
4498
4515
  case "provider": {
@@ -4705,6 +4722,20 @@ async function prepareResponsesTools({
4705
4722
  }
4706
4723
  }
4707
4724
  }
4725
+ function prepareFunctionTool({
4726
+ tool,
4727
+ options
4728
+ }) {
4729
+ const deferLoading = options == null ? void 0 : options.deferLoading;
4730
+ return {
4731
+ type: "function",
4732
+ name: tool.name,
4733
+ description: tool.description,
4734
+ parameters: tool.inputSchema,
4735
+ ...tool.strict != null ? { strict: tool.strict } : {},
4736
+ ...deferLoading != null ? { defer_loading: deferLoading } : {}
4737
+ };
4738
+ }
4708
4739
  function mapShellEnvironment(environment) {
4709
4740
  if (environment.type === "containerReference") {
4710
4741
  const env2 = environment;
@@ -6814,7 +6845,7 @@ var OpenAITranscriptionModel = class {
6814
6845
  };
6815
6846
 
6816
6847
  // src/version.ts
6817
- var VERSION = true ? "3.0.68" : "0.0.0-test";
6848
+ var VERSION = true ? "3.0.70" : "0.0.0-test";
6818
6849
 
6819
6850
  // src/openai-provider.ts
6820
6851
  function createOpenAI(options = {}) {