@ai-sdk/google 2.0.55 → 2.0.57
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 +12 -0
- package/dist/index.d.mts +18 -4
- package/dist/index.d.ts +18 -4
- package/dist/index.js +51 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -30
- 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 +50 -29
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +50 -29
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ declare class GoogleGenerativeAILanguageModel implements LanguageModelV2 {
|
|
|
30
30
|
}
|
|
31
31
|
declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
32
32
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
|
+
imageSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
34
|
retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
34
35
|
searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
35
36
|
renderedContent: z.ZodString;
|
|
@@ -39,6 +40,12 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
|
39
40
|
uri: z.ZodString;
|
|
40
41
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
42
|
}, z.core.$strip>>>;
|
|
43
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
44
|
+
sourceUri: z.ZodString;
|
|
45
|
+
imageUri: z.ZodString;
|
|
46
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
42
49
|
retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
43
50
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
51
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -113,6 +120,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
113
120
|
}[] | null | undefined;
|
|
114
121
|
groundingMetadata?: {
|
|
115
122
|
webSearchQueries?: string[] | null | undefined;
|
|
123
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
116
124
|
retrievalQueries?: string[] | null | undefined;
|
|
117
125
|
searchEntryPoint?: {
|
|
118
126
|
renderedContent: string;
|
|
@@ -122,6 +130,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
122
130
|
uri: string;
|
|
123
131
|
title?: string | null | undefined;
|
|
124
132
|
} | null | undefined;
|
|
133
|
+
image?: {
|
|
134
|
+
sourceUri: string;
|
|
135
|
+
imageUri: string;
|
|
136
|
+
title?: string | null | undefined;
|
|
137
|
+
domain?: string | null | undefined;
|
|
138
|
+
} | null | undefined;
|
|
125
139
|
retrievedContext?: {
|
|
126
140
|
uri?: string | null | undefined;
|
|
127
141
|
title?: string | null | undefined;
|
|
@@ -188,8 +202,15 @@ declare const googleTools: {
|
|
|
188
202
|
* Must have name "google_search".
|
|
189
203
|
*/
|
|
190
204
|
googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
[x: string]: unknown;
|
|
206
|
+
searchTypes?: {
|
|
207
|
+
webSearch?: Record<string, never> | undefined;
|
|
208
|
+
imageSearch?: Record<string, never> | undefined;
|
|
209
|
+
} | undefined;
|
|
210
|
+
timeRangeFilter?: {
|
|
211
|
+
startTime: string;
|
|
212
|
+
endTime: string;
|
|
213
|
+
} | undefined;
|
|
193
214
|
}>;
|
|
194
215
|
/**
|
|
195
216
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class GoogleGenerativeAILanguageModel implements LanguageModelV2 {
|
|
|
30
30
|
}
|
|
31
31
|
declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
32
32
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
|
+
imageSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
34
|
retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
34
35
|
searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
35
36
|
renderedContent: z.ZodString;
|
|
@@ -39,6 +40,12 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
|
39
40
|
uri: z.ZodString;
|
|
40
41
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
42
|
}, z.core.$strip>>>;
|
|
43
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
44
|
+
sourceUri: z.ZodString;
|
|
45
|
+
imageUri: z.ZodString;
|
|
46
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
42
49
|
retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
43
50
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
51
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -113,6 +120,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
113
120
|
}[] | null | undefined;
|
|
114
121
|
groundingMetadata?: {
|
|
115
122
|
webSearchQueries?: string[] | null | undefined;
|
|
123
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
116
124
|
retrievalQueries?: string[] | null | undefined;
|
|
117
125
|
searchEntryPoint?: {
|
|
118
126
|
renderedContent: string;
|
|
@@ -122,6 +130,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
122
130
|
uri: string;
|
|
123
131
|
title?: string | null | undefined;
|
|
124
132
|
} | null | undefined;
|
|
133
|
+
image?: {
|
|
134
|
+
sourceUri: string;
|
|
135
|
+
imageUri: string;
|
|
136
|
+
title?: string | null | undefined;
|
|
137
|
+
domain?: string | null | undefined;
|
|
138
|
+
} | null | undefined;
|
|
125
139
|
retrievedContext?: {
|
|
126
140
|
uri?: string | null | undefined;
|
|
127
141
|
title?: string | null | undefined;
|
|
@@ -188,8 +202,15 @@ declare const googleTools: {
|
|
|
188
202
|
* Must have name "google_search".
|
|
189
203
|
*/
|
|
190
204
|
googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
[x: string]: unknown;
|
|
206
|
+
searchTypes?: {
|
|
207
|
+
webSearch?: Record<string, never> | undefined;
|
|
208
|
+
imageSearch?: Record<string, never> | undefined;
|
|
209
|
+
} | undefined;
|
|
210
|
+
timeRangeFilter?: {
|
|
211
|
+
startTime: string;
|
|
212
|
+
endTime: string;
|
|
213
|
+
} | undefined;
|
|
193
214
|
}>;
|
|
194
215
|
/**
|
|
195
216
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/internal/index.js
CHANGED
|
@@ -440,9 +440,13 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
440
440
|
"5:4",
|
|
441
441
|
"9:16",
|
|
442
442
|
"16:9",
|
|
443
|
-
"21:9"
|
|
443
|
+
"21:9",
|
|
444
|
+
"1:8",
|
|
445
|
+
"8:1",
|
|
446
|
+
"1:4",
|
|
447
|
+
"4:1"
|
|
444
448
|
]).optional(),
|
|
445
|
-
imageSize: import_v42.z.enum(["1K", "2K", "4K"]).optional()
|
|
449
|
+
imageSize: import_v42.z.enum(["1K", "2K", "4K", "512"]).optional()
|
|
446
450
|
}).optional(),
|
|
447
451
|
/**
|
|
448
452
|
* Optional. Configuration for grounding retrieval.
|
|
@@ -475,9 +479,8 @@ function prepareTools({
|
|
|
475
479
|
"gemini-flash-lite-latest",
|
|
476
480
|
"gemini-pro-latest"
|
|
477
481
|
].some((id) => id === modelId);
|
|
478
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
|
|
479
|
-
const
|
|
480
|
-
const supportsFileSearch = modelId.includes("gemini-2.5");
|
|
482
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
483
|
+
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
481
484
|
if (tools == null) {
|
|
482
485
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
483
486
|
}
|
|
@@ -502,18 +505,13 @@ function prepareTools({
|
|
|
502
505
|
switch (tool.id) {
|
|
503
506
|
case "google.google_search":
|
|
504
507
|
if (isGemini2orNewer) {
|
|
505
|
-
googleTools2.push({ googleSearch: {} });
|
|
506
|
-
} else if (supportsDynamicRetrieval) {
|
|
507
|
-
googleTools2.push({
|
|
508
|
-
googleSearchRetrieval: {
|
|
509
|
-
dynamicRetrievalConfig: {
|
|
510
|
-
mode: tool.args.mode,
|
|
511
|
-
dynamicThreshold: tool.args.dynamicThreshold
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
});
|
|
508
|
+
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
515
509
|
} else {
|
|
516
|
-
|
|
510
|
+
toolWarnings.push({
|
|
511
|
+
type: "unsupported-tool",
|
|
512
|
+
tool,
|
|
513
|
+
details: "Google Search requires Gemini 2.0 or newer."
|
|
514
|
+
});
|
|
517
515
|
}
|
|
518
516
|
break;
|
|
519
517
|
case "google.enterprise_web_search":
|
|
@@ -1186,7 +1184,7 @@ function extractSources({
|
|
|
1186
1184
|
groundingMetadata,
|
|
1187
1185
|
generateId: generateId2
|
|
1188
1186
|
}) {
|
|
1189
|
-
var _a, _b, _c, _d, _e;
|
|
1187
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1190
1188
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1191
1189
|
return void 0;
|
|
1192
1190
|
}
|
|
@@ -1200,6 +1198,16 @@ function extractSources({
|
|
|
1200
1198
|
url: chunk.web.uri,
|
|
1201
1199
|
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
1202
1200
|
});
|
|
1201
|
+
} else if (chunk.image != null) {
|
|
1202
|
+
sources.push({
|
|
1203
|
+
type: "source",
|
|
1204
|
+
sourceType: "url",
|
|
1205
|
+
id: generateId2(),
|
|
1206
|
+
// Google requires attribution to the source URI, not the actual image URI.
|
|
1207
|
+
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
1208
|
+
url: chunk.image.sourceUri,
|
|
1209
|
+
title: (_b = chunk.image.title) != null ? _b : void 0
|
|
1210
|
+
});
|
|
1203
1211
|
} else if (chunk.retrievedContext != null) {
|
|
1204
1212
|
const uri = chunk.retrievedContext.uri;
|
|
1205
1213
|
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
@@ -1209,10 +1217,10 @@ function extractSources({
|
|
|
1209
1217
|
sourceType: "url",
|
|
1210
1218
|
id: generateId2(),
|
|
1211
1219
|
url: uri,
|
|
1212
|
-
title: (
|
|
1220
|
+
title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
|
|
1213
1221
|
});
|
|
1214
1222
|
} else if (uri) {
|
|
1215
|
-
const title = (
|
|
1223
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1216
1224
|
let mediaType = "application/octet-stream";
|
|
1217
1225
|
let filename = void 0;
|
|
1218
1226
|
if (uri.endsWith(".pdf")) {
|
|
@@ -1242,7 +1250,7 @@ function extractSources({
|
|
|
1242
1250
|
filename
|
|
1243
1251
|
});
|
|
1244
1252
|
} else if (fileSearchStore) {
|
|
1245
|
-
const title = (
|
|
1253
|
+
const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
|
|
1246
1254
|
sources.push({
|
|
1247
1255
|
type: "source",
|
|
1248
1256
|
sourceType: "document",
|
|
@@ -1259,7 +1267,7 @@ function extractSources({
|
|
|
1259
1267
|
sourceType: "url",
|
|
1260
1268
|
id: generateId2(),
|
|
1261
1269
|
url: chunk.maps.uri,
|
|
1262
|
-
title: (
|
|
1270
|
+
title: (_f = chunk.maps.title) != null ? _f : void 0
|
|
1263
1271
|
});
|
|
1264
1272
|
}
|
|
1265
1273
|
}
|
|
@@ -1268,11 +1276,18 @@ function extractSources({
|
|
|
1268
1276
|
}
|
|
1269
1277
|
var getGroundingMetadataSchema = () => import_v43.z.object({
|
|
1270
1278
|
webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
|
|
1279
|
+
imageSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
|
|
1271
1280
|
retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
|
|
1272
1281
|
searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
|
|
1273
1282
|
groundingChunks: import_v43.z.array(
|
|
1274
1283
|
import_v43.z.object({
|
|
1275
1284
|
web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string().nullish() }).nullish(),
|
|
1285
|
+
image: import_v43.z.object({
|
|
1286
|
+
sourceUri: import_v43.z.string(),
|
|
1287
|
+
imageUri: import_v43.z.string(),
|
|
1288
|
+
title: import_v43.z.string().nullish(),
|
|
1289
|
+
domain: import_v43.z.string().nullish()
|
|
1290
|
+
}).nullish(),
|
|
1276
1291
|
retrievedContext: import_v43.z.object({
|
|
1277
1292
|
uri: import_v43.z.string().nullish(),
|
|
1278
1293
|
title: import_v43.z.string().nullish(),
|
|
@@ -1472,17 +1487,23 @@ var googleMaps = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
|
1472
1487
|
// src/tool/google-search.ts
|
|
1473
1488
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1474
1489
|
var import_v48 = require("zod/v4");
|
|
1490
|
+
var googleSearchToolArgsBaseSchema = import_v48.z.object({
|
|
1491
|
+
searchTypes: import_v48.z.object({
|
|
1492
|
+
webSearch: import_v48.z.object({}).optional(),
|
|
1493
|
+
imageSearch: import_v48.z.object({}).optional()
|
|
1494
|
+
}).optional(),
|
|
1495
|
+
timeRangeFilter: import_v48.z.object({
|
|
1496
|
+
startTime: import_v48.z.string(),
|
|
1497
|
+
endTime: import_v48.z.string()
|
|
1498
|
+
}).optional()
|
|
1499
|
+
}).passthrough();
|
|
1500
|
+
var googleSearchToolArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1501
|
+
() => (0, import_provider_utils9.zodSchema)(googleSearchToolArgsBaseSchema)
|
|
1502
|
+
);
|
|
1475
1503
|
var googleSearch = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1476
1504
|
id: "google.google_search",
|
|
1477
1505
|
name: "google_search",
|
|
1478
|
-
inputSchema:
|
|
1479
|
-
() => (0, import_provider_utils9.zodSchema)(
|
|
1480
|
-
import_v48.z.object({
|
|
1481
|
-
mode: import_v48.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1482
|
-
dynamicThreshold: import_v48.z.number().default(1)
|
|
1483
|
-
})
|
|
1484
|
-
)
|
|
1485
|
-
)
|
|
1506
|
+
inputSchema: googleSearchToolArgsSchema
|
|
1486
1507
|
});
|
|
1487
1508
|
|
|
1488
1509
|
// src/tool/url-context.ts
|