@ai-sdk/google 3.0.0-beta.80 → 3.0.0-beta.82
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 +15 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +95 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -51
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +11 -0
- package/dist/internal/index.d.ts +11 -0
- package/dist/internal/index.js +60 -30
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +70 -36
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.82
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9061dc0: feat: image editing
|
|
8
|
+
- Updated dependencies [9061dc0]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.0-beta.54
|
|
10
|
+
- @ai-sdk/provider@3.0.0-beta.28
|
|
11
|
+
|
|
12
|
+
## 3.0.0-beta.81
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 0ad470b: feat(provider/google): add enterpriseWebSearch tool
|
|
17
|
+
|
|
3
18
|
## 3.0.0-beta.80
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -190,6 +190,17 @@ declare const googleTools: {
|
|
|
190
190
|
mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
|
|
191
191
|
dynamicThreshold?: number;
|
|
192
192
|
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
195
|
+
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
196
|
+
* Does not log customer data and supports VPC service controls.
|
|
197
|
+
* Must have name "enterprise_web_search".
|
|
198
|
+
*
|
|
199
|
+
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
200
|
+
*
|
|
201
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
202
|
+
*/
|
|
203
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
193
204
|
/**
|
|
194
205
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
195
206
|
* Must have name "google_maps".
|
package/dist/index.d.ts
CHANGED
|
@@ -190,6 +190,17 @@ declare const googleTools: {
|
|
|
190
190
|
mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
|
|
191
191
|
dynamicThreshold?: number;
|
|
192
192
|
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
195
|
+
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
196
|
+
* Does not log customer data and supports VPC service controls.
|
|
197
|
+
* Must have name "enterprise_web_search".
|
|
198
|
+
*
|
|
199
|
+
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
200
|
+
*
|
|
201
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
202
|
+
*/
|
|
203
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
193
204
|
/**
|
|
194
205
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
195
206
|
* Must have name "google_maps".
|
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_utils15 = 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.82" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -682,6 +682,17 @@ function prepareTools({
|
|
|
682
682
|
googleTools2.push({ googleSearchRetrieval: {} });
|
|
683
683
|
}
|
|
684
684
|
break;
|
|
685
|
+
case "google.enterprise_web_search":
|
|
686
|
+
if (isGemini2orNewer) {
|
|
687
|
+
googleTools2.push({ enterpriseWebSearch: {} });
|
|
688
|
+
} else {
|
|
689
|
+
toolWarnings.push({
|
|
690
|
+
type: "unsupported",
|
|
691
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
692
|
+
details: "Enterprise Web Search requires Gemini 2.0 or newer."
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
break;
|
|
685
696
|
case "google.url_context":
|
|
686
697
|
if (isGemini2orNewer) {
|
|
687
698
|
googleTools2.push({ urlContext: {} });
|
|
@@ -1586,72 +1597,80 @@ var codeExecution = (0, import_provider_utils7.createProviderToolFactoryWithOutp
|
|
|
1586
1597
|
})
|
|
1587
1598
|
});
|
|
1588
1599
|
|
|
1589
|
-
// src/tool/
|
|
1600
|
+
// src/tool/enterprise-web-search.ts
|
|
1590
1601
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1591
1602
|
var import_v47 = require("zod/v4");
|
|
1592
|
-
var
|
|
1603
|
+
var enterpriseWebSearch = (0, import_provider_utils8.createProviderToolFactory)({
|
|
1604
|
+
id: "google.enterprise_web_search",
|
|
1605
|
+
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
|
|
1606
|
+
});
|
|
1607
|
+
|
|
1608
|
+
// src/tool/file-search.ts
|
|
1609
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1610
|
+
var import_v48 = require("zod/v4");
|
|
1611
|
+
var fileSearchArgsBaseSchema = import_v48.z.object({
|
|
1593
1612
|
/** The names of the file_search_stores to retrieve from.
|
|
1594
1613
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
1595
1614
|
*/
|
|
1596
|
-
fileSearchStoreNames:
|
|
1615
|
+
fileSearchStoreNames: import_v48.z.array(import_v48.z.string()).describe(
|
|
1597
1616
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
1598
1617
|
),
|
|
1599
1618
|
/** The number of file search retrieval chunks to retrieve. */
|
|
1600
|
-
topK:
|
|
1619
|
+
topK: import_v48.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
1601
1620
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
1602
1621
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
1603
1622
|
*/
|
|
1604
|
-
metadataFilter:
|
|
1623
|
+
metadataFilter: import_v48.z.string().describe(
|
|
1605
1624
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
1606
1625
|
).optional()
|
|
1607
1626
|
}).passthrough();
|
|
1608
|
-
var fileSearchArgsSchema = (0,
|
|
1609
|
-
() => (0,
|
|
1627
|
+
var fileSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1628
|
+
() => (0, import_provider_utils9.zodSchema)(fileSearchArgsBaseSchema)
|
|
1610
1629
|
);
|
|
1611
|
-
var fileSearch = (0,
|
|
1630
|
+
var fileSearch = (0, import_provider_utils9.createProviderToolFactory)({
|
|
1612
1631
|
id: "google.file_search",
|
|
1613
1632
|
inputSchema: fileSearchArgsSchema
|
|
1614
1633
|
});
|
|
1615
1634
|
|
|
1616
1635
|
// src/tool/google-maps.ts
|
|
1617
|
-
var
|
|
1618
|
-
var
|
|
1619
|
-
var googleMaps = (0,
|
|
1636
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1637
|
+
var import_v49 = require("zod/v4");
|
|
1638
|
+
var googleMaps = (0, import_provider_utils10.createProviderToolFactory)({
|
|
1620
1639
|
id: "google.google_maps",
|
|
1621
|
-
inputSchema: (0,
|
|
1640
|
+
inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
|
|
1622
1641
|
});
|
|
1623
1642
|
|
|
1624
1643
|
// src/tool/google-search.ts
|
|
1625
|
-
var
|
|
1626
|
-
var
|
|
1627
|
-
var googleSearch = (0,
|
|
1644
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1645
|
+
var import_v410 = require("zod/v4");
|
|
1646
|
+
var googleSearch = (0, import_provider_utils11.createProviderToolFactory)({
|
|
1628
1647
|
id: "google.google_search",
|
|
1629
|
-
inputSchema: (0,
|
|
1630
|
-
() => (0,
|
|
1631
|
-
|
|
1632
|
-
mode:
|
|
1633
|
-
dynamicThreshold:
|
|
1648
|
+
inputSchema: (0, import_provider_utils11.lazySchema)(
|
|
1649
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
1650
|
+
import_v410.z.object({
|
|
1651
|
+
mode: import_v410.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1652
|
+
dynamicThreshold: import_v410.z.number().default(1)
|
|
1634
1653
|
})
|
|
1635
1654
|
)
|
|
1636
1655
|
)
|
|
1637
1656
|
});
|
|
1638
1657
|
|
|
1639
1658
|
// src/tool/url-context.ts
|
|
1640
|
-
var
|
|
1641
|
-
var
|
|
1642
|
-
var urlContext = (0,
|
|
1659
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1660
|
+
var import_v411 = require("zod/v4");
|
|
1661
|
+
var urlContext = (0, import_provider_utils12.createProviderToolFactory)({
|
|
1643
1662
|
id: "google.url_context",
|
|
1644
|
-
inputSchema: (0,
|
|
1663
|
+
inputSchema: (0, import_provider_utils12.lazySchema)(() => (0, import_provider_utils12.zodSchema)(import_v411.z.object({})))
|
|
1645
1664
|
});
|
|
1646
1665
|
|
|
1647
1666
|
// src/tool/vertex-rag-store.ts
|
|
1648
|
-
var
|
|
1649
|
-
var
|
|
1650
|
-
var vertexRagStore = (0,
|
|
1667
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1668
|
+
var import_v412 = require("zod/v4");
|
|
1669
|
+
var vertexRagStore = (0, import_provider_utils13.createProviderToolFactory)({
|
|
1651
1670
|
id: "google.vertex_rag_store",
|
|
1652
|
-
inputSchema:
|
|
1653
|
-
ragCorpus:
|
|
1654
|
-
topK:
|
|
1671
|
+
inputSchema: import_v412.z.object({
|
|
1672
|
+
ragCorpus: import_v412.z.string(),
|
|
1673
|
+
topK: import_v412.z.number().optional()
|
|
1655
1674
|
})
|
|
1656
1675
|
});
|
|
1657
1676
|
|
|
@@ -1662,6 +1681,17 @@ var googleTools = {
|
|
|
1662
1681
|
* Must have name "google_search".
|
|
1663
1682
|
*/
|
|
1664
1683
|
googleSearch,
|
|
1684
|
+
/**
|
|
1685
|
+
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
1686
|
+
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
1687
|
+
* Does not log customer data and supports VPC service controls.
|
|
1688
|
+
* Must have name "enterprise_web_search".
|
|
1689
|
+
*
|
|
1690
|
+
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
1691
|
+
*
|
|
1692
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
1693
|
+
*/
|
|
1694
|
+
enterpriseWebSearch,
|
|
1665
1695
|
/**
|
|
1666
1696
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
1667
1697
|
* Must have name "google_maps".
|
|
@@ -1705,8 +1735,8 @@ var googleTools = {
|
|
|
1705
1735
|
};
|
|
1706
1736
|
|
|
1707
1737
|
// src/google-generative-ai-image-model.ts
|
|
1708
|
-
var
|
|
1709
|
-
var
|
|
1738
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
1739
|
+
var import_v413 = require("zod/v4");
|
|
1710
1740
|
var GoogleGenerativeAIImageModel = class {
|
|
1711
1741
|
constructor(modelId, settings, config) {
|
|
1712
1742
|
this.modelId = modelId;
|
|
@@ -1726,14 +1756,26 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1726
1756
|
const {
|
|
1727
1757
|
prompt,
|
|
1728
1758
|
n = 1,
|
|
1729
|
-
size
|
|
1759
|
+
size,
|
|
1730
1760
|
aspectRatio = "1:1",
|
|
1731
1761
|
seed,
|
|
1732
1762
|
providerOptions,
|
|
1733
1763
|
headers,
|
|
1734
|
-
abortSignal
|
|
1764
|
+
abortSignal,
|
|
1765
|
+
files,
|
|
1766
|
+
mask
|
|
1735
1767
|
} = options;
|
|
1736
1768
|
const warnings = [];
|
|
1769
|
+
if (files != null && files.length > 0) {
|
|
1770
|
+
throw new Error(
|
|
1771
|
+
"Google Generative AI does not support image editing. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities."
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1774
|
+
if (mask != null) {
|
|
1775
|
+
throw new Error(
|
|
1776
|
+
"Google Generative AI does not support image editing with masks. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities."
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1737
1779
|
if (size != null) {
|
|
1738
1780
|
warnings.push({
|
|
1739
1781
|
type: "unsupported",
|
|
@@ -1748,7 +1790,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1748
1790
|
details: "This model does not support the `seed` option through this provider."
|
|
1749
1791
|
});
|
|
1750
1792
|
}
|
|
1751
|
-
const googleOptions = await (0,
|
|
1793
|
+
const googleOptions = await (0, import_provider_utils14.parseProviderOptions)({
|
|
1752
1794
|
provider: "google",
|
|
1753
1795
|
providerOptions,
|
|
1754
1796
|
schema: googleImageProviderOptionsSchema
|
|
@@ -1767,12 +1809,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1767
1809
|
instances: [{ prompt }],
|
|
1768
1810
|
parameters
|
|
1769
1811
|
};
|
|
1770
|
-
const { responseHeaders, value: response } = await (0,
|
|
1812
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
|
|
1771
1813
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
1772
|
-
headers: (0,
|
|
1814
|
+
headers: (0, import_provider_utils14.combineHeaders)(await (0, import_provider_utils14.resolve)(this.config.headers), headers),
|
|
1773
1815
|
body,
|
|
1774
1816
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1775
|
-
successfulResponseHandler: (0,
|
|
1817
|
+
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
1776
1818
|
googleImageResponseSchema
|
|
1777
1819
|
),
|
|
1778
1820
|
abortSignal,
|
|
@@ -1798,18 +1840,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1798
1840
|
};
|
|
1799
1841
|
}
|
|
1800
1842
|
};
|
|
1801
|
-
var googleImageResponseSchema = (0,
|
|
1802
|
-
() => (0,
|
|
1803
|
-
|
|
1804
|
-
predictions:
|
|
1843
|
+
var googleImageResponseSchema = (0, import_provider_utils14.lazySchema)(
|
|
1844
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1845
|
+
import_v413.z.object({
|
|
1846
|
+
predictions: import_v413.z.array(import_v413.z.object({ bytesBase64Encoded: import_v413.z.string() })).default([])
|
|
1805
1847
|
})
|
|
1806
1848
|
)
|
|
1807
1849
|
);
|
|
1808
|
-
var googleImageProviderOptionsSchema = (0,
|
|
1809
|
-
() => (0,
|
|
1810
|
-
|
|
1811
|
-
personGeneration:
|
|
1812
|
-
aspectRatio:
|
|
1850
|
+
var googleImageProviderOptionsSchema = (0, import_provider_utils14.lazySchema)(
|
|
1851
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1852
|
+
import_v413.z.object({
|
|
1853
|
+
personGeneration: import_v413.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1854
|
+
aspectRatio: import_v413.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
1813
1855
|
})
|
|
1814
1856
|
)
|
|
1815
1857
|
);
|
|
@@ -1817,11 +1859,11 @@ var googleImageProviderOptionsSchema = (0, import_provider_utils13.lazySchema)(
|
|
|
1817
1859
|
// src/google-provider.ts
|
|
1818
1860
|
function createGoogleGenerativeAI(options = {}) {
|
|
1819
1861
|
var _a, _b;
|
|
1820
|
-
const baseURL = (_a = (0,
|
|
1862
|
+
const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
1821
1863
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
1822
|
-
const getHeaders = () => (0,
|
|
1864
|
+
const getHeaders = () => (0, import_provider_utils15.withUserAgentSuffix)(
|
|
1823
1865
|
{
|
|
1824
|
-
"x-goog-api-key": (0,
|
|
1866
|
+
"x-goog-api-key": (0, import_provider_utils15.loadApiKey)({
|
|
1825
1867
|
apiKey: options.apiKey,
|
|
1826
1868
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
1827
1869
|
description: "Google Generative AI"
|
|
@@ -1836,7 +1878,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
1836
1878
|
provider: providerName,
|
|
1837
1879
|
baseURL,
|
|
1838
1880
|
headers: getHeaders,
|
|
1839
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
1881
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils15.generateId,
|
|
1840
1882
|
supportedUrls: () => ({
|
|
1841
1883
|
"*": [
|
|
1842
1884
|
// Google Generative Language "files" endpoint
|