@ai-sdk/google 3.0.0-beta.76 → 3.0.0-beta.77
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 +6 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +98 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -34
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +20 -0
- package/dist/internal/index.d.ts +20 -0
- package/dist/internal/index.js +77 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +83 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -33,6 +33,12 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
|
|
|
33
33
|
aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | undefined;
|
|
34
34
|
imageSize?: "1K" | "2K" | "4K" | undefined;
|
|
35
35
|
} | undefined;
|
|
36
|
+
retrievalConfig?: {
|
|
37
|
+
latLng?: {
|
|
38
|
+
latitude: number;
|
|
39
|
+
longitude: number;
|
|
40
|
+
} | undefined;
|
|
41
|
+
} | undefined;
|
|
36
42
|
}>;
|
|
37
43
|
type GoogleGenerativeAIProviderOptions = InferSchema<typeof googleGenerativeAIProviderOptions>;
|
|
38
44
|
|
|
@@ -91,6 +97,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
91
97
|
text?: string | null | undefined;
|
|
92
98
|
fileSearchStore?: string | null | undefined;
|
|
93
99
|
} | null | undefined;
|
|
100
|
+
maps?: {
|
|
101
|
+
uri?: string | null | undefined;
|
|
102
|
+
title?: string | null | undefined;
|
|
103
|
+
text?: string | null | undefined;
|
|
104
|
+
placeId?: string | null | undefined;
|
|
105
|
+
} | null | undefined;
|
|
94
106
|
}[] | null | undefined;
|
|
95
107
|
groundingSupports?: {
|
|
96
108
|
segment: {
|
|
@@ -178,6 +190,14 @@ declare const googleTools: {
|
|
|
178
190
|
mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
|
|
179
191
|
dynamicThreshold?: number;
|
|
180
192
|
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
195
|
+
* Must have name "google_maps".
|
|
196
|
+
*
|
|
197
|
+
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
198
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
199
|
+
*/
|
|
200
|
+
googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
181
201
|
/**
|
|
182
202
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
183
203
|
* Must have name "url_context".
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
|
|
|
33
33
|
aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | undefined;
|
|
34
34
|
imageSize?: "1K" | "2K" | "4K" | undefined;
|
|
35
35
|
} | undefined;
|
|
36
|
+
retrievalConfig?: {
|
|
37
|
+
latLng?: {
|
|
38
|
+
latitude: number;
|
|
39
|
+
longitude: number;
|
|
40
|
+
} | undefined;
|
|
41
|
+
} | undefined;
|
|
36
42
|
}>;
|
|
37
43
|
type GoogleGenerativeAIProviderOptions = InferSchema<typeof googleGenerativeAIProviderOptions>;
|
|
38
44
|
|
|
@@ -91,6 +97,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
91
97
|
text?: string | null | undefined;
|
|
92
98
|
fileSearchStore?: string | null | undefined;
|
|
93
99
|
} | null | undefined;
|
|
100
|
+
maps?: {
|
|
101
|
+
uri?: string | null | undefined;
|
|
102
|
+
title?: string | null | undefined;
|
|
103
|
+
text?: string | null | undefined;
|
|
104
|
+
placeId?: string | null | undefined;
|
|
105
|
+
} | null | undefined;
|
|
94
106
|
}[] | null | undefined;
|
|
95
107
|
groundingSupports?: {
|
|
96
108
|
segment: {
|
|
@@ -178,6 +190,14 @@ declare const googleTools: {
|
|
|
178
190
|
mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
|
|
179
191
|
dynamicThreshold?: number;
|
|
180
192
|
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
195
|
+
* Must have name "google_maps".
|
|
196
|
+
*
|
|
197
|
+
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
198
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
199
|
+
*/
|
|
200
|
+
googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
181
201
|
/**
|
|
182
202
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
183
203
|
* Must have name "url_context".
|
package/dist/index.js
CHANGED
|
@@ -27,10 +27,10 @@ __export(src_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(src_exports);
|
|
28
28
|
|
|
29
29
|
// src/google-provider.ts
|
|
30
|
-
var
|
|
30
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.0-beta.
|
|
33
|
+
var VERSION = true ? "3.0.0-beta.77" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -615,6 +615,18 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
615
615
|
"21:9"
|
|
616
616
|
]).optional(),
|
|
617
617
|
imageSize: import_v44.z.enum(["1K", "2K", "4K"]).optional()
|
|
618
|
+
}).optional(),
|
|
619
|
+
/**
|
|
620
|
+
* Optional. Configuration for grounding retrieval.
|
|
621
|
+
* Used to provide location context for Google Maps and Google Search grounding.
|
|
622
|
+
*
|
|
623
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
624
|
+
*/
|
|
625
|
+
retrievalConfig: import_v44.z.object({
|
|
626
|
+
latLng: import_v44.z.object({
|
|
627
|
+
latitude: import_v44.z.number(),
|
|
628
|
+
longitude: import_v44.z.number()
|
|
629
|
+
}).optional()
|
|
618
630
|
}).optional()
|
|
619
631
|
})
|
|
620
632
|
)
|
|
@@ -723,6 +735,17 @@ function prepareTools({
|
|
|
723
735
|
});
|
|
724
736
|
}
|
|
725
737
|
break;
|
|
738
|
+
case "google.google_maps":
|
|
739
|
+
if (isGemini2orNewer) {
|
|
740
|
+
googleTools2.push({ googleMaps: {} });
|
|
741
|
+
} else {
|
|
742
|
+
toolWarnings.push({
|
|
743
|
+
type: "unsupported",
|
|
744
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
745
|
+
details: "The Google Maps grounding tool is not supported with Gemini models other than Gemini 2 or newer."
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
break;
|
|
726
749
|
default:
|
|
727
750
|
toolWarnings.push({
|
|
728
751
|
type: "unsupported",
|
|
@@ -932,7 +955,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
932
955
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
933
956
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
934
957
|
tools: googleTools2,
|
|
935
|
-
toolConfig:
|
|
958
|
+
toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
959
|
+
...googleToolConfig,
|
|
960
|
+
retrievalConfig: googleOptions.retrievalConfig
|
|
961
|
+
} : googleToolConfig,
|
|
936
962
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
937
963
|
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
938
964
|
},
|
|
@@ -1323,7 +1349,7 @@ function extractSources({
|
|
|
1323
1349
|
groundingMetadata,
|
|
1324
1350
|
generateId: generateId3
|
|
1325
1351
|
}) {
|
|
1326
|
-
var _a, _b, _c, _d;
|
|
1352
|
+
var _a, _b, _c, _d, _e;
|
|
1327
1353
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1328
1354
|
return void 0;
|
|
1329
1355
|
}
|
|
@@ -1389,6 +1415,16 @@ function extractSources({
|
|
|
1389
1415
|
filename: fileSearchStore.split("/").pop()
|
|
1390
1416
|
});
|
|
1391
1417
|
}
|
|
1418
|
+
} else if (chunk.maps != null) {
|
|
1419
|
+
if (chunk.maps.uri) {
|
|
1420
|
+
sources.push({
|
|
1421
|
+
type: "source",
|
|
1422
|
+
sourceType: "url",
|
|
1423
|
+
id: generateId3(),
|
|
1424
|
+
url: chunk.maps.uri,
|
|
1425
|
+
title: (_e = chunk.maps.title) != null ? _e : void 0
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1392
1428
|
}
|
|
1393
1429
|
}
|
|
1394
1430
|
return sources.length > 0 ? sources : void 0;
|
|
@@ -1405,6 +1441,12 @@ var getGroundingMetadataSchema = () => import_v45.z.object({
|
|
|
1405
1441
|
title: import_v45.z.string().nullish(),
|
|
1406
1442
|
text: import_v45.z.string().nullish(),
|
|
1407
1443
|
fileSearchStore: import_v45.z.string().nullish()
|
|
1444
|
+
}).nullish(),
|
|
1445
|
+
maps: import_v45.z.object({
|
|
1446
|
+
uri: import_v45.z.string().nullish(),
|
|
1447
|
+
title: import_v45.z.string().nullish(),
|
|
1448
|
+
text: import_v45.z.string().nullish(),
|
|
1449
|
+
placeId: import_v45.z.string().nullish()
|
|
1408
1450
|
}).nullish()
|
|
1409
1451
|
})
|
|
1410
1452
|
).nullish(),
|
|
@@ -1571,37 +1613,45 @@ var fileSearch = (0, import_provider_utils8.createProviderToolFactory)({
|
|
|
1571
1613
|
inputSchema: fileSearchArgsSchema
|
|
1572
1614
|
});
|
|
1573
1615
|
|
|
1574
|
-
// src/tool/google-
|
|
1616
|
+
// src/tool/google-maps.ts
|
|
1575
1617
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1576
1618
|
var import_v48 = require("zod/v4");
|
|
1577
|
-
var
|
|
1619
|
+
var googleMaps = (0, import_provider_utils9.createProviderToolFactory)({
|
|
1620
|
+
id: "google.google_maps",
|
|
1621
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v48.z.object({})))
|
|
1622
|
+
});
|
|
1623
|
+
|
|
1624
|
+
// src/tool/google-search.ts
|
|
1625
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1626
|
+
var import_v49 = require("zod/v4");
|
|
1627
|
+
var googleSearch = (0, import_provider_utils10.createProviderToolFactory)({
|
|
1578
1628
|
id: "google.google_search",
|
|
1579
|
-
inputSchema: (0,
|
|
1580
|
-
() => (0,
|
|
1581
|
-
|
|
1582
|
-
mode:
|
|
1583
|
-
dynamicThreshold:
|
|
1629
|
+
inputSchema: (0, import_provider_utils10.lazySchema)(
|
|
1630
|
+
() => (0, import_provider_utils10.zodSchema)(
|
|
1631
|
+
import_v49.z.object({
|
|
1632
|
+
mode: import_v49.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1633
|
+
dynamicThreshold: import_v49.z.number().default(1)
|
|
1584
1634
|
})
|
|
1585
1635
|
)
|
|
1586
1636
|
)
|
|
1587
1637
|
});
|
|
1588
1638
|
|
|
1589
1639
|
// src/tool/url-context.ts
|
|
1590
|
-
var
|
|
1591
|
-
var
|
|
1592
|
-
var urlContext = (0,
|
|
1640
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1641
|
+
var import_v410 = require("zod/v4");
|
|
1642
|
+
var urlContext = (0, import_provider_utils11.createProviderToolFactory)({
|
|
1593
1643
|
id: "google.url_context",
|
|
1594
|
-
inputSchema: (0,
|
|
1644
|
+
inputSchema: (0, import_provider_utils11.lazySchema)(() => (0, import_provider_utils11.zodSchema)(import_v410.z.object({})))
|
|
1595
1645
|
});
|
|
1596
1646
|
|
|
1597
1647
|
// src/tool/vertex-rag-store.ts
|
|
1598
|
-
var
|
|
1599
|
-
var
|
|
1600
|
-
var vertexRagStore = (0,
|
|
1648
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1649
|
+
var import_v411 = require("zod/v4");
|
|
1650
|
+
var vertexRagStore = (0, import_provider_utils12.createProviderToolFactory)({
|
|
1601
1651
|
id: "google.vertex_rag_store",
|
|
1602
|
-
inputSchema:
|
|
1603
|
-
ragCorpus:
|
|
1604
|
-
topK:
|
|
1652
|
+
inputSchema: import_v411.z.object({
|
|
1653
|
+
ragCorpus: import_v411.z.string(),
|
|
1654
|
+
topK: import_v411.z.number().optional()
|
|
1605
1655
|
})
|
|
1606
1656
|
});
|
|
1607
1657
|
|
|
@@ -1612,6 +1662,14 @@ var googleTools = {
|
|
|
1612
1662
|
* Must have name "google_search".
|
|
1613
1663
|
*/
|
|
1614
1664
|
googleSearch,
|
|
1665
|
+
/**
|
|
1666
|
+
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
1667
|
+
* Must have name "google_maps".
|
|
1668
|
+
*
|
|
1669
|
+
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
1670
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1671
|
+
*/
|
|
1672
|
+
googleMaps,
|
|
1615
1673
|
/**
|
|
1616
1674
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
1617
1675
|
* Must have name "url_context".
|
|
@@ -1647,8 +1705,8 @@ var googleTools = {
|
|
|
1647
1705
|
};
|
|
1648
1706
|
|
|
1649
1707
|
// src/google-generative-ai-image-model.ts
|
|
1650
|
-
var
|
|
1651
|
-
var
|
|
1708
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1709
|
+
var import_v412 = require("zod/v4");
|
|
1652
1710
|
var GoogleGenerativeAIImageModel = class {
|
|
1653
1711
|
constructor(modelId, settings, config) {
|
|
1654
1712
|
this.modelId = modelId;
|
|
@@ -1690,7 +1748,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1690
1748
|
details: "This model does not support the `seed` option through this provider."
|
|
1691
1749
|
});
|
|
1692
1750
|
}
|
|
1693
|
-
const googleOptions = await (0,
|
|
1751
|
+
const googleOptions = await (0, import_provider_utils13.parseProviderOptions)({
|
|
1694
1752
|
provider: "google",
|
|
1695
1753
|
providerOptions,
|
|
1696
1754
|
schema: googleImageProviderOptionsSchema
|
|
@@ -1709,12 +1767,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1709
1767
|
instances: [{ prompt }],
|
|
1710
1768
|
parameters
|
|
1711
1769
|
};
|
|
1712
|
-
const { responseHeaders, value: response } = await (0,
|
|
1770
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils13.postJsonToApi)({
|
|
1713
1771
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
1714
|
-
headers: (0,
|
|
1772
|
+
headers: (0, import_provider_utils13.combineHeaders)(await (0, import_provider_utils13.resolve)(this.config.headers), headers),
|
|
1715
1773
|
body,
|
|
1716
1774
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1717
|
-
successfulResponseHandler: (0,
|
|
1775
|
+
successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
|
|
1718
1776
|
googleImageResponseSchema
|
|
1719
1777
|
),
|
|
1720
1778
|
abortSignal,
|
|
@@ -1740,18 +1798,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1740
1798
|
};
|
|
1741
1799
|
}
|
|
1742
1800
|
};
|
|
1743
|
-
var googleImageResponseSchema = (0,
|
|
1744
|
-
() => (0,
|
|
1745
|
-
|
|
1746
|
-
predictions:
|
|
1801
|
+
var googleImageResponseSchema = (0, import_provider_utils13.lazySchema)(
|
|
1802
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
1803
|
+
import_v412.z.object({
|
|
1804
|
+
predictions: import_v412.z.array(import_v412.z.object({ bytesBase64Encoded: import_v412.z.string() })).default([])
|
|
1747
1805
|
})
|
|
1748
1806
|
)
|
|
1749
1807
|
);
|
|
1750
|
-
var googleImageProviderOptionsSchema = (0,
|
|
1751
|
-
() => (0,
|
|
1752
|
-
|
|
1753
|
-
personGeneration:
|
|
1754
|
-
aspectRatio:
|
|
1808
|
+
var googleImageProviderOptionsSchema = (0, import_provider_utils13.lazySchema)(
|
|
1809
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
1810
|
+
import_v412.z.object({
|
|
1811
|
+
personGeneration: import_v412.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1812
|
+
aspectRatio: import_v412.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
1755
1813
|
})
|
|
1756
1814
|
)
|
|
1757
1815
|
);
|
|
@@ -1759,11 +1817,11 @@ var googleImageProviderOptionsSchema = (0, import_provider_utils12.lazySchema)(
|
|
|
1759
1817
|
// src/google-provider.ts
|
|
1760
1818
|
function createGoogleGenerativeAI(options = {}) {
|
|
1761
1819
|
var _a, _b;
|
|
1762
|
-
const baseURL = (_a = (0,
|
|
1820
|
+
const baseURL = (_a = (0, import_provider_utils14.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
1763
1821
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
1764
|
-
const getHeaders = () => (0,
|
|
1822
|
+
const getHeaders = () => (0, import_provider_utils14.withUserAgentSuffix)(
|
|
1765
1823
|
{
|
|
1766
|
-
"x-goog-api-key": (0,
|
|
1824
|
+
"x-goog-api-key": (0, import_provider_utils14.loadApiKey)({
|
|
1767
1825
|
apiKey: options.apiKey,
|
|
1768
1826
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
1769
1827
|
description: "Google Generative AI"
|
|
@@ -1778,7 +1836,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
1778
1836
|
provider: providerName,
|
|
1779
1837
|
baseURL,
|
|
1780
1838
|
headers: getHeaders,
|
|
1781
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
1839
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils14.generateId,
|
|
1782
1840
|
supportedUrls: () => ({
|
|
1783
1841
|
"*": [
|
|
1784
1842
|
// Google Generative Language "files" endpoint
|