@ai-sdk/google 2.0.56 → 2.0.58
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 +14 -0
- package/dist/index.d.mts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +45 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -28
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +23 -2
- package/dist/internal/index.d.ts +23 -2
- package/dist/internal/index.js +44 -27
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +44 -27
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -471,9 +471,8 @@ function prepareTools({
|
|
|
471
471
|
"gemini-flash-lite-latest",
|
|
472
472
|
"gemini-pro-latest"
|
|
473
473
|
].some((id) => id === modelId);
|
|
474
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
|
|
475
|
-
const
|
|
476
|
-
const supportsFileSearch = modelId.includes("gemini-2.5");
|
|
474
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
475
|
+
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
477
476
|
if (tools == null) {
|
|
478
477
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
479
478
|
}
|
|
@@ -498,18 +497,13 @@ function prepareTools({
|
|
|
498
497
|
switch (tool.id) {
|
|
499
498
|
case "google.google_search":
|
|
500
499
|
if (isGemini2orNewer) {
|
|
501
|
-
googleTools2.push({ googleSearch: {} });
|
|
502
|
-
} else if (supportsDynamicRetrieval) {
|
|
503
|
-
googleTools2.push({
|
|
504
|
-
googleSearchRetrieval: {
|
|
505
|
-
dynamicRetrievalConfig: {
|
|
506
|
-
mode: tool.args.mode,
|
|
507
|
-
dynamicThreshold: tool.args.dynamicThreshold
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
});
|
|
500
|
+
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
511
501
|
} else {
|
|
512
|
-
|
|
502
|
+
toolWarnings.push({
|
|
503
|
+
type: "unsupported-tool",
|
|
504
|
+
tool,
|
|
505
|
+
details: "Google Search requires Gemini 2.0 or newer."
|
|
506
|
+
});
|
|
513
507
|
}
|
|
514
508
|
break;
|
|
515
509
|
case "google.enterprise_web_search":
|
|
@@ -1182,7 +1176,7 @@ function extractSources({
|
|
|
1182
1176
|
groundingMetadata,
|
|
1183
1177
|
generateId: generateId2
|
|
1184
1178
|
}) {
|
|
1185
|
-
var _a, _b, _c, _d, _e;
|
|
1179
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1186
1180
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1187
1181
|
return void 0;
|
|
1188
1182
|
}
|
|
@@ -1196,6 +1190,16 @@ function extractSources({
|
|
|
1196
1190
|
url: chunk.web.uri,
|
|
1197
1191
|
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
1198
1192
|
});
|
|
1193
|
+
} else if (chunk.image != null) {
|
|
1194
|
+
sources.push({
|
|
1195
|
+
type: "source",
|
|
1196
|
+
sourceType: "url",
|
|
1197
|
+
id: generateId2(),
|
|
1198
|
+
// Google requires attribution to the source URI, not the actual image URI.
|
|
1199
|
+
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
1200
|
+
url: chunk.image.sourceUri,
|
|
1201
|
+
title: (_b = chunk.image.title) != null ? _b : void 0
|
|
1202
|
+
});
|
|
1199
1203
|
} else if (chunk.retrievedContext != null) {
|
|
1200
1204
|
const uri = chunk.retrievedContext.uri;
|
|
1201
1205
|
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
@@ -1205,10 +1209,10 @@ function extractSources({
|
|
|
1205
1209
|
sourceType: "url",
|
|
1206
1210
|
id: generateId2(),
|
|
1207
1211
|
url: uri,
|
|
1208
|
-
title: (
|
|
1212
|
+
title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
|
|
1209
1213
|
});
|
|
1210
1214
|
} else if (uri) {
|
|
1211
|
-
const title = (
|
|
1215
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1212
1216
|
let mediaType = "application/octet-stream";
|
|
1213
1217
|
let filename = void 0;
|
|
1214
1218
|
if (uri.endsWith(".pdf")) {
|
|
@@ -1238,7 +1242,7 @@ function extractSources({
|
|
|
1238
1242
|
filename
|
|
1239
1243
|
});
|
|
1240
1244
|
} else if (fileSearchStore) {
|
|
1241
|
-
const title = (
|
|
1245
|
+
const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
|
|
1242
1246
|
sources.push({
|
|
1243
1247
|
type: "source",
|
|
1244
1248
|
sourceType: "document",
|
|
@@ -1255,7 +1259,7 @@ function extractSources({
|
|
|
1255
1259
|
sourceType: "url",
|
|
1256
1260
|
id: generateId2(),
|
|
1257
1261
|
url: chunk.maps.uri,
|
|
1258
|
-
title: (
|
|
1262
|
+
title: (_f = chunk.maps.title) != null ? _f : void 0
|
|
1259
1263
|
});
|
|
1260
1264
|
}
|
|
1261
1265
|
}
|
|
@@ -1264,11 +1268,18 @@ function extractSources({
|
|
|
1264
1268
|
}
|
|
1265
1269
|
var getGroundingMetadataSchema = () => z3.object({
|
|
1266
1270
|
webSearchQueries: z3.array(z3.string()).nullish(),
|
|
1271
|
+
imageSearchQueries: z3.array(z3.string()).nullish(),
|
|
1267
1272
|
retrievalQueries: z3.array(z3.string()).nullish(),
|
|
1268
1273
|
searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
|
|
1269
1274
|
groundingChunks: z3.array(
|
|
1270
1275
|
z3.object({
|
|
1271
1276
|
web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(),
|
|
1277
|
+
image: z3.object({
|
|
1278
|
+
sourceUri: z3.string(),
|
|
1279
|
+
imageUri: z3.string(),
|
|
1280
|
+
title: z3.string().nullish(),
|
|
1281
|
+
domain: z3.string().nullish()
|
|
1282
|
+
}).nullish(),
|
|
1272
1283
|
retrievedContext: z3.object({
|
|
1273
1284
|
uri: z3.string().nullish(),
|
|
1274
1285
|
title: z3.string().nullish(),
|
|
@@ -1484,17 +1495,23 @@ import {
|
|
|
1484
1495
|
zodSchema as zodSchema7
|
|
1485
1496
|
} from "@ai-sdk/provider-utils";
|
|
1486
1497
|
import { z as z8 } from "zod/v4";
|
|
1498
|
+
var googleSearchToolArgsBaseSchema = z8.object({
|
|
1499
|
+
searchTypes: z8.object({
|
|
1500
|
+
webSearch: z8.object({}).optional(),
|
|
1501
|
+
imageSearch: z8.object({}).optional()
|
|
1502
|
+
}).optional(),
|
|
1503
|
+
timeRangeFilter: z8.object({
|
|
1504
|
+
startTime: z8.string(),
|
|
1505
|
+
endTime: z8.string()
|
|
1506
|
+
}).optional()
|
|
1507
|
+
}).passthrough();
|
|
1508
|
+
var googleSearchToolArgsSchema = lazySchema7(
|
|
1509
|
+
() => zodSchema7(googleSearchToolArgsBaseSchema)
|
|
1510
|
+
);
|
|
1487
1511
|
var googleSearch = createProviderDefinedToolFactory4({
|
|
1488
1512
|
id: "google.google_search",
|
|
1489
1513
|
name: "google_search",
|
|
1490
|
-
inputSchema:
|
|
1491
|
-
() => zodSchema7(
|
|
1492
|
-
z8.object({
|
|
1493
|
-
mode: z8.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1494
|
-
dynamicThreshold: z8.number().default(1)
|
|
1495
|
-
})
|
|
1496
|
-
)
|
|
1497
|
-
)
|
|
1514
|
+
inputSchema: googleSearchToolArgsSchema
|
|
1498
1515
|
});
|
|
1499
1516
|
|
|
1500
1517
|
// src/tool/url-context.ts
|