@ai-sdk/google 3.0.113 → 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 +6 -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 +1 -1
- package/src/convert-json-schema-to-openapi-schema.ts +13 -1
- package/src/google-prepare-tools.ts +45 -21
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.114" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -296,6 +296,10 @@ function convertGoogleGenerativeAIUsage(usage) {
|
|
|
296
296
|
import {
|
|
297
297
|
UnsupportedFunctionalityError
|
|
298
298
|
} from "@ai-sdk/provider";
|
|
299
|
+
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
300
|
+
function isRecursiveJSONSchemaReferenceError(error) {
|
|
301
|
+
return UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
302
|
+
}
|
|
299
303
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
300
304
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
301
305
|
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
@@ -438,7 +442,7 @@ function convertJSONSchemaReference({
|
|
|
438
442
|
);
|
|
439
443
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
440
444
|
throw new UnsupportedFunctionalityError({
|
|
441
|
-
functionality:
|
|
445
|
+
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
442
446
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
443
447
|
});
|
|
444
448
|
}
|
|
@@ -1099,7 +1103,6 @@ function prepareTools({
|
|
|
1099
1103
|
modelId,
|
|
1100
1104
|
isVertexProvider = false
|
|
1101
1105
|
}) {
|
|
1102
|
-
var _a, _b;
|
|
1103
1106
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1104
1107
|
const toolWarnings = [];
|
|
1105
1108
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
@@ -1217,11 +1220,7 @@ function prepareTools({
|
|
|
1217
1220
|
const functionDeclarations2 = [];
|
|
1218
1221
|
for (const tool of tools) {
|
|
1219
1222
|
if (tool.type === "function") {
|
|
1220
|
-
functionDeclarations2.push(
|
|
1221
|
-
name: tool.name,
|
|
1222
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
1223
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1224
|
-
});
|
|
1223
|
+
functionDeclarations2.push(prepareFunctionDeclaration(tool));
|
|
1225
1224
|
}
|
|
1226
1225
|
}
|
|
1227
1226
|
const combinedToolConfig = {
|
|
@@ -1265,11 +1264,7 @@ function prepareTools({
|
|
|
1265
1264
|
for (const tool of tools) {
|
|
1266
1265
|
switch (tool.type) {
|
|
1267
1266
|
case "function":
|
|
1268
|
-
functionDeclarations.push(
|
|
1269
|
-
name: tool.name,
|
|
1270
|
-
description: (_b = tool.description) != null ? _b : "",
|
|
1271
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1272
|
-
});
|
|
1267
|
+
functionDeclarations.push(prepareFunctionDeclaration(tool));
|
|
1273
1268
|
if (tool.strict === true) {
|
|
1274
1269
|
hasStrictTools = true;
|
|
1275
1270
|
}
|
|
@@ -1336,6 +1331,27 @@ function prepareTools({
|
|
|
1336
1331
|
}
|
|
1337
1332
|
}
|
|
1338
1333
|
}
|
|
1334
|
+
function prepareFunctionDeclaration(tool) {
|
|
1335
|
+
var _a;
|
|
1336
|
+
const declaration = {
|
|
1337
|
+
name: tool.name,
|
|
1338
|
+
description: (_a = tool.description) != null ? _a : ""
|
|
1339
|
+
};
|
|
1340
|
+
try {
|
|
1341
|
+
return {
|
|
1342
|
+
...declaration,
|
|
1343
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1344
|
+
};
|
|
1345
|
+
} catch (error) {
|
|
1346
|
+
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1347
|
+
throw error;
|
|
1348
|
+
}
|
|
1349
|
+
return {
|
|
1350
|
+
...declaration,
|
|
1351
|
+
parametersJsonSchema: tool.inputSchema
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1339
1355
|
|
|
1340
1356
|
// src/google-json-accumulator.ts
|
|
1341
1357
|
var GoogleJSONAccumulator = class {
|