@ai-sdk/google 2.0.48 → 2.0.49
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 +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +82 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -49
- 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 +61 -30
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +71 -36
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -189,6 +189,17 @@ declare const googleTools: {
|
|
|
189
189
|
mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
|
|
190
190
|
dynamicThreshold?: number;
|
|
191
191
|
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
194
|
+
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
195
|
+
* Does not log customer data and supports VPC service controls.
|
|
196
|
+
* Must have name "enterprise_web_search".
|
|
197
|
+
*
|
|
198
|
+
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
199
|
+
*
|
|
200
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
201
|
+
*/
|
|
202
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
|
|
192
203
|
/**
|
|
193
204
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
194
205
|
* Must have name "google_maps".
|
package/dist/index.d.ts
CHANGED
|
@@ -189,6 +189,17 @@ declare const googleTools: {
|
|
|
189
189
|
mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
|
|
190
190
|
dynamicThreshold?: number;
|
|
191
191
|
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
194
|
+
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
195
|
+
* Does not log customer data and supports VPC service controls.
|
|
196
|
+
* Must have name "enterprise_web_search".
|
|
197
|
+
*
|
|
198
|
+
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
199
|
+
*
|
|
200
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
201
|
+
*/
|
|
202
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
|
|
192
203
|
/**
|
|
193
204
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
194
205
|
* 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 ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.49" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -651,6 +651,17 @@ function prepareTools({
|
|
|
651
651
|
googleTools2.push({ googleSearchRetrieval: {} });
|
|
652
652
|
}
|
|
653
653
|
break;
|
|
654
|
+
case "google.enterprise_web_search":
|
|
655
|
+
if (isGemini2orNewer) {
|
|
656
|
+
googleTools2.push({ enterpriseWebSearch: {} });
|
|
657
|
+
} else {
|
|
658
|
+
toolWarnings.push({
|
|
659
|
+
type: "unsupported-tool",
|
|
660
|
+
tool,
|
|
661
|
+
details: "Enterprise Web Search requires Gemini 2.0 or newer."
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
break;
|
|
654
665
|
case "google.url_context":
|
|
655
666
|
if (isGemini2orNewer) {
|
|
656
667
|
googleTools2.push({ urlContext: {} });
|
|
@@ -1535,77 +1546,86 @@ var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryW
|
|
|
1535
1546
|
})
|
|
1536
1547
|
});
|
|
1537
1548
|
|
|
1538
|
-
// src/tool/
|
|
1549
|
+
// src/tool/enterprise-web-search.ts
|
|
1539
1550
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1540
1551
|
var import_v47 = require("zod/v4");
|
|
1541
|
-
var
|
|
1552
|
+
var enterpriseWebSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1553
|
+
id: "google.enterprise_web_search",
|
|
1554
|
+
name: "enterprise_web_search",
|
|
1555
|
+
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
|
|
1556
|
+
});
|
|
1557
|
+
|
|
1558
|
+
// src/tool/file-search.ts
|
|
1559
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1560
|
+
var import_v48 = require("zod/v4");
|
|
1561
|
+
var fileSearchArgsBaseSchema = import_v48.z.object({
|
|
1542
1562
|
/** The names of the file_search_stores to retrieve from.
|
|
1543
1563
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
1544
1564
|
*/
|
|
1545
|
-
fileSearchStoreNames:
|
|
1565
|
+
fileSearchStoreNames: import_v48.z.array(import_v48.z.string()).describe(
|
|
1546
1566
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
1547
1567
|
),
|
|
1548
1568
|
/** The number of file search retrieval chunks to retrieve. */
|
|
1549
|
-
topK:
|
|
1569
|
+
topK: import_v48.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
1550
1570
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
1551
1571
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
1552
1572
|
*/
|
|
1553
|
-
metadataFilter:
|
|
1573
|
+
metadataFilter: import_v48.z.string().describe(
|
|
1554
1574
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
1555
1575
|
).optional()
|
|
1556
1576
|
}).passthrough();
|
|
1557
|
-
var fileSearchArgsSchema = (0,
|
|
1558
|
-
() => (0,
|
|
1577
|
+
var fileSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1578
|
+
() => (0, import_provider_utils9.zodSchema)(fileSearchArgsBaseSchema)
|
|
1559
1579
|
);
|
|
1560
|
-
var fileSearch = (0,
|
|
1580
|
+
var fileSearch = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1561
1581
|
id: "google.file_search",
|
|
1562
1582
|
name: "file_search",
|
|
1563
1583
|
inputSchema: fileSearchArgsSchema
|
|
1564
1584
|
});
|
|
1565
1585
|
|
|
1566
1586
|
// src/tool/google-maps.ts
|
|
1567
|
-
var
|
|
1568
|
-
var
|
|
1569
|
-
var googleMaps = (0,
|
|
1587
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1588
|
+
var import_v49 = require("zod/v4");
|
|
1589
|
+
var googleMaps = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1570
1590
|
id: "google.google_maps",
|
|
1571
1591
|
name: "google_maps",
|
|
1572
|
-
inputSchema: (0,
|
|
1592
|
+
inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
|
|
1573
1593
|
});
|
|
1574
1594
|
|
|
1575
1595
|
// src/tool/google-search.ts
|
|
1576
|
-
var
|
|
1577
|
-
var
|
|
1578
|
-
var googleSearch = (0,
|
|
1596
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1597
|
+
var import_v410 = require("zod/v4");
|
|
1598
|
+
var googleSearch = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1579
1599
|
id: "google.google_search",
|
|
1580
1600
|
name: "google_search",
|
|
1581
|
-
inputSchema: (0,
|
|
1582
|
-
() => (0,
|
|
1583
|
-
|
|
1584
|
-
mode:
|
|
1585
|
-
dynamicThreshold:
|
|
1601
|
+
inputSchema: (0, import_provider_utils11.lazySchema)(
|
|
1602
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
1603
|
+
import_v410.z.object({
|
|
1604
|
+
mode: import_v410.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1605
|
+
dynamicThreshold: import_v410.z.number().default(1)
|
|
1586
1606
|
})
|
|
1587
1607
|
)
|
|
1588
1608
|
)
|
|
1589
1609
|
});
|
|
1590
1610
|
|
|
1591
1611
|
// src/tool/url-context.ts
|
|
1592
|
-
var
|
|
1593
|
-
var
|
|
1594
|
-
var urlContext = (0,
|
|
1612
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1613
|
+
var import_v411 = require("zod/v4");
|
|
1614
|
+
var urlContext = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
1595
1615
|
id: "google.url_context",
|
|
1596
1616
|
name: "url_context",
|
|
1597
|
-
inputSchema: (0,
|
|
1617
|
+
inputSchema: (0, import_provider_utils12.lazySchema)(() => (0, import_provider_utils12.zodSchema)(import_v411.z.object({})))
|
|
1598
1618
|
});
|
|
1599
1619
|
|
|
1600
1620
|
// src/tool/vertex-rag-store.ts
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1603
|
-
var vertexRagStore = (0,
|
|
1621
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1622
|
+
var import_v412 = require("zod/v4");
|
|
1623
|
+
var vertexRagStore = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
1604
1624
|
id: "google.vertex_rag_store",
|
|
1605
1625
|
name: "vertex_rag_store",
|
|
1606
|
-
inputSchema:
|
|
1607
|
-
ragCorpus:
|
|
1608
|
-
topK:
|
|
1626
|
+
inputSchema: import_v412.z.object({
|
|
1627
|
+
ragCorpus: import_v412.z.string(),
|
|
1628
|
+
topK: import_v412.z.number().optional()
|
|
1609
1629
|
})
|
|
1610
1630
|
});
|
|
1611
1631
|
|
|
@@ -1616,6 +1636,17 @@ var googleTools = {
|
|
|
1616
1636
|
* Must have name "google_search".
|
|
1617
1637
|
*/
|
|
1618
1638
|
googleSearch,
|
|
1639
|
+
/**
|
|
1640
|
+
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
1641
|
+
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
1642
|
+
* Does not log customer data and supports VPC service controls.
|
|
1643
|
+
* Must have name "enterprise_web_search".
|
|
1644
|
+
*
|
|
1645
|
+
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
1646
|
+
*
|
|
1647
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
1648
|
+
*/
|
|
1649
|
+
enterpriseWebSearch,
|
|
1619
1650
|
/**
|
|
1620
1651
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
1621
1652
|
* Must have name "google_maps".
|
|
@@ -1659,8 +1690,8 @@ var googleTools = {
|
|
|
1659
1690
|
};
|
|
1660
1691
|
|
|
1661
1692
|
// src/google-generative-ai-image-model.ts
|
|
1662
|
-
var
|
|
1663
|
-
var
|
|
1693
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
1694
|
+
var import_v413 = require("zod/v4");
|
|
1664
1695
|
var GoogleGenerativeAIImageModel = class {
|
|
1665
1696
|
constructor(modelId, settings, config) {
|
|
1666
1697
|
this.modelId = modelId;
|
|
@@ -1702,7 +1733,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1702
1733
|
details: "This model does not support the `seed` option through this provider."
|
|
1703
1734
|
});
|
|
1704
1735
|
}
|
|
1705
|
-
const googleOptions = await (0,
|
|
1736
|
+
const googleOptions = await (0, import_provider_utils14.parseProviderOptions)({
|
|
1706
1737
|
provider: "google",
|
|
1707
1738
|
providerOptions,
|
|
1708
1739
|
schema: googleImageProviderOptionsSchema
|
|
@@ -1721,12 +1752,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1721
1752
|
instances: [{ prompt }],
|
|
1722
1753
|
parameters
|
|
1723
1754
|
};
|
|
1724
|
-
const { responseHeaders, value: response } = await (0,
|
|
1755
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
|
|
1725
1756
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
1726
|
-
headers: (0,
|
|
1757
|
+
headers: (0, import_provider_utils14.combineHeaders)(await (0, import_provider_utils14.resolve)(this.config.headers), headers),
|
|
1727
1758
|
body,
|
|
1728
1759
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1729
|
-
successfulResponseHandler: (0,
|
|
1760
|
+
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
1730
1761
|
googleImageResponseSchema
|
|
1731
1762
|
),
|
|
1732
1763
|
abortSignal,
|
|
@@ -1752,18 +1783,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1752
1783
|
};
|
|
1753
1784
|
}
|
|
1754
1785
|
};
|
|
1755
|
-
var googleImageResponseSchema = (0,
|
|
1756
|
-
() => (0,
|
|
1757
|
-
|
|
1758
|
-
predictions:
|
|
1786
|
+
var googleImageResponseSchema = (0, import_provider_utils14.lazySchema)(
|
|
1787
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1788
|
+
import_v413.z.object({
|
|
1789
|
+
predictions: import_v413.z.array(import_v413.z.object({ bytesBase64Encoded: import_v413.z.string() })).default([])
|
|
1759
1790
|
})
|
|
1760
1791
|
)
|
|
1761
1792
|
);
|
|
1762
|
-
var googleImageProviderOptionsSchema = (0,
|
|
1763
|
-
() => (0,
|
|
1764
|
-
|
|
1765
|
-
personGeneration:
|
|
1766
|
-
aspectRatio:
|
|
1793
|
+
var googleImageProviderOptionsSchema = (0, import_provider_utils14.lazySchema)(
|
|
1794
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1795
|
+
import_v413.z.object({
|
|
1796
|
+
personGeneration: import_v413.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1797
|
+
aspectRatio: import_v413.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
1767
1798
|
})
|
|
1768
1799
|
)
|
|
1769
1800
|
);
|
|
@@ -1771,11 +1802,11 @@ var googleImageProviderOptionsSchema = (0, import_provider_utils13.lazySchema)(
|
|
|
1771
1802
|
// src/google-provider.ts
|
|
1772
1803
|
function createGoogleGenerativeAI(options = {}) {
|
|
1773
1804
|
var _a, _b;
|
|
1774
|
-
const baseURL = (_a = (0,
|
|
1805
|
+
const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
1775
1806
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
1776
|
-
const getHeaders = () => (0,
|
|
1807
|
+
const getHeaders = () => (0, import_provider_utils15.withUserAgentSuffix)(
|
|
1777
1808
|
{
|
|
1778
|
-
"x-goog-api-key": (0,
|
|
1809
|
+
"x-goog-api-key": (0, import_provider_utils15.loadApiKey)({
|
|
1779
1810
|
apiKey: options.apiKey,
|
|
1780
1811
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
1781
1812
|
description: "Google Generative AI"
|
|
@@ -1790,7 +1821,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
1790
1821
|
provider: providerName,
|
|
1791
1822
|
baseURL,
|
|
1792
1823
|
headers: getHeaders,
|
|
1793
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
1824
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils15.generateId,
|
|
1794
1825
|
supportedUrls: () => ({
|
|
1795
1826
|
"*": [
|
|
1796
1827
|
// Google Generative Language "files" endpoint
|