@ai-sdk/google 3.0.112 → 3.0.114
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 +13 -0
- package/dist/index.js +29 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +28 -12
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +28 -12
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/convert-json-schema-to-openapi-schema.ts +13 -1
- package/src/google-prepare-tools.ts +45 -21
package/dist/internal/index.js
CHANGED
|
@@ -73,6 +73,10 @@ function convertGoogleGenerativeAIUsage(usage) {
|
|
|
73
73
|
|
|
74
74
|
// src/convert-json-schema-to-openapi-schema.ts
|
|
75
75
|
var import_provider = require("@ai-sdk/provider");
|
|
76
|
+
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
77
|
+
function isRecursiveJSONSchemaReferenceError(error) {
|
|
78
|
+
return import_provider.UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
79
|
+
}
|
|
76
80
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
77
81
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
78
82
|
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
@@ -215,7 +219,7 @@ function convertJSONSchemaReference({
|
|
|
215
219
|
);
|
|
216
220
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
217
221
|
throw new import_provider.UnsupportedFunctionalityError({
|
|
218
|
-
functionality:
|
|
222
|
+
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
219
223
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
220
224
|
});
|
|
221
225
|
}
|
|
@@ -889,7 +893,6 @@ function prepareTools({
|
|
|
889
893
|
modelId,
|
|
890
894
|
isVertexProvider = false
|
|
891
895
|
}) {
|
|
892
|
-
var _a, _b;
|
|
893
896
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
894
897
|
const toolWarnings = [];
|
|
895
898
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
@@ -1007,11 +1010,7 @@ function prepareTools({
|
|
|
1007
1010
|
const functionDeclarations2 = [];
|
|
1008
1011
|
for (const tool of tools) {
|
|
1009
1012
|
if (tool.type === "function") {
|
|
1010
|
-
functionDeclarations2.push(
|
|
1011
|
-
name: tool.name,
|
|
1012
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
1013
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1014
|
-
});
|
|
1013
|
+
functionDeclarations2.push(prepareFunctionDeclaration(tool));
|
|
1015
1014
|
}
|
|
1016
1015
|
}
|
|
1017
1016
|
const combinedToolConfig = {
|
|
@@ -1055,11 +1054,7 @@ function prepareTools({
|
|
|
1055
1054
|
for (const tool of tools) {
|
|
1056
1055
|
switch (tool.type) {
|
|
1057
1056
|
case "function":
|
|
1058
|
-
functionDeclarations.push(
|
|
1059
|
-
name: tool.name,
|
|
1060
|
-
description: (_b = tool.description) != null ? _b : "",
|
|
1061
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1062
|
-
});
|
|
1057
|
+
functionDeclarations.push(prepareFunctionDeclaration(tool));
|
|
1063
1058
|
if (tool.strict === true) {
|
|
1064
1059
|
hasStrictTools = true;
|
|
1065
1060
|
}
|
|
@@ -1126,6 +1121,27 @@ function prepareTools({
|
|
|
1126
1121
|
}
|
|
1127
1122
|
}
|
|
1128
1123
|
}
|
|
1124
|
+
function prepareFunctionDeclaration(tool) {
|
|
1125
|
+
var _a;
|
|
1126
|
+
const declaration = {
|
|
1127
|
+
name: tool.name,
|
|
1128
|
+
description: (_a = tool.description) != null ? _a : ""
|
|
1129
|
+
};
|
|
1130
|
+
try {
|
|
1131
|
+
return {
|
|
1132
|
+
...declaration,
|
|
1133
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1134
|
+
};
|
|
1135
|
+
} catch (error) {
|
|
1136
|
+
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1137
|
+
throw error;
|
|
1138
|
+
}
|
|
1139
|
+
return {
|
|
1140
|
+
...declaration,
|
|
1141
|
+
parametersJsonSchema: tool.inputSchema
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1129
1145
|
|
|
1130
1146
|
// src/google-json-accumulator.ts
|
|
1131
1147
|
var GoogleJSONAccumulator = class {
|