@ai-sdk/google 2.0.46 → 2.0.48
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 +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +100 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -35
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +21 -1
- package/dist/internal/index.d.ts +21 -1
- package/dist/internal/index.js +79 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +85 -22
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "2.0.
|
|
10
|
+
var VERSION = true ? "2.0.48" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -497,7 +497,7 @@ var googleGenerativeAIProviderOptions = lazySchema4(
|
|
|
497
497
|
thinkingBudget: z4.number().optional(),
|
|
498
498
|
includeThoughts: z4.boolean().optional(),
|
|
499
499
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
500
|
-
thinkingLevel: z4.enum(["low", "medium", "high"]).optional()
|
|
500
|
+
thinkingLevel: z4.enum(["minimal", "low", "medium", "high"]).optional()
|
|
501
501
|
}).optional(),
|
|
502
502
|
/**
|
|
503
503
|
* Optional.
|
|
@@ -587,6 +587,18 @@ var googleGenerativeAIProviderOptions = lazySchema4(
|
|
|
587
587
|
"21:9"
|
|
588
588
|
]).optional(),
|
|
589
589
|
imageSize: z4.enum(["1K", "2K", "4K"]).optional()
|
|
590
|
+
}).optional(),
|
|
591
|
+
/**
|
|
592
|
+
* Optional. Configuration for grounding retrieval.
|
|
593
|
+
* Used to provide location context for Google Maps and Google Search grounding.
|
|
594
|
+
*
|
|
595
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
596
|
+
*/
|
|
597
|
+
retrievalConfig: z4.object({
|
|
598
|
+
latLng: z4.object({
|
|
599
|
+
latitude: z4.number(),
|
|
600
|
+
longitude: z4.number()
|
|
601
|
+
}).optional()
|
|
590
602
|
}).optional()
|
|
591
603
|
})
|
|
592
604
|
)
|
|
@@ -703,6 +715,17 @@ function prepareTools({
|
|
|
703
715
|
});
|
|
704
716
|
}
|
|
705
717
|
break;
|
|
718
|
+
case "google.google_maps":
|
|
719
|
+
if (isGemini2orNewer) {
|
|
720
|
+
googleTools2.push({ googleMaps: {} });
|
|
721
|
+
} else {
|
|
722
|
+
toolWarnings.push({
|
|
723
|
+
type: "unsupported-tool",
|
|
724
|
+
tool,
|
|
725
|
+
details: "The Google Maps grounding tool is not supported with Gemini models other than Gemini 2 or newer."
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
706
729
|
default:
|
|
707
730
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
708
731
|
break;
|
|
@@ -898,7 +921,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
898
921
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
899
922
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
900
923
|
tools: googleTools2,
|
|
901
|
-
toolConfig:
|
|
924
|
+
toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
925
|
+
...googleToolConfig,
|
|
926
|
+
retrievalConfig: googleOptions.retrievalConfig
|
|
927
|
+
} : googleToolConfig,
|
|
902
928
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
903
929
|
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
904
930
|
},
|
|
@@ -1283,7 +1309,7 @@ function extractSources({
|
|
|
1283
1309
|
groundingMetadata,
|
|
1284
1310
|
generateId: generateId3
|
|
1285
1311
|
}) {
|
|
1286
|
-
var _a, _b, _c, _d;
|
|
1312
|
+
var _a, _b, _c, _d, _e;
|
|
1287
1313
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1288
1314
|
return void 0;
|
|
1289
1315
|
}
|
|
@@ -1349,6 +1375,16 @@ function extractSources({
|
|
|
1349
1375
|
filename: fileSearchStore.split("/").pop()
|
|
1350
1376
|
});
|
|
1351
1377
|
}
|
|
1378
|
+
} else if (chunk.maps != null) {
|
|
1379
|
+
if (chunk.maps.uri) {
|
|
1380
|
+
sources.push({
|
|
1381
|
+
type: "source",
|
|
1382
|
+
sourceType: "url",
|
|
1383
|
+
id: generateId3(),
|
|
1384
|
+
url: chunk.maps.uri,
|
|
1385
|
+
title: (_e = chunk.maps.title) != null ? _e : void 0
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1352
1388
|
}
|
|
1353
1389
|
}
|
|
1354
1390
|
return sources.length > 0 ? sources : void 0;
|
|
@@ -1365,6 +1401,12 @@ var getGroundingMetadataSchema = () => z5.object({
|
|
|
1365
1401
|
title: z5.string().nullish(),
|
|
1366
1402
|
text: z5.string().nullish(),
|
|
1367
1403
|
fileSearchStore: z5.string().nullish()
|
|
1404
|
+
}).nullish(),
|
|
1405
|
+
maps: z5.object({
|
|
1406
|
+
uri: z5.string().nullish(),
|
|
1407
|
+
title: z5.string().nullish(),
|
|
1408
|
+
text: z5.string().nullish(),
|
|
1409
|
+
placeId: z5.string().nullish()
|
|
1368
1410
|
}).nullish()
|
|
1369
1411
|
})
|
|
1370
1412
|
).nullish(),
|
|
@@ -1536,21 +1578,34 @@ var fileSearch = createProviderDefinedToolFactory({
|
|
|
1536
1578
|
inputSchema: fileSearchArgsSchema
|
|
1537
1579
|
});
|
|
1538
1580
|
|
|
1539
|
-
// src/tool/google-
|
|
1581
|
+
// src/tool/google-maps.ts
|
|
1540
1582
|
import {
|
|
1541
1583
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
1542
1584
|
lazySchema as lazySchema7,
|
|
1543
1585
|
zodSchema as zodSchema7
|
|
1544
1586
|
} from "@ai-sdk/provider-utils";
|
|
1545
1587
|
import { z as z8 } from "zod/v4";
|
|
1546
|
-
var
|
|
1588
|
+
var googleMaps = createProviderDefinedToolFactory2({
|
|
1589
|
+
id: "google.google_maps",
|
|
1590
|
+
name: "google_maps",
|
|
1591
|
+
inputSchema: lazySchema7(() => zodSchema7(z8.object({})))
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1594
|
+
// src/tool/google-search.ts
|
|
1595
|
+
import {
|
|
1596
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
1597
|
+
lazySchema as lazySchema8,
|
|
1598
|
+
zodSchema as zodSchema8
|
|
1599
|
+
} from "@ai-sdk/provider-utils";
|
|
1600
|
+
import { z as z9 } from "zod/v4";
|
|
1601
|
+
var googleSearch = createProviderDefinedToolFactory3({
|
|
1547
1602
|
id: "google.google_search",
|
|
1548
1603
|
name: "google_search",
|
|
1549
|
-
inputSchema:
|
|
1550
|
-
() =>
|
|
1551
|
-
|
|
1552
|
-
mode:
|
|
1553
|
-
dynamicThreshold:
|
|
1604
|
+
inputSchema: lazySchema8(
|
|
1605
|
+
() => zodSchema8(
|
|
1606
|
+
z9.object({
|
|
1607
|
+
mode: z9.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1608
|
+
dynamicThreshold: z9.number().default(1)
|
|
1554
1609
|
})
|
|
1555
1610
|
)
|
|
1556
1611
|
)
|
|
@@ -1558,26 +1613,26 @@ var googleSearch = createProviderDefinedToolFactory2({
|
|
|
1558
1613
|
|
|
1559
1614
|
// src/tool/url-context.ts
|
|
1560
1615
|
import {
|
|
1561
|
-
createProviderDefinedToolFactory as
|
|
1562
|
-
lazySchema as
|
|
1563
|
-
zodSchema as
|
|
1616
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
1617
|
+
lazySchema as lazySchema9,
|
|
1618
|
+
zodSchema as zodSchema9
|
|
1564
1619
|
} from "@ai-sdk/provider-utils";
|
|
1565
|
-
import { z as
|
|
1566
|
-
var urlContext =
|
|
1620
|
+
import { z as z10 } from "zod/v4";
|
|
1621
|
+
var urlContext = createProviderDefinedToolFactory4({
|
|
1567
1622
|
id: "google.url_context",
|
|
1568
1623
|
name: "url_context",
|
|
1569
|
-
inputSchema:
|
|
1624
|
+
inputSchema: lazySchema9(() => zodSchema9(z10.object({})))
|
|
1570
1625
|
});
|
|
1571
1626
|
|
|
1572
1627
|
// src/tool/vertex-rag-store.ts
|
|
1573
|
-
import { createProviderDefinedToolFactory as
|
|
1574
|
-
import { z as
|
|
1575
|
-
var vertexRagStore =
|
|
1628
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
1629
|
+
import { z as z11 } from "zod/v4";
|
|
1630
|
+
var vertexRagStore = createProviderDefinedToolFactory5({
|
|
1576
1631
|
id: "google.vertex_rag_store",
|
|
1577
1632
|
name: "vertex_rag_store",
|
|
1578
|
-
inputSchema:
|
|
1579
|
-
ragCorpus:
|
|
1580
|
-
topK:
|
|
1633
|
+
inputSchema: z11.object({
|
|
1634
|
+
ragCorpus: z11.string(),
|
|
1635
|
+
topK: z11.number().optional()
|
|
1581
1636
|
})
|
|
1582
1637
|
});
|
|
1583
1638
|
|
|
@@ -1588,6 +1643,14 @@ var googleTools = {
|
|
|
1588
1643
|
* Must have name "google_search".
|
|
1589
1644
|
*/
|
|
1590
1645
|
googleSearch,
|
|
1646
|
+
/**
|
|
1647
|
+
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
1648
|
+
* Must have name "google_maps".
|
|
1649
|
+
*
|
|
1650
|
+
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
1651
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1652
|
+
*/
|
|
1653
|
+
googleMaps,
|
|
1591
1654
|
/**
|
|
1592
1655
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
1593
1656
|
* Must have name "url_context".
|
|
@@ -1626,13 +1689,13 @@ var googleTools = {
|
|
|
1626
1689
|
import {
|
|
1627
1690
|
combineHeaders as combineHeaders3,
|
|
1628
1691
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1629
|
-
lazySchema as
|
|
1692
|
+
lazySchema as lazySchema10,
|
|
1630
1693
|
parseProviderOptions as parseProviderOptions3,
|
|
1631
1694
|
postJsonToApi as postJsonToApi3,
|
|
1632
1695
|
resolve as resolve3,
|
|
1633
|
-
zodSchema as
|
|
1696
|
+
zodSchema as zodSchema10
|
|
1634
1697
|
} from "@ai-sdk/provider-utils";
|
|
1635
|
-
import { z as
|
|
1698
|
+
import { z as z12 } from "zod/v4";
|
|
1636
1699
|
var GoogleGenerativeAIImageModel = class {
|
|
1637
1700
|
constructor(modelId, settings, config) {
|
|
1638
1701
|
this.modelId = modelId;
|
|
@@ -1724,18 +1787,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1724
1787
|
};
|
|
1725
1788
|
}
|
|
1726
1789
|
};
|
|
1727
|
-
var googleImageResponseSchema =
|
|
1728
|
-
() =>
|
|
1729
|
-
|
|
1730
|
-
predictions:
|
|
1790
|
+
var googleImageResponseSchema = lazySchema10(
|
|
1791
|
+
() => zodSchema10(
|
|
1792
|
+
z12.object({
|
|
1793
|
+
predictions: z12.array(z12.object({ bytesBase64Encoded: z12.string() })).default([])
|
|
1731
1794
|
})
|
|
1732
1795
|
)
|
|
1733
1796
|
);
|
|
1734
|
-
var googleImageProviderOptionsSchema =
|
|
1735
|
-
() =>
|
|
1736
|
-
|
|
1737
|
-
personGeneration:
|
|
1738
|
-
aspectRatio:
|
|
1797
|
+
var googleImageProviderOptionsSchema = lazySchema10(
|
|
1798
|
+
() => zodSchema10(
|
|
1799
|
+
z12.object({
|
|
1800
|
+
personGeneration: z12.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1801
|
+
aspectRatio: z12.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
1739
1802
|
})
|
|
1740
1803
|
)
|
|
1741
1804
|
);
|