@ai-sdk/google 3.0.38 → 3.0.40
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 +50 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -31
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +27 -6
- package/dist/internal/index.d.ts +27 -6
- package/dist/internal/index.js +49 -30
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +49 -30
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +22 -10
- package/package.json +3 -3
- package/src/google-generative-ai-language-model.ts +28 -6
- package/src/google-prepare-tools.ts +10 -20
- package/src/tool/google-search.ts +31 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.40
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 89d8b45: fix(google): make urlMetadata optional in urlContextMetadata schema
|
|
8
|
+
|
|
9
|
+
## 3.0.39
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2565e70: feat(google): add support for image search, replace obsolete google_search_retrieval implementation
|
|
14
|
+
|
|
3
15
|
## 3.0.38
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -82,6 +82,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
82
82
|
}[] | null | undefined;
|
|
83
83
|
groundingMetadata?: {
|
|
84
84
|
webSearchQueries?: string[] | null | undefined;
|
|
85
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
85
86
|
retrievalQueries?: string[] | null | undefined;
|
|
86
87
|
searchEntryPoint?: {
|
|
87
88
|
renderedContent: string;
|
|
@@ -91,6 +92,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
91
92
|
uri: string;
|
|
92
93
|
title?: string | null | undefined;
|
|
93
94
|
} | null | undefined;
|
|
95
|
+
image?: {
|
|
96
|
+
sourceUri: string;
|
|
97
|
+
imageUri: string;
|
|
98
|
+
title?: string | null | undefined;
|
|
99
|
+
domain?: string | null | undefined;
|
|
100
|
+
} | null | undefined;
|
|
94
101
|
retrievedContext?: {
|
|
95
102
|
uri?: string | null | undefined;
|
|
96
103
|
title?: string | null | undefined;
|
|
@@ -121,10 +128,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
121
128
|
} | null | undefined;
|
|
122
129
|
} | null | undefined;
|
|
123
130
|
urlContextMetadata?: {
|
|
124
|
-
urlMetadata
|
|
131
|
+
urlMetadata?: {
|
|
125
132
|
retrievedUrl: string;
|
|
126
133
|
urlRetrievalStatus: string;
|
|
127
|
-
}[];
|
|
134
|
+
}[] | null | undefined;
|
|
128
135
|
} | null | undefined;
|
|
129
136
|
}[];
|
|
130
137
|
usageMetadata?: {
|
|
@@ -201,8 +208,15 @@ declare const googleTools: {
|
|
|
201
208
|
* Must have name "google_search".
|
|
202
209
|
*/
|
|
203
210
|
googleSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
[x: string]: unknown;
|
|
212
|
+
searchTypes?: {
|
|
213
|
+
webSearch?: Record<string, never> | undefined;
|
|
214
|
+
imageSearch?: Record<string, never> | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
timeRangeFilter?: {
|
|
217
|
+
startTime: string;
|
|
218
|
+
endTime: string;
|
|
219
|
+
} | undefined;
|
|
206
220
|
}>;
|
|
207
221
|
/**
|
|
208
222
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
82
82
|
}[] | null | undefined;
|
|
83
83
|
groundingMetadata?: {
|
|
84
84
|
webSearchQueries?: string[] | null | undefined;
|
|
85
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
85
86
|
retrievalQueries?: string[] | null | undefined;
|
|
86
87
|
searchEntryPoint?: {
|
|
87
88
|
renderedContent: string;
|
|
@@ -91,6 +92,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
91
92
|
uri: string;
|
|
92
93
|
title?: string | null | undefined;
|
|
93
94
|
} | null | undefined;
|
|
95
|
+
image?: {
|
|
96
|
+
sourceUri: string;
|
|
97
|
+
imageUri: string;
|
|
98
|
+
title?: string | null | undefined;
|
|
99
|
+
domain?: string | null | undefined;
|
|
100
|
+
} | null | undefined;
|
|
94
101
|
retrievedContext?: {
|
|
95
102
|
uri?: string | null | undefined;
|
|
96
103
|
title?: string | null | undefined;
|
|
@@ -121,10 +128,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
121
128
|
} | null | undefined;
|
|
122
129
|
} | null | undefined;
|
|
123
130
|
urlContextMetadata?: {
|
|
124
|
-
urlMetadata
|
|
131
|
+
urlMetadata?: {
|
|
125
132
|
retrievedUrl: string;
|
|
126
133
|
urlRetrievalStatus: string;
|
|
127
|
-
}[];
|
|
134
|
+
}[] | null | undefined;
|
|
128
135
|
} | null | undefined;
|
|
129
136
|
}[];
|
|
130
137
|
usageMetadata?: {
|
|
@@ -201,8 +208,15 @@ declare const googleTools: {
|
|
|
201
208
|
* Must have name "google_search".
|
|
202
209
|
*/
|
|
203
210
|
googleSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
[x: string]: unknown;
|
|
212
|
+
searchTypes?: {
|
|
213
|
+
webSearch?: Record<string, never> | undefined;
|
|
214
|
+
imageSearch?: Record<string, never> | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
timeRangeFilter?: {
|
|
217
|
+
startTime: string;
|
|
218
|
+
endTime: string;
|
|
219
|
+
} | undefined;
|
|
206
220
|
}>;
|
|
207
221
|
/**
|
|
208
222
|
* 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_utils16 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.40" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -676,8 +676,7 @@ function prepareTools({
|
|
|
676
676
|
"gemini-flash-lite-latest",
|
|
677
677
|
"gemini-pro-latest"
|
|
678
678
|
].some((id) => id === modelId);
|
|
679
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
|
|
680
|
-
const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
|
|
679
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
681
680
|
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
682
681
|
if (tools == null) {
|
|
683
682
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
@@ -697,18 +696,13 @@ function prepareTools({
|
|
|
697
696
|
switch (tool.id) {
|
|
698
697
|
case "google.google_search":
|
|
699
698
|
if (isGemini2orNewer) {
|
|
700
|
-
googleTools2.push({ googleSearch: {} });
|
|
701
|
-
} else if (supportsDynamicRetrieval) {
|
|
702
|
-
googleTools2.push({
|
|
703
|
-
googleSearchRetrieval: {
|
|
704
|
-
dynamicRetrievalConfig: {
|
|
705
|
-
mode: tool.args.mode,
|
|
706
|
-
dynamicThreshold: tool.args.dynamicThreshold
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
});
|
|
699
|
+
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
710
700
|
} else {
|
|
711
|
-
|
|
701
|
+
toolWarnings.push({
|
|
702
|
+
type: "unsupported",
|
|
703
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
704
|
+
details: "Google Search requires Gemini 2.0 or newer."
|
|
705
|
+
});
|
|
712
706
|
}
|
|
713
707
|
break;
|
|
714
708
|
case "google.enterprise_web_search":
|
|
@@ -1425,7 +1419,7 @@ function extractSources({
|
|
|
1425
1419
|
groundingMetadata,
|
|
1426
1420
|
generateId: generateId3
|
|
1427
1421
|
}) {
|
|
1428
|
-
var _a, _b, _c, _d, _e;
|
|
1422
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1429
1423
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1430
1424
|
return void 0;
|
|
1431
1425
|
}
|
|
@@ -1439,6 +1433,16 @@ function extractSources({
|
|
|
1439
1433
|
url: chunk.web.uri,
|
|
1440
1434
|
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
1441
1435
|
});
|
|
1436
|
+
} else if (chunk.image != null) {
|
|
1437
|
+
sources.push({
|
|
1438
|
+
type: "source",
|
|
1439
|
+
sourceType: "url",
|
|
1440
|
+
id: generateId3(),
|
|
1441
|
+
// Google requires attribution to the source URI, not the actual image URI.
|
|
1442
|
+
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
1443
|
+
url: chunk.image.sourceUri,
|
|
1444
|
+
title: (_b = chunk.image.title) != null ? _b : void 0
|
|
1445
|
+
});
|
|
1442
1446
|
} else if (chunk.retrievedContext != null) {
|
|
1443
1447
|
const uri = chunk.retrievedContext.uri;
|
|
1444
1448
|
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
@@ -1448,10 +1452,10 @@ function extractSources({
|
|
|
1448
1452
|
sourceType: "url",
|
|
1449
1453
|
id: generateId3(),
|
|
1450
1454
|
url: uri,
|
|
1451
|
-
title: (
|
|
1455
|
+
title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
|
|
1452
1456
|
});
|
|
1453
1457
|
} else if (uri) {
|
|
1454
|
-
const title = (
|
|
1458
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1455
1459
|
let mediaType = "application/octet-stream";
|
|
1456
1460
|
let filename = void 0;
|
|
1457
1461
|
if (uri.endsWith(".pdf")) {
|
|
@@ -1481,7 +1485,7 @@ function extractSources({
|
|
|
1481
1485
|
filename
|
|
1482
1486
|
});
|
|
1483
1487
|
} else if (fileSearchStore) {
|
|
1484
|
-
const title = (
|
|
1488
|
+
const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
|
|
1485
1489
|
sources.push({
|
|
1486
1490
|
type: "source",
|
|
1487
1491
|
sourceType: "document",
|
|
@@ -1498,7 +1502,7 @@ function extractSources({
|
|
|
1498
1502
|
sourceType: "url",
|
|
1499
1503
|
id: generateId3(),
|
|
1500
1504
|
url: chunk.maps.uri,
|
|
1501
|
-
title: (
|
|
1505
|
+
title: (_f = chunk.maps.title) != null ? _f : void 0
|
|
1502
1506
|
});
|
|
1503
1507
|
}
|
|
1504
1508
|
}
|
|
@@ -1507,11 +1511,18 @@ function extractSources({
|
|
|
1507
1511
|
}
|
|
1508
1512
|
var getGroundingMetadataSchema = () => import_v45.z.object({
|
|
1509
1513
|
webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
|
1514
|
+
imageSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
|
1510
1515
|
retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
|
1511
1516
|
searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
|
|
1512
1517
|
groundingChunks: import_v45.z.array(
|
|
1513
1518
|
import_v45.z.object({
|
|
1514
1519
|
web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
|
|
1520
|
+
image: import_v45.z.object({
|
|
1521
|
+
sourceUri: import_v45.z.string(),
|
|
1522
|
+
imageUri: import_v45.z.string(),
|
|
1523
|
+
title: import_v45.z.string().nullish(),
|
|
1524
|
+
domain: import_v45.z.string().nullish()
|
|
1525
|
+
}).nullish(),
|
|
1515
1526
|
retrievedContext: import_v45.z.object({
|
|
1516
1527
|
uri: import_v45.z.string().nullish(),
|
|
1517
1528
|
title: import_v45.z.string().nullish(),
|
|
@@ -1604,7 +1615,7 @@ var getUrlContextMetadataSchema = () => import_v45.z.object({
|
|
|
1604
1615
|
retrievedUrl: import_v45.z.string(),
|
|
1605
1616
|
urlRetrievalStatus: import_v45.z.string()
|
|
1606
1617
|
})
|
|
1607
|
-
)
|
|
1618
|
+
).nullish()
|
|
1608
1619
|
});
|
|
1609
1620
|
var responseSchema = (0, import_provider_utils6.lazySchema)(
|
|
1610
1621
|
() => (0, import_provider_utils6.zodSchema)(
|
|
@@ -1708,17 +1719,25 @@ var googleMaps = (0, import_provider_utils10.createProviderToolFactory)({
|
|
|
1708
1719
|
// src/tool/google-search.ts
|
|
1709
1720
|
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1710
1721
|
var import_v410 = require("zod/v4");
|
|
1711
|
-
var
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
()
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
+
var googleSearchToolArgsBaseSchema = import_v410.z.object({
|
|
1723
|
+
searchTypes: import_v410.z.object({
|
|
1724
|
+
webSearch: import_v410.z.object({}).optional(),
|
|
1725
|
+
imageSearch: import_v410.z.object({}).optional()
|
|
1726
|
+
}).optional(),
|
|
1727
|
+
timeRangeFilter: import_v410.z.object({
|
|
1728
|
+
startTime: import_v410.z.string(),
|
|
1729
|
+
endTime: import_v410.z.string()
|
|
1730
|
+
}).optional()
|
|
1731
|
+
}).passthrough();
|
|
1732
|
+
var googleSearchToolArgsSchema = (0, import_provider_utils11.lazySchema)(
|
|
1733
|
+
() => (0, import_provider_utils11.zodSchema)(googleSearchToolArgsBaseSchema)
|
|
1734
|
+
);
|
|
1735
|
+
var googleSearch = (0, import_provider_utils11.createProviderToolFactory)(
|
|
1736
|
+
{
|
|
1737
|
+
id: "google.google_search",
|
|
1738
|
+
inputSchema: googleSearchToolArgsSchema
|
|
1739
|
+
}
|
|
1740
|
+
);
|
|
1722
1741
|
|
|
1723
1742
|
// src/tool/url-context.ts
|
|
1724
1743
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|