@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 2.0.58
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6a2f01b]
|
|
8
|
+
- Updated dependencies [17d64e3]
|
|
9
|
+
- @ai-sdk/provider-utils@3.0.22
|
|
10
|
+
|
|
11
|
+
## 2.0.57
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 4dda2a3: feat(google): add support for image search, replace obsolete google_search_retrieval implementation
|
|
16
|
+
|
|
3
17
|
## 2.0.56
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -81,6 +81,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
81
81
|
}[] | null | undefined;
|
|
82
82
|
groundingMetadata?: {
|
|
83
83
|
webSearchQueries?: string[] | null | undefined;
|
|
84
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
84
85
|
retrievalQueries?: string[] | null | undefined;
|
|
85
86
|
searchEntryPoint?: {
|
|
86
87
|
renderedContent: string;
|
|
@@ -90,6 +91,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
90
91
|
uri: string;
|
|
91
92
|
title?: string | null | undefined;
|
|
92
93
|
} | null | undefined;
|
|
94
|
+
image?: {
|
|
95
|
+
sourceUri: string;
|
|
96
|
+
imageUri: string;
|
|
97
|
+
title?: string | null | undefined;
|
|
98
|
+
domain?: string | null | undefined;
|
|
99
|
+
} | null | undefined;
|
|
93
100
|
retrievedContext?: {
|
|
94
101
|
uri?: string | null | undefined;
|
|
95
102
|
title?: string | null | undefined;
|
|
@@ -186,8 +193,15 @@ declare const googleTools: {
|
|
|
186
193
|
* Must have name "google_search".
|
|
187
194
|
*/
|
|
188
195
|
googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
189
|
-
|
|
190
|
-
|
|
196
|
+
[x: string]: unknown;
|
|
197
|
+
searchTypes?: {
|
|
198
|
+
webSearch?: Record<string, never> | undefined;
|
|
199
|
+
imageSearch?: Record<string, never> | undefined;
|
|
200
|
+
} | undefined;
|
|
201
|
+
timeRangeFilter?: {
|
|
202
|
+
startTime: string;
|
|
203
|
+
endTime: string;
|
|
204
|
+
} | undefined;
|
|
191
205
|
}>;
|
|
192
206
|
/**
|
|
193
207
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
81
81
|
}[] | null | undefined;
|
|
82
82
|
groundingMetadata?: {
|
|
83
83
|
webSearchQueries?: string[] | null | undefined;
|
|
84
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
84
85
|
retrievalQueries?: string[] | null | undefined;
|
|
85
86
|
searchEntryPoint?: {
|
|
86
87
|
renderedContent: string;
|
|
@@ -90,6 +91,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
90
91
|
uri: string;
|
|
91
92
|
title?: string | null | undefined;
|
|
92
93
|
} | null | undefined;
|
|
94
|
+
image?: {
|
|
95
|
+
sourceUri: string;
|
|
96
|
+
imageUri: string;
|
|
97
|
+
title?: string | null | undefined;
|
|
98
|
+
domain?: string | null | undefined;
|
|
99
|
+
} | null | undefined;
|
|
93
100
|
retrievedContext?: {
|
|
94
101
|
uri?: string | null | undefined;
|
|
95
102
|
title?: string | null | undefined;
|
|
@@ -186,8 +193,15 @@ declare const googleTools: {
|
|
|
186
193
|
* Must have name "google_search".
|
|
187
194
|
*/
|
|
188
195
|
googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
189
|
-
|
|
190
|
-
|
|
196
|
+
[x: string]: unknown;
|
|
197
|
+
searchTypes?: {
|
|
198
|
+
webSearch?: Record<string, never> | undefined;
|
|
199
|
+
imageSearch?: Record<string, never> | undefined;
|
|
200
|
+
} | undefined;
|
|
201
|
+
timeRangeFilter?: {
|
|
202
|
+
startTime: string;
|
|
203
|
+
endTime: string;
|
|
204
|
+
} | undefined;
|
|
191
205
|
}>;
|
|
192
206
|
/**
|
|
193
207
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
30
30
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.58" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -634,9 +634,8 @@ function prepareTools({
|
|
|
634
634
|
"gemini-flash-lite-latest",
|
|
635
635
|
"gemini-pro-latest"
|
|
636
636
|
].some((id) => id === modelId);
|
|
637
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
|
|
638
|
-
const
|
|
639
|
-
const supportsFileSearch = modelId.includes("gemini-2.5");
|
|
637
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
638
|
+
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
640
639
|
if (tools == null) {
|
|
641
640
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
642
641
|
}
|
|
@@ -661,18 +660,13 @@ function prepareTools({
|
|
|
661
660
|
switch (tool.id) {
|
|
662
661
|
case "google.google_search":
|
|
663
662
|
if (isGemini2orNewer) {
|
|
664
|
-
googleTools2.push({ googleSearch: {} });
|
|
665
|
-
} else if (supportsDynamicRetrieval) {
|
|
666
|
-
googleTools2.push({
|
|
667
|
-
googleSearchRetrieval: {
|
|
668
|
-
dynamicRetrievalConfig: {
|
|
669
|
-
mode: tool.args.mode,
|
|
670
|
-
dynamicThreshold: tool.args.dynamicThreshold
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
});
|
|
663
|
+
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
674
664
|
} else {
|
|
675
|
-
|
|
665
|
+
toolWarnings.push({
|
|
666
|
+
type: "unsupported-tool",
|
|
667
|
+
tool,
|
|
668
|
+
details: "Google Search requires Gemini 2.0 or newer."
|
|
669
|
+
});
|
|
676
670
|
}
|
|
677
671
|
break;
|
|
678
672
|
case "google.enterprise_web_search":
|
|
@@ -1345,7 +1339,7 @@ function extractSources({
|
|
|
1345
1339
|
groundingMetadata,
|
|
1346
1340
|
generateId: generateId3
|
|
1347
1341
|
}) {
|
|
1348
|
-
var _a, _b, _c, _d, _e;
|
|
1342
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1349
1343
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1350
1344
|
return void 0;
|
|
1351
1345
|
}
|
|
@@ -1359,6 +1353,16 @@ function extractSources({
|
|
|
1359
1353
|
url: chunk.web.uri,
|
|
1360
1354
|
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
1361
1355
|
});
|
|
1356
|
+
} else if (chunk.image != null) {
|
|
1357
|
+
sources.push({
|
|
1358
|
+
type: "source",
|
|
1359
|
+
sourceType: "url",
|
|
1360
|
+
id: generateId3(),
|
|
1361
|
+
// Google requires attribution to the source URI, not the actual image URI.
|
|
1362
|
+
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
1363
|
+
url: chunk.image.sourceUri,
|
|
1364
|
+
title: (_b = chunk.image.title) != null ? _b : void 0
|
|
1365
|
+
});
|
|
1362
1366
|
} else if (chunk.retrievedContext != null) {
|
|
1363
1367
|
const uri = chunk.retrievedContext.uri;
|
|
1364
1368
|
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
@@ -1368,10 +1372,10 @@ function extractSources({
|
|
|
1368
1372
|
sourceType: "url",
|
|
1369
1373
|
id: generateId3(),
|
|
1370
1374
|
url: uri,
|
|
1371
|
-
title: (
|
|
1375
|
+
title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
|
|
1372
1376
|
});
|
|
1373
1377
|
} else if (uri) {
|
|
1374
|
-
const title = (
|
|
1378
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1375
1379
|
let mediaType = "application/octet-stream";
|
|
1376
1380
|
let filename = void 0;
|
|
1377
1381
|
if (uri.endsWith(".pdf")) {
|
|
@@ -1401,7 +1405,7 @@ function extractSources({
|
|
|
1401
1405
|
filename
|
|
1402
1406
|
});
|
|
1403
1407
|
} else if (fileSearchStore) {
|
|
1404
|
-
const title = (
|
|
1408
|
+
const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
|
|
1405
1409
|
sources.push({
|
|
1406
1410
|
type: "source",
|
|
1407
1411
|
sourceType: "document",
|
|
@@ -1418,7 +1422,7 @@ function extractSources({
|
|
|
1418
1422
|
sourceType: "url",
|
|
1419
1423
|
id: generateId3(),
|
|
1420
1424
|
url: chunk.maps.uri,
|
|
1421
|
-
title: (
|
|
1425
|
+
title: (_f = chunk.maps.title) != null ? _f : void 0
|
|
1422
1426
|
});
|
|
1423
1427
|
}
|
|
1424
1428
|
}
|
|
@@ -1427,11 +1431,18 @@ function extractSources({
|
|
|
1427
1431
|
}
|
|
1428
1432
|
var getGroundingMetadataSchema = () => import_v45.z.object({
|
|
1429
1433
|
webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
|
1434
|
+
imageSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
|
1430
1435
|
retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
|
1431
1436
|
searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
|
|
1432
1437
|
groundingChunks: import_v45.z.array(
|
|
1433
1438
|
import_v45.z.object({
|
|
1434
1439
|
web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
|
|
1440
|
+
image: import_v45.z.object({
|
|
1441
|
+
sourceUri: import_v45.z.string(),
|
|
1442
|
+
imageUri: import_v45.z.string(),
|
|
1443
|
+
title: import_v45.z.string().nullish(),
|
|
1444
|
+
domain: import_v45.z.string().nullish()
|
|
1445
|
+
}).nullish(),
|
|
1435
1446
|
retrievedContext: import_v45.z.object({
|
|
1436
1447
|
uri: import_v45.z.string().nullish(),
|
|
1437
1448
|
title: import_v45.z.string().nullish(),
|
|
@@ -1631,17 +1642,23 @@ var googleMaps = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
|
1631
1642
|
// src/tool/google-search.ts
|
|
1632
1643
|
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1633
1644
|
var import_v410 = require("zod/v4");
|
|
1645
|
+
var googleSearchToolArgsBaseSchema = import_v410.z.object({
|
|
1646
|
+
searchTypes: import_v410.z.object({
|
|
1647
|
+
webSearch: import_v410.z.object({}).optional(),
|
|
1648
|
+
imageSearch: import_v410.z.object({}).optional()
|
|
1649
|
+
}).optional(),
|
|
1650
|
+
timeRangeFilter: import_v410.z.object({
|
|
1651
|
+
startTime: import_v410.z.string(),
|
|
1652
|
+
endTime: import_v410.z.string()
|
|
1653
|
+
}).optional()
|
|
1654
|
+
}).passthrough();
|
|
1655
|
+
var googleSearchToolArgsSchema = (0, import_provider_utils11.lazySchema)(
|
|
1656
|
+
() => (0, import_provider_utils11.zodSchema)(googleSearchToolArgsBaseSchema)
|
|
1657
|
+
);
|
|
1634
1658
|
var googleSearch = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1635
1659
|
id: "google.google_search",
|
|
1636
1660
|
name: "google_search",
|
|
1637
|
-
inputSchema:
|
|
1638
|
-
() => (0, import_provider_utils11.zodSchema)(
|
|
1639
|
-
import_v410.z.object({
|
|
1640
|
-
mode: import_v410.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1641
|
-
dynamicThreshold: import_v410.z.number().default(1)
|
|
1642
|
-
})
|
|
1643
|
-
)
|
|
1644
|
-
)
|
|
1661
|
+
inputSchema: googleSearchToolArgsSchema
|
|
1645
1662
|
});
|
|
1646
1663
|
|
|
1647
1664
|
// src/tool/url-context.ts
|