@ai-sdk/google 2.0.28 → 2.0.29
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 +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +90 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -27
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +24 -2
- package/dist/internal/index.d.ts +24 -2
- package/dist/internal/index.js +69 -12
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +75 -14
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -85,6 +85,9 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
85
85
|
retrievedContext?: {
|
|
86
86
|
uri: string;
|
|
87
87
|
title?: string | null | undefined;
|
|
88
|
+
} | {
|
|
89
|
+
title?: string | null | undefined;
|
|
90
|
+
text?: string | null | undefined;
|
|
88
91
|
} | null | undefined;
|
|
89
92
|
}[] | null | undefined;
|
|
90
93
|
groundingSupports?: {
|
|
@@ -177,6 +180,22 @@ declare const googleTools: {
|
|
|
177
180
|
* Must have name "url_context".
|
|
178
181
|
*/
|
|
179
182
|
urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
|
|
183
|
+
/**
|
|
184
|
+
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
185
|
+
* Must have name "file_search".
|
|
186
|
+
*
|
|
187
|
+
* @param fileSearchStoreNames - Fully-qualified File Search store resource names.
|
|
188
|
+
* @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
|
|
189
|
+
* @param topK - Optional result limit for the number of chunks returned from File Search.
|
|
190
|
+
*
|
|
191
|
+
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
192
|
+
*/
|
|
193
|
+
fileSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
194
|
+
[x: string]: unknown;
|
|
195
|
+
fileSearchStoreNames: string[];
|
|
196
|
+
topK?: number | undefined;
|
|
197
|
+
metadataFilter?: string | undefined;
|
|
198
|
+
}>;
|
|
180
199
|
/**
|
|
181
200
|
* A tool that enables the model to generate and run Python code.
|
|
182
201
|
* Must have name "code_execution".
|
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,9 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
85
85
|
retrievedContext?: {
|
|
86
86
|
uri: string;
|
|
87
87
|
title?: string | null | undefined;
|
|
88
|
+
} | {
|
|
89
|
+
title?: string | null | undefined;
|
|
90
|
+
text?: string | null | undefined;
|
|
88
91
|
} | null | undefined;
|
|
89
92
|
}[] | null | undefined;
|
|
90
93
|
groundingSupports?: {
|
|
@@ -177,6 +180,22 @@ declare const googleTools: {
|
|
|
177
180
|
* Must have name "url_context".
|
|
178
181
|
*/
|
|
179
182
|
urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
|
|
183
|
+
/**
|
|
184
|
+
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
185
|
+
* Must have name "file_search".
|
|
186
|
+
*
|
|
187
|
+
* @param fileSearchStoreNames - Fully-qualified File Search store resource names.
|
|
188
|
+
* @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
|
|
189
|
+
* @param topK - Optional result limit for the number of chunks returned from File Search.
|
|
190
|
+
*
|
|
191
|
+
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
192
|
+
*/
|
|
193
|
+
fileSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
194
|
+
[x: string]: unknown;
|
|
195
|
+
fileSearchStoreNames: string[];
|
|
196
|
+
topK?: number | undefined;
|
|
197
|
+
metadataFilter?: string | undefined;
|
|
198
|
+
}>;
|
|
180
199
|
/**
|
|
181
200
|
* A tool that enables the model to generate and run Python code.
|
|
182
201
|
* Must have name "code_execution".
|
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_utils12 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.29" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -589,6 +589,7 @@ function prepareTools({
|
|
|
589
589
|
const toolWarnings = [];
|
|
590
590
|
const isGemini2 = modelId.includes("gemini-2");
|
|
591
591
|
const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
|
|
592
|
+
const supportsFileSearch = modelId.includes("gemini-2.5");
|
|
592
593
|
if (tools == null) {
|
|
593
594
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
594
595
|
}
|
|
@@ -648,6 +649,17 @@ function prepareTools({
|
|
|
648
649
|
});
|
|
649
650
|
}
|
|
650
651
|
break;
|
|
652
|
+
case "google.file_search":
|
|
653
|
+
if (supportsFileSearch) {
|
|
654
|
+
googleTools2.push({ fileSearch: { ...tool.args } });
|
|
655
|
+
} else {
|
|
656
|
+
toolWarnings.push({
|
|
657
|
+
type: "unsupported-tool",
|
|
658
|
+
tool,
|
|
659
|
+
details: "The file search tool is only supported with Gemini 2.5 models."
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
break;
|
|
651
663
|
default:
|
|
652
664
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
653
665
|
break;
|
|
@@ -1253,7 +1265,13 @@ var getGroundingMetadataSchema = () => import_v45.z.object({
|
|
|
1253
1265
|
groundingChunks: import_v45.z.array(
|
|
1254
1266
|
import_v45.z.object({
|
|
1255
1267
|
web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
|
|
1256
|
-
retrievedContext: import_v45.z.
|
|
1268
|
+
retrievedContext: import_v45.z.union([
|
|
1269
|
+
import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
|
|
1270
|
+
import_v45.z.object({
|
|
1271
|
+
title: import_v45.z.string().nullish(),
|
|
1272
|
+
text: import_v45.z.string().nullish()
|
|
1273
|
+
})
|
|
1274
|
+
])
|
|
1257
1275
|
})
|
|
1258
1276
|
).nullish(),
|
|
1259
1277
|
groundingSupports: import_v45.z.array(
|
|
@@ -1390,29 +1408,57 @@ var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryW
|
|
|
1390
1408
|
})
|
|
1391
1409
|
});
|
|
1392
1410
|
|
|
1393
|
-
// src/tool/
|
|
1411
|
+
// src/tool/file-search.ts
|
|
1394
1412
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1395
1413
|
var import_v47 = require("zod/v4");
|
|
1396
|
-
var
|
|
1414
|
+
var fileSearchArgsBaseSchema = import_v47.z.object({
|
|
1415
|
+
/** The names of the file_search_stores to retrieve from.
|
|
1416
|
+
* Example: `fileSearchStores/my-file-search-store-123`
|
|
1417
|
+
*/
|
|
1418
|
+
fileSearchStoreNames: import_v47.z.array(import_v47.z.string()).describe(
|
|
1419
|
+
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
1420
|
+
),
|
|
1421
|
+
/** The number of file search retrieval chunks to retrieve. */
|
|
1422
|
+
topK: import_v47.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
1423
|
+
/** Metadata filter to apply to the file search retrieval documents.
|
|
1424
|
+
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
1425
|
+
*/
|
|
1426
|
+
metadataFilter: import_v47.z.string().describe(
|
|
1427
|
+
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
1428
|
+
).optional()
|
|
1429
|
+
}).passthrough();
|
|
1430
|
+
var fileSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
1431
|
+
() => (0, import_provider_utils8.zodSchema)(fileSearchArgsBaseSchema)
|
|
1432
|
+
);
|
|
1433
|
+
var fileSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1434
|
+
id: "google.file_search",
|
|
1435
|
+
name: "file_search",
|
|
1436
|
+
inputSchema: fileSearchArgsSchema
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
// src/tool/google-search.ts
|
|
1440
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1441
|
+
var import_v48 = require("zod/v4");
|
|
1442
|
+
var googleSearch = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1397
1443
|
id: "google.google_search",
|
|
1398
1444
|
name: "google_search",
|
|
1399
|
-
inputSchema: (0,
|
|
1400
|
-
() => (0,
|
|
1401
|
-
|
|
1402
|
-
mode:
|
|
1403
|
-
dynamicThreshold:
|
|
1445
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(
|
|
1446
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1447
|
+
import_v48.z.object({
|
|
1448
|
+
mode: import_v48.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1449
|
+
dynamicThreshold: import_v48.z.number().default(1)
|
|
1404
1450
|
})
|
|
1405
1451
|
)
|
|
1406
1452
|
)
|
|
1407
1453
|
});
|
|
1408
1454
|
|
|
1409
1455
|
// src/tool/url-context.ts
|
|
1410
|
-
var
|
|
1411
|
-
var
|
|
1412
|
-
var urlContext = (0,
|
|
1456
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1457
|
+
var import_v49 = require("zod/v4");
|
|
1458
|
+
var urlContext = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1413
1459
|
id: "google.url_context",
|
|
1414
1460
|
name: "url_context",
|
|
1415
|
-
inputSchema: (0,
|
|
1461
|
+
inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
|
|
1416
1462
|
});
|
|
1417
1463
|
|
|
1418
1464
|
// src/google-tools.ts
|
|
@@ -1427,6 +1473,17 @@ var googleTools = {
|
|
|
1427
1473
|
* Must have name "url_context".
|
|
1428
1474
|
*/
|
|
1429
1475
|
urlContext,
|
|
1476
|
+
/**
|
|
1477
|
+
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
1478
|
+
* Must have name "file_search".
|
|
1479
|
+
*
|
|
1480
|
+
* @param fileSearchStoreNames - Fully-qualified File Search store resource names.
|
|
1481
|
+
* @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
|
|
1482
|
+
* @param topK - Optional result limit for the number of chunks returned from File Search.
|
|
1483
|
+
*
|
|
1484
|
+
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
1485
|
+
*/
|
|
1486
|
+
fileSearch,
|
|
1430
1487
|
/**
|
|
1431
1488
|
* A tool that enables the model to generate and run Python code.
|
|
1432
1489
|
* Must have name "code_execution".
|
|
@@ -1441,8 +1498,8 @@ var googleTools = {
|
|
|
1441
1498
|
};
|
|
1442
1499
|
|
|
1443
1500
|
// src/google-generative-ai-image-model.ts
|
|
1444
|
-
var
|
|
1445
|
-
var
|
|
1501
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1502
|
+
var import_v410 = require("zod/v4");
|
|
1446
1503
|
var GoogleGenerativeAIImageModel = class {
|
|
1447
1504
|
constructor(modelId, settings, config) {
|
|
1448
1505
|
this.modelId = modelId;
|
|
@@ -1484,7 +1541,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1484
1541
|
details: "This model does not support the `seed` option through this provider."
|
|
1485
1542
|
});
|
|
1486
1543
|
}
|
|
1487
|
-
const googleOptions = await (0,
|
|
1544
|
+
const googleOptions = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1488
1545
|
provider: "google",
|
|
1489
1546
|
providerOptions,
|
|
1490
1547
|
schema: googleImageProviderOptionsSchema
|
|
@@ -1503,12 +1560,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1503
1560
|
instances: [{ prompt }],
|
|
1504
1561
|
parameters
|
|
1505
1562
|
};
|
|
1506
|
-
const { responseHeaders, value: response } = await (0,
|
|
1563
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
|
|
1507
1564
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
1508
|
-
headers: (0,
|
|
1565
|
+
headers: (0, import_provider_utils11.combineHeaders)(await (0, import_provider_utils11.resolve)(this.config.headers), headers),
|
|
1509
1566
|
body,
|
|
1510
1567
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1511
|
-
successfulResponseHandler: (0,
|
|
1568
|
+
successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
|
|
1512
1569
|
googleImageResponseSchema
|
|
1513
1570
|
),
|
|
1514
1571
|
abortSignal,
|
|
@@ -1534,18 +1591,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
1534
1591
|
};
|
|
1535
1592
|
}
|
|
1536
1593
|
};
|
|
1537
|
-
var googleImageResponseSchema = (0,
|
|
1538
|
-
() => (0,
|
|
1539
|
-
|
|
1540
|
-
predictions:
|
|
1594
|
+
var googleImageResponseSchema = (0, import_provider_utils11.lazySchema)(
|
|
1595
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
1596
|
+
import_v410.z.object({
|
|
1597
|
+
predictions: import_v410.z.array(import_v410.z.object({ bytesBase64Encoded: import_v410.z.string() })).default([])
|
|
1541
1598
|
})
|
|
1542
1599
|
)
|
|
1543
1600
|
);
|
|
1544
|
-
var googleImageProviderOptionsSchema = (0,
|
|
1545
|
-
() => (0,
|
|
1546
|
-
|
|
1547
|
-
personGeneration:
|
|
1548
|
-
aspectRatio:
|
|
1601
|
+
var googleImageProviderOptionsSchema = (0, import_provider_utils11.lazySchema)(
|
|
1602
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
1603
|
+
import_v410.z.object({
|
|
1604
|
+
personGeneration: import_v410.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1605
|
+
aspectRatio: import_v410.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
1549
1606
|
})
|
|
1550
1607
|
)
|
|
1551
1608
|
);
|
|
@@ -1553,10 +1610,10 @@ var googleImageProviderOptionsSchema = (0, import_provider_utils10.lazySchema)(
|
|
|
1553
1610
|
// src/google-provider.ts
|
|
1554
1611
|
function createGoogleGenerativeAI(options = {}) {
|
|
1555
1612
|
var _a;
|
|
1556
|
-
const baseURL = (_a = (0,
|
|
1557
|
-
const getHeaders = () => (0,
|
|
1613
|
+
const baseURL = (_a = (0, import_provider_utils12.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
1614
|
+
const getHeaders = () => (0, import_provider_utils12.withUserAgentSuffix)(
|
|
1558
1615
|
{
|
|
1559
|
-
"x-goog-api-key": (0,
|
|
1616
|
+
"x-goog-api-key": (0, import_provider_utils12.loadApiKey)({
|
|
1560
1617
|
apiKey: options.apiKey,
|
|
1561
1618
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
1562
1619
|
description: "Google Generative AI"
|
|
@@ -1571,7 +1628,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
1571
1628
|
provider: "google.generative-ai",
|
|
1572
1629
|
baseURL,
|
|
1573
1630
|
headers: getHeaders,
|
|
1574
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
1631
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils12.generateId,
|
|
1575
1632
|
supportedUrls: () => ({
|
|
1576
1633
|
"*": [
|
|
1577
1634
|
// Google Generative Language "files" endpoint
|