@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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.114" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -290,6 +290,10 @@ function convertGoogleGenerativeAIUsage(usage) {
|
|
|
290
290
|
|
|
291
291
|
// src/convert-json-schema-to-openapi-schema.ts
|
|
292
292
|
var import_provider2 = require("@ai-sdk/provider");
|
|
293
|
+
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
294
|
+
function isRecursiveJSONSchemaReferenceError(error) {
|
|
295
|
+
return import_provider2.UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
296
|
+
}
|
|
293
297
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
294
298
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
295
299
|
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
@@ -432,7 +436,7 @@ function convertJSONSchemaReference({
|
|
|
432
436
|
);
|
|
433
437
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
434
438
|
throw new import_provider2.UnsupportedFunctionalityError({
|
|
435
|
-
functionality:
|
|
439
|
+
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
436
440
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
437
441
|
});
|
|
438
442
|
}
|
|
@@ -1086,7 +1090,6 @@ function prepareTools({
|
|
|
1086
1090
|
modelId,
|
|
1087
1091
|
isVertexProvider = false
|
|
1088
1092
|
}) {
|
|
1089
|
-
var _a, _b;
|
|
1090
1093
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1091
1094
|
const toolWarnings = [];
|
|
1092
1095
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
@@ -1204,11 +1207,7 @@ function prepareTools({
|
|
|
1204
1207
|
const functionDeclarations2 = [];
|
|
1205
1208
|
for (const tool of tools) {
|
|
1206
1209
|
if (tool.type === "function") {
|
|
1207
|
-
functionDeclarations2.push(
|
|
1208
|
-
name: tool.name,
|
|
1209
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
1210
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1211
|
-
});
|
|
1210
|
+
functionDeclarations2.push(prepareFunctionDeclaration(tool));
|
|
1212
1211
|
}
|
|
1213
1212
|
}
|
|
1214
1213
|
const combinedToolConfig = {
|
|
@@ -1252,11 +1251,7 @@ function prepareTools({
|
|
|
1252
1251
|
for (const tool of tools) {
|
|
1253
1252
|
switch (tool.type) {
|
|
1254
1253
|
case "function":
|
|
1255
|
-
functionDeclarations.push(
|
|
1256
|
-
name: tool.name,
|
|
1257
|
-
description: (_b = tool.description) != null ? _b : "",
|
|
1258
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1259
|
-
});
|
|
1254
|
+
functionDeclarations.push(prepareFunctionDeclaration(tool));
|
|
1260
1255
|
if (tool.strict === true) {
|
|
1261
1256
|
hasStrictTools = true;
|
|
1262
1257
|
}
|
|
@@ -1323,6 +1318,27 @@ function prepareTools({
|
|
|
1323
1318
|
}
|
|
1324
1319
|
}
|
|
1325
1320
|
}
|
|
1321
|
+
function prepareFunctionDeclaration(tool) {
|
|
1322
|
+
var _a;
|
|
1323
|
+
const declaration = {
|
|
1324
|
+
name: tool.name,
|
|
1325
|
+
description: (_a = tool.description) != null ? _a : ""
|
|
1326
|
+
};
|
|
1327
|
+
try {
|
|
1328
|
+
return {
|
|
1329
|
+
...declaration,
|
|
1330
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1331
|
+
};
|
|
1332
|
+
} catch (error) {
|
|
1333
|
+
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1334
|
+
throw error;
|
|
1335
|
+
}
|
|
1336
|
+
return {
|
|
1337
|
+
...declaration,
|
|
1338
|
+
parametersJsonSchema: tool.inputSchema
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1326
1342
|
|
|
1327
1343
|
// src/google-json-accumulator.ts
|
|
1328
1344
|
var GoogleJSONAccumulator = class {
|