@ai-sdk/openai 3.0.68 → 3.0.69
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 +6 -0
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +39 -8
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +39 -8
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +78 -0
- package/package.json +3 -3
- package/src/responses/openai-responses-api.ts +13 -5
- package/src/responses/openai-responses-prepare-tools.ts +64 -11
package/dist/internal/index.mjs
CHANGED
|
@@ -4828,20 +4828,37 @@ async function prepareResponsesTools({
|
|
|
4828
4828
|
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
4829
4829
|
}
|
|
4830
4830
|
const openaiTools = [];
|
|
4831
|
+
const namespaceTools = /* @__PURE__ */ new Map();
|
|
4831
4832
|
const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
|
|
4832
4833
|
for (const tool of tools) {
|
|
4833
4834
|
switch (tool.type) {
|
|
4834
4835
|
case "function": {
|
|
4835
4836
|
const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
|
|
4836
|
-
const
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
name: tool.name,
|
|
4840
|
-
description: tool.description,
|
|
4841
|
-
parameters: tool.inputSchema,
|
|
4842
|
-
...tool.strict != null ? { strict: tool.strict } : {},
|
|
4843
|
-
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
4837
|
+
const openaiFunctionTool = prepareFunctionTool({
|
|
4838
|
+
tool,
|
|
4839
|
+
options: openaiOptions
|
|
4844
4840
|
});
|
|
4841
|
+
const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
|
|
4842
|
+
if (namespace == null) {
|
|
4843
|
+
openaiTools.push(openaiFunctionTool);
|
|
4844
|
+
} else {
|
|
4845
|
+
let namespaceTool = namespaceTools.get(namespace.name);
|
|
4846
|
+
if (namespaceTool == null) {
|
|
4847
|
+
namespaceTool = {
|
|
4848
|
+
type: "namespace",
|
|
4849
|
+
name: namespace.name,
|
|
4850
|
+
description: namespace.description,
|
|
4851
|
+
tools: []
|
|
4852
|
+
};
|
|
4853
|
+
namespaceTools.set(namespace.name, namespaceTool);
|
|
4854
|
+
openaiTools.push(namespaceTool);
|
|
4855
|
+
} else if (namespaceTool.description !== namespace.description) {
|
|
4856
|
+
throw new UnsupportedFunctionalityError5({
|
|
4857
|
+
functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
|
|
4858
|
+
});
|
|
4859
|
+
}
|
|
4860
|
+
namespaceTool.tools.push(openaiFunctionTool);
|
|
4861
|
+
}
|
|
4845
4862
|
break;
|
|
4846
4863
|
}
|
|
4847
4864
|
case "provider": {
|
|
@@ -5054,6 +5071,20 @@ async function prepareResponsesTools({
|
|
|
5054
5071
|
}
|
|
5055
5072
|
}
|
|
5056
5073
|
}
|
|
5074
|
+
function prepareFunctionTool({
|
|
5075
|
+
tool,
|
|
5076
|
+
options
|
|
5077
|
+
}) {
|
|
5078
|
+
const deferLoading = options == null ? void 0 : options.deferLoading;
|
|
5079
|
+
return {
|
|
5080
|
+
type: "function",
|
|
5081
|
+
name: tool.name,
|
|
5082
|
+
description: tool.description,
|
|
5083
|
+
parameters: tool.inputSchema,
|
|
5084
|
+
...tool.strict != null ? { strict: tool.strict } : {},
|
|
5085
|
+
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
5086
|
+
};
|
|
5087
|
+
}
|
|
5057
5088
|
function mapShellEnvironment(environment) {
|
|
5058
5089
|
if (environment.type === "containerReference") {
|
|
5059
5090
|
const env2 = environment;
|