@ai-sdk/google 2.0.46 → 2.0.47
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.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +99 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -34
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +20 -0
- package/dist/internal/index.d.ts +20 -0
- package/dist/internal/index.js +78 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +84 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.mjs
CHANGED
|
@@ -413,6 +413,18 @@ var googleGenerativeAIProviderOptions = lazySchema2(
|
|
|
413
413
|
"21:9"
|
|
414
414
|
]).optional(),
|
|
415
415
|
imageSize: z2.enum(["1K", "2K", "4K"]).optional()
|
|
416
|
+
}).optional(),
|
|
417
|
+
/**
|
|
418
|
+
* Optional. Configuration for grounding retrieval.
|
|
419
|
+
* Used to provide location context for Google Maps and Google Search grounding.
|
|
420
|
+
*
|
|
421
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
422
|
+
*/
|
|
423
|
+
retrievalConfig: z2.object({
|
|
424
|
+
latLng: z2.object({
|
|
425
|
+
latitude: z2.number(),
|
|
426
|
+
longitude: z2.number()
|
|
427
|
+
}).optional()
|
|
416
428
|
}).optional()
|
|
417
429
|
})
|
|
418
430
|
)
|
|
@@ -529,6 +541,17 @@ function prepareTools({
|
|
|
529
541
|
});
|
|
530
542
|
}
|
|
531
543
|
break;
|
|
544
|
+
case "google.google_maps":
|
|
545
|
+
if (isGemini2orNewer) {
|
|
546
|
+
googleTools2.push({ googleMaps: {} });
|
|
547
|
+
} else {
|
|
548
|
+
toolWarnings.push({
|
|
549
|
+
type: "unsupported-tool",
|
|
550
|
+
tool,
|
|
551
|
+
details: "The Google Maps grounding tool is not supported with Gemini models other than Gemini 2 or newer."
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
break;
|
|
532
555
|
default:
|
|
533
556
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
534
557
|
break;
|
|
@@ -724,7 +747,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
724
747
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
725
748
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
726
749
|
tools: googleTools2,
|
|
727
|
-
toolConfig:
|
|
750
|
+
toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
751
|
+
...googleToolConfig,
|
|
752
|
+
retrievalConfig: googleOptions.retrievalConfig
|
|
753
|
+
} : googleToolConfig,
|
|
728
754
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
729
755
|
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
730
756
|
},
|
|
@@ -1109,7 +1135,7 @@ function extractSources({
|
|
|
1109
1135
|
groundingMetadata,
|
|
1110
1136
|
generateId: generateId2
|
|
1111
1137
|
}) {
|
|
1112
|
-
var _a, _b, _c, _d;
|
|
1138
|
+
var _a, _b, _c, _d, _e;
|
|
1113
1139
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1114
1140
|
return void 0;
|
|
1115
1141
|
}
|
|
@@ -1175,6 +1201,16 @@ function extractSources({
|
|
|
1175
1201
|
filename: fileSearchStore.split("/").pop()
|
|
1176
1202
|
});
|
|
1177
1203
|
}
|
|
1204
|
+
} else if (chunk.maps != null) {
|
|
1205
|
+
if (chunk.maps.uri) {
|
|
1206
|
+
sources.push({
|
|
1207
|
+
type: "source",
|
|
1208
|
+
sourceType: "url",
|
|
1209
|
+
id: generateId2(),
|
|
1210
|
+
url: chunk.maps.uri,
|
|
1211
|
+
title: (_e = chunk.maps.title) != null ? _e : void 0
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1178
1214
|
}
|
|
1179
1215
|
}
|
|
1180
1216
|
return sources.length > 0 ? sources : void 0;
|
|
@@ -1191,6 +1227,12 @@ var getGroundingMetadataSchema = () => z3.object({
|
|
|
1191
1227
|
title: z3.string().nullish(),
|
|
1192
1228
|
text: z3.string().nullish(),
|
|
1193
1229
|
fileSearchStore: z3.string().nullish()
|
|
1230
|
+
}).nullish(),
|
|
1231
|
+
maps: z3.object({
|
|
1232
|
+
uri: z3.string().nullish(),
|
|
1233
|
+
title: z3.string().nullish(),
|
|
1234
|
+
text: z3.string().nullish(),
|
|
1235
|
+
placeId: z3.string().nullish()
|
|
1194
1236
|
}).nullish()
|
|
1195
1237
|
})
|
|
1196
1238
|
).nullish(),
|
|
@@ -1362,21 +1404,34 @@ var fileSearch = createProviderDefinedToolFactory({
|
|
|
1362
1404
|
inputSchema: fileSearchArgsSchema
|
|
1363
1405
|
});
|
|
1364
1406
|
|
|
1365
|
-
// src/tool/google-
|
|
1407
|
+
// src/tool/google-maps.ts
|
|
1366
1408
|
import {
|
|
1367
1409
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
1368
1410
|
lazySchema as lazySchema5,
|
|
1369
1411
|
zodSchema as zodSchema5
|
|
1370
1412
|
} from "@ai-sdk/provider-utils";
|
|
1371
1413
|
import { z as z6 } from "zod/v4";
|
|
1372
|
-
var
|
|
1414
|
+
var googleMaps = createProviderDefinedToolFactory2({
|
|
1415
|
+
id: "google.google_maps",
|
|
1416
|
+
name: "google_maps",
|
|
1417
|
+
inputSchema: lazySchema5(() => zodSchema5(z6.object({})))
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1420
|
+
// src/tool/google-search.ts
|
|
1421
|
+
import {
|
|
1422
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
1423
|
+
lazySchema as lazySchema6,
|
|
1424
|
+
zodSchema as zodSchema6
|
|
1425
|
+
} from "@ai-sdk/provider-utils";
|
|
1426
|
+
import { z as z7 } from "zod/v4";
|
|
1427
|
+
var googleSearch = createProviderDefinedToolFactory3({
|
|
1373
1428
|
id: "google.google_search",
|
|
1374
1429
|
name: "google_search",
|
|
1375
|
-
inputSchema:
|
|
1376
|
-
() =>
|
|
1377
|
-
|
|
1378
|
-
mode:
|
|
1379
|
-
dynamicThreshold:
|
|
1430
|
+
inputSchema: lazySchema6(
|
|
1431
|
+
() => zodSchema6(
|
|
1432
|
+
z7.object({
|
|
1433
|
+
mode: z7.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1434
|
+
dynamicThreshold: z7.number().default(1)
|
|
1380
1435
|
})
|
|
1381
1436
|
)
|
|
1382
1437
|
)
|
|
@@ -1384,26 +1439,26 @@ var googleSearch = createProviderDefinedToolFactory2({
|
|
|
1384
1439
|
|
|
1385
1440
|
// src/tool/url-context.ts
|
|
1386
1441
|
import {
|
|
1387
|
-
createProviderDefinedToolFactory as
|
|
1388
|
-
lazySchema as
|
|
1389
|
-
zodSchema as
|
|
1442
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
1443
|
+
lazySchema as lazySchema7,
|
|
1444
|
+
zodSchema as zodSchema7
|
|
1390
1445
|
} from "@ai-sdk/provider-utils";
|
|
1391
|
-
import { z as
|
|
1392
|
-
var urlContext =
|
|
1446
|
+
import { z as z8 } from "zod/v4";
|
|
1447
|
+
var urlContext = createProviderDefinedToolFactory4({
|
|
1393
1448
|
id: "google.url_context",
|
|
1394
1449
|
name: "url_context",
|
|
1395
|
-
inputSchema:
|
|
1450
|
+
inputSchema: lazySchema7(() => zodSchema7(z8.object({})))
|
|
1396
1451
|
});
|
|
1397
1452
|
|
|
1398
1453
|
// src/tool/vertex-rag-store.ts
|
|
1399
|
-
import { createProviderDefinedToolFactory as
|
|
1400
|
-
import { z as
|
|
1401
|
-
var vertexRagStore =
|
|
1454
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
1455
|
+
import { z as z9 } from "zod/v4";
|
|
1456
|
+
var vertexRagStore = createProviderDefinedToolFactory5({
|
|
1402
1457
|
id: "google.vertex_rag_store",
|
|
1403
1458
|
name: "vertex_rag_store",
|
|
1404
|
-
inputSchema:
|
|
1405
|
-
ragCorpus:
|
|
1406
|
-
topK:
|
|
1459
|
+
inputSchema: z9.object({
|
|
1460
|
+
ragCorpus: z9.string(),
|
|
1461
|
+
topK: z9.number().optional()
|
|
1407
1462
|
})
|
|
1408
1463
|
});
|
|
1409
1464
|
|
|
@@ -1414,6 +1469,14 @@ var googleTools = {
|
|
|
1414
1469
|
* Must have name "google_search".
|
|
1415
1470
|
*/
|
|
1416
1471
|
googleSearch,
|
|
1472
|
+
/**
|
|
1473
|
+
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
1474
|
+
* Must have name "google_maps".
|
|
1475
|
+
*
|
|
1476
|
+
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
1477
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1478
|
+
*/
|
|
1479
|
+
googleMaps,
|
|
1417
1480
|
/**
|
|
1418
1481
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
1419
1482
|
* Must have name "url_context".
|