@ai-sdk/google 4.0.0-beta.36 → 4.0.0-beta.38
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 +30 -0
- package/dist/index.js +546 -431
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +11 -3
- package/dist/internal/index.js +325 -296
- package/dist/internal/index.js.map +1 -1
- package/package.json +9 -10
- package/src/convert-to-google-generative-ai-messages.ts +15 -13
- package/src/google-generative-ai-embedding-model.ts +22 -2
- package/src/google-generative-ai-image-model.ts +25 -1
- package/src/google-generative-ai-language-model.ts +20 -3
- package/dist/index.d.mts +0 -427
- package/dist/index.mjs +0 -3439
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -319
- package/dist/internal/index.mjs +0 -2458
- package/dist/internal/index.mjs.map +0 -1
package/dist/internal/index.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/internal/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
GoogleGenerativeAILanguageModel: () => GoogleGenerativeAILanguageModel,
|
|
24
|
-
getGroundingMetadataSchema: () => getGroundingMetadataSchema,
|
|
25
|
-
getUrlContextMetadataSchema: () => getUrlContextMetadataSchema,
|
|
26
|
-
googleTools: () => googleTools
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
1
|
// src/google-generative-ai-language-model.ts
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
import {
|
|
3
|
+
combineHeaders,
|
|
4
|
+
createEventSourceResponseHandler,
|
|
5
|
+
createJsonResponseHandler,
|
|
6
|
+
generateId,
|
|
7
|
+
isCustomReasoning,
|
|
8
|
+
lazySchema as lazySchema3,
|
|
9
|
+
mapReasoningToProviderBudget,
|
|
10
|
+
mapReasoningToProviderEffort,
|
|
11
|
+
parseProviderOptions,
|
|
12
|
+
postJsonToApi,
|
|
13
|
+
resolve,
|
|
14
|
+
serializeModelOptions,
|
|
15
|
+
WORKFLOW_SERIALIZE,
|
|
16
|
+
WORKFLOW_DESERIALIZE,
|
|
17
|
+
zodSchema as zodSchema3
|
|
18
|
+
} from "@ai-sdk/provider-utils";
|
|
19
|
+
import { z as z3 } from "zod/v4";
|
|
33
20
|
|
|
34
21
|
// src/convert-google-generative-ai-usage.ts
|
|
35
22
|
function convertGoogleGenerativeAIUsage(usage) {
|
|
@@ -187,8 +174,14 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
187
174
|
}
|
|
188
175
|
|
|
189
176
|
// src/convert-to-google-generative-ai-messages.ts
|
|
190
|
-
|
|
191
|
-
|
|
177
|
+
import {
|
|
178
|
+
UnsupportedFunctionalityError
|
|
179
|
+
} from "@ai-sdk/provider";
|
|
180
|
+
import {
|
|
181
|
+
convertToBase64,
|
|
182
|
+
isProviderReference,
|
|
183
|
+
resolveProviderReference
|
|
184
|
+
} from "@ai-sdk/provider-utils";
|
|
192
185
|
var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
|
|
193
186
|
function parseBase64DataUrl(value) {
|
|
194
187
|
const match = dataUrlRegex.exec(value);
|
|
@@ -221,7 +214,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
|
|
|
221
214
|
responseTextParts.push(contentPart.text);
|
|
222
215
|
break;
|
|
223
216
|
}
|
|
224
|
-
case "image-data":
|
|
225
217
|
case "file-data": {
|
|
226
218
|
functionResponseParts.push({
|
|
227
219
|
inlineData: {
|
|
@@ -231,7 +223,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
|
|
|
231
223
|
});
|
|
232
224
|
break;
|
|
233
225
|
}
|
|
234
|
-
case "image-url":
|
|
235
226
|
case "file-url": {
|
|
236
227
|
const functionResponsePart = convertUrlToolResultPart(
|
|
237
228
|
contentPart.url
|
|
@@ -274,18 +265,22 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
|
|
|
274
265
|
}
|
|
275
266
|
});
|
|
276
267
|
break;
|
|
277
|
-
case "
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
268
|
+
case "file-data":
|
|
269
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
270
|
+
parts.push(
|
|
271
|
+
{
|
|
272
|
+
inlineData: {
|
|
273
|
+
mimeType: contentPart.mediaType,
|
|
274
|
+
data: contentPart.data
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
text: "Tool executed successfully and returned this image as a response"
|
|
283
279
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
);
|
|
280
|
+
);
|
|
281
|
+
} else {
|
|
282
|
+
parts.push({ text: JSON.stringify(contentPart) });
|
|
283
|
+
}
|
|
289
284
|
break;
|
|
290
285
|
default:
|
|
291
286
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
@@ -305,7 +300,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
305
300
|
switch (role) {
|
|
306
301
|
case "system": {
|
|
307
302
|
if (!systemMessagesAllowed) {
|
|
308
|
-
throw new
|
|
303
|
+
throw new UnsupportedFunctionalityError({
|
|
309
304
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
310
305
|
});
|
|
311
306
|
}
|
|
@@ -330,16 +325,16 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
330
325
|
fileUri: part.data.toString()
|
|
331
326
|
}
|
|
332
327
|
});
|
|
333
|
-
} else if (
|
|
328
|
+
} else if (isProviderReference(part.data)) {
|
|
334
329
|
if (providerOptionsName === "vertex") {
|
|
335
|
-
throw new
|
|
330
|
+
throw new UnsupportedFunctionalityError({
|
|
336
331
|
functionality: "file parts with provider references"
|
|
337
332
|
});
|
|
338
333
|
}
|
|
339
334
|
parts.push({
|
|
340
335
|
fileData: {
|
|
341
336
|
mimeType: mediaType,
|
|
342
|
-
fileUri:
|
|
337
|
+
fileUri: resolveProviderReference({
|
|
343
338
|
reference: part.data,
|
|
344
339
|
provider: "google"
|
|
345
340
|
})
|
|
@@ -349,7 +344,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
349
344
|
parts.push({
|
|
350
345
|
inlineData: {
|
|
351
346
|
mimeType: mediaType,
|
|
352
|
-
data:
|
|
347
|
+
data: convertToBase64(part.data)
|
|
353
348
|
}
|
|
354
349
|
});
|
|
355
350
|
}
|
|
@@ -384,14 +379,14 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
384
379
|
}
|
|
385
380
|
case "reasoning-file": {
|
|
386
381
|
if (part.data instanceof URL) {
|
|
387
|
-
throw new
|
|
382
|
+
throw new UnsupportedFunctionalityError({
|
|
388
383
|
functionality: "File data URLs in assistant messages are not supported"
|
|
389
384
|
});
|
|
390
385
|
}
|
|
391
386
|
return {
|
|
392
387
|
inlineData: {
|
|
393
388
|
mimeType: part.mediaType,
|
|
394
|
-
data:
|
|
389
|
+
data: convertToBase64(part.data)
|
|
395
390
|
},
|
|
396
391
|
thought: true,
|
|
397
392
|
thoughtSignature
|
|
@@ -399,20 +394,20 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
399
394
|
}
|
|
400
395
|
case "file": {
|
|
401
396
|
if (part.data instanceof URL) {
|
|
402
|
-
throw new
|
|
397
|
+
throw new UnsupportedFunctionalityError({
|
|
403
398
|
functionality: "File data URLs in assistant messages are not supported"
|
|
404
399
|
});
|
|
405
400
|
}
|
|
406
|
-
if (
|
|
401
|
+
if (isProviderReference(part.data)) {
|
|
407
402
|
if (providerOptionsName === "vertex") {
|
|
408
|
-
throw new
|
|
403
|
+
throw new UnsupportedFunctionalityError({
|
|
409
404
|
functionality: "file parts with provider references"
|
|
410
405
|
});
|
|
411
406
|
}
|
|
412
407
|
return {
|
|
413
408
|
fileData: {
|
|
414
409
|
mimeType: part.mediaType,
|
|
415
|
-
fileUri:
|
|
410
|
+
fileUri: resolveProviderReference({
|
|
416
411
|
reference: part.data,
|
|
417
412
|
provider: "google"
|
|
418
413
|
})
|
|
@@ -424,7 +419,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
424
419
|
return {
|
|
425
420
|
inlineData: {
|
|
426
421
|
mimeType: part.mediaType,
|
|
427
|
-
data:
|
|
422
|
+
data: convertToBase64(part.data)
|
|
428
423
|
},
|
|
429
424
|
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
430
425
|
thoughtSignature
|
|
@@ -541,43 +536,47 @@ function getModelPath(modelId) {
|
|
|
541
536
|
}
|
|
542
537
|
|
|
543
538
|
// src/google-error.ts
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
539
|
+
import {
|
|
540
|
+
createJsonErrorResponseHandler,
|
|
541
|
+
lazySchema,
|
|
542
|
+
zodSchema
|
|
543
|
+
} from "@ai-sdk/provider-utils";
|
|
544
|
+
import { z } from "zod/v4";
|
|
545
|
+
var googleErrorDataSchema = lazySchema(
|
|
546
|
+
() => zodSchema(
|
|
547
|
+
z.object({
|
|
548
|
+
error: z.object({
|
|
549
|
+
code: z.number().nullable(),
|
|
550
|
+
message: z.string(),
|
|
551
|
+
status: z.string()
|
|
553
552
|
})
|
|
554
553
|
})
|
|
555
554
|
)
|
|
556
555
|
);
|
|
557
|
-
var googleFailedResponseHandler =
|
|
556
|
+
var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
558
557
|
errorSchema: googleErrorDataSchema,
|
|
559
558
|
errorToMessage: (data) => data.error.message
|
|
560
559
|
});
|
|
561
560
|
|
|
562
561
|
// src/google-generative-ai-options.ts
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
var googleLanguageModelOptions = (
|
|
566
|
-
() => (
|
|
567
|
-
|
|
568
|
-
responseModalities:
|
|
569
|
-
thinkingConfig:
|
|
570
|
-
thinkingBudget:
|
|
571
|
-
includeThoughts:
|
|
562
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
563
|
+
import { z as z2 } from "zod/v4";
|
|
564
|
+
var googleLanguageModelOptions = lazySchema2(
|
|
565
|
+
() => zodSchema2(
|
|
566
|
+
z2.object({
|
|
567
|
+
responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
|
|
568
|
+
thinkingConfig: z2.object({
|
|
569
|
+
thinkingBudget: z2.number().optional(),
|
|
570
|
+
includeThoughts: z2.boolean().optional(),
|
|
572
571
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
573
|
-
thinkingLevel:
|
|
572
|
+
thinkingLevel: z2.enum(["minimal", "low", "medium", "high"]).optional()
|
|
574
573
|
}).optional(),
|
|
575
574
|
/**
|
|
576
575
|
* Optional.
|
|
577
576
|
* The name of the cached content used as context to serve the prediction.
|
|
578
577
|
* Format: cachedContents/{cachedContent}
|
|
579
578
|
*/
|
|
580
|
-
cachedContent:
|
|
579
|
+
cachedContent: z2.string().optional(),
|
|
581
580
|
/**
|
|
582
581
|
* Optional. Enable structured output. Default is true.
|
|
583
582
|
*
|
|
@@ -586,13 +585,13 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
586
585
|
* Google Generative AI uses. You can use this to disable
|
|
587
586
|
* structured outputs if you need to.
|
|
588
587
|
*/
|
|
589
|
-
structuredOutputs:
|
|
588
|
+
structuredOutputs: z2.boolean().optional(),
|
|
590
589
|
/**
|
|
591
590
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
592
591
|
*/
|
|
593
|
-
safetySettings:
|
|
594
|
-
|
|
595
|
-
category:
|
|
592
|
+
safetySettings: z2.array(
|
|
593
|
+
z2.object({
|
|
594
|
+
category: z2.enum([
|
|
596
595
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
597
596
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
598
597
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -600,7 +599,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
600
599
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
601
600
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
602
601
|
]),
|
|
603
|
-
threshold:
|
|
602
|
+
threshold: z2.enum([
|
|
604
603
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
605
604
|
"BLOCK_LOW_AND_ABOVE",
|
|
606
605
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -610,7 +609,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
610
609
|
])
|
|
611
610
|
})
|
|
612
611
|
).optional(),
|
|
613
|
-
threshold:
|
|
612
|
+
threshold: z2.enum([
|
|
614
613
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
615
614
|
"BLOCK_LOW_AND_ABOVE",
|
|
616
615
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -623,19 +622,19 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
623
622
|
*
|
|
624
623
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
625
624
|
*/
|
|
626
|
-
audioTimestamp:
|
|
625
|
+
audioTimestamp: z2.boolean().optional(),
|
|
627
626
|
/**
|
|
628
627
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
629
628
|
*
|
|
630
629
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
631
630
|
*/
|
|
632
|
-
labels:
|
|
631
|
+
labels: z2.record(z2.string(), z2.string()).optional(),
|
|
633
632
|
/**
|
|
634
633
|
* Optional. If specified, the media resolution specified will be used.
|
|
635
634
|
*
|
|
636
635
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
637
636
|
*/
|
|
638
|
-
mediaResolution:
|
|
637
|
+
mediaResolution: z2.enum([
|
|
639
638
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
640
639
|
"MEDIA_RESOLUTION_LOW",
|
|
641
640
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -646,8 +645,8 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
646
645
|
*
|
|
647
646
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
648
647
|
*/
|
|
649
|
-
imageConfig:
|
|
650
|
-
aspectRatio:
|
|
648
|
+
imageConfig: z2.object({
|
|
649
|
+
aspectRatio: z2.enum([
|
|
651
650
|
"1:1",
|
|
652
651
|
"2:3",
|
|
653
652
|
"3:2",
|
|
@@ -663,7 +662,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
663
662
|
"1:4",
|
|
664
663
|
"4:1"
|
|
665
664
|
]).optional(),
|
|
666
|
-
imageSize:
|
|
665
|
+
imageSize: z2.enum(["1K", "2K", "4K", "512"]).optional()
|
|
667
666
|
}).optional(),
|
|
668
667
|
/**
|
|
669
668
|
* Optional. Configuration for grounding retrieval.
|
|
@@ -671,10 +670,10 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
671
670
|
*
|
|
672
671
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
673
672
|
*/
|
|
674
|
-
retrievalConfig:
|
|
675
|
-
latLng:
|
|
676
|
-
latitude:
|
|
677
|
-
longitude:
|
|
673
|
+
retrievalConfig: z2.object({
|
|
674
|
+
latLng: z2.object({
|
|
675
|
+
latitude: z2.number(),
|
|
676
|
+
longitude: z2.number()
|
|
678
677
|
}).optional()
|
|
679
678
|
}).optional(),
|
|
680
679
|
/**
|
|
@@ -687,11 +686,11 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
687
686
|
*
|
|
688
687
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
689
688
|
*/
|
|
690
|
-
streamFunctionCallArguments:
|
|
689
|
+
streamFunctionCallArguments: z2.boolean().optional(),
|
|
691
690
|
/**
|
|
692
691
|
* Optional. The service tier to use for the request.
|
|
693
692
|
*/
|
|
694
|
-
serviceTier:
|
|
693
|
+
serviceTier: z2.enum(["standard", "flex", "priority"]).optional()
|
|
695
694
|
})
|
|
696
695
|
)
|
|
697
696
|
);
|
|
@@ -702,7 +701,9 @@ var VertexServiceTierMap = {
|
|
|
702
701
|
};
|
|
703
702
|
|
|
704
703
|
// src/google-prepare-tools.ts
|
|
705
|
-
|
|
704
|
+
import {
|
|
705
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
706
|
+
} from "@ai-sdk/provider";
|
|
706
707
|
function prepareTools({
|
|
707
708
|
tools,
|
|
708
709
|
toolChoice,
|
|
@@ -944,7 +945,7 @@ function prepareTools({
|
|
|
944
945
|
};
|
|
945
946
|
default: {
|
|
946
947
|
const _exhaustiveCheck = type;
|
|
947
|
-
throw new
|
|
948
|
+
throw new UnsupportedFunctionalityError2({
|
|
948
949
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
949
950
|
});
|
|
950
951
|
}
|
|
@@ -1201,13 +1202,22 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1201
1202
|
}
|
|
1202
1203
|
|
|
1203
1204
|
// src/google-generative-ai-language-model.ts
|
|
1204
|
-
var GoogleGenerativeAILanguageModel = class {
|
|
1205
|
+
var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
1205
1206
|
constructor(modelId, config) {
|
|
1206
1207
|
this.specificationVersion = "v4";
|
|
1207
1208
|
var _a;
|
|
1208
1209
|
this.modelId = modelId;
|
|
1209
1210
|
this.config = config;
|
|
1210
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1211
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
1212
|
+
}
|
|
1213
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
1214
|
+
return serializeModelOptions({
|
|
1215
|
+
modelId: model.modelId,
|
|
1216
|
+
config: model.config
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
1220
|
+
return new _GoogleGenerativeAILanguageModel(options.modelId, options.config);
|
|
1211
1221
|
}
|
|
1212
1222
|
get provider() {
|
|
1213
1223
|
return this.config.provider;
|
|
@@ -1235,13 +1245,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1235
1245
|
var _a, _b;
|
|
1236
1246
|
const warnings = [];
|
|
1237
1247
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1238
|
-
let googleOptions = await
|
|
1248
|
+
let googleOptions = await parseProviderOptions({
|
|
1239
1249
|
provider: providerOptionsName,
|
|
1240
1250
|
providerOptions,
|
|
1241
1251
|
schema: googleLanguageModelOptions
|
|
1242
1252
|
});
|
|
1243
1253
|
if (googleOptions == null && providerOptionsName !== "google") {
|
|
1244
|
-
googleOptions = await
|
|
1254
|
+
googleOptions = await parseProviderOptions({
|
|
1245
1255
|
provider: "google",
|
|
1246
1256
|
providerOptions,
|
|
1247
1257
|
schema: googleLanguageModelOptions
|
|
@@ -1351,22 +1361,22 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1351
1361
|
async doGenerate(options) {
|
|
1352
1362
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1353
1363
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1354
|
-
const mergedHeaders =
|
|
1355
|
-
await
|
|
1364
|
+
const mergedHeaders = combineHeaders(
|
|
1365
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1356
1366
|
options.headers
|
|
1357
1367
|
);
|
|
1358
1368
|
const {
|
|
1359
1369
|
responseHeaders,
|
|
1360
1370
|
value: response,
|
|
1361
1371
|
rawValue: rawResponse
|
|
1362
|
-
} = await
|
|
1372
|
+
} = await postJsonToApi({
|
|
1363
1373
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1364
1374
|
this.modelId
|
|
1365
1375
|
)}:generateContent`,
|
|
1366
1376
|
headers: mergedHeaders,
|
|
1367
1377
|
body: args,
|
|
1368
1378
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1369
|
-
successfulResponseHandler:
|
|
1379
|
+
successfulResponseHandler: createJsonResponseHandler(responseSchema),
|
|
1370
1380
|
abortSignal: options.abortSignal,
|
|
1371
1381
|
fetch: this.config.fetch
|
|
1372
1382
|
});
|
|
@@ -1533,18 +1543,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1533
1543
|
options,
|
|
1534
1544
|
{ isStreaming: true }
|
|
1535
1545
|
);
|
|
1536
|
-
const headers =
|
|
1537
|
-
await
|
|
1546
|
+
const headers = combineHeaders(
|
|
1547
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1538
1548
|
options.headers
|
|
1539
1549
|
);
|
|
1540
|
-
const { responseHeaders, value: response } = await
|
|
1550
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
1541
1551
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1542
1552
|
this.modelId
|
|
1543
1553
|
)}:streamGenerateContent?alt=sse`,
|
|
1544
1554
|
headers,
|
|
1545
1555
|
body: args,
|
|
1546
1556
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1547
|
-
successfulResponseHandler:
|
|
1557
|
+
successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
|
|
1548
1558
|
abortSignal: options.abortSignal,
|
|
1549
1559
|
fetch: this.config.fetch
|
|
1550
1560
|
});
|
|
@@ -1940,7 +1950,7 @@ function resolveThinkingConfig({
|
|
|
1940
1950
|
modelId,
|
|
1941
1951
|
warnings
|
|
1942
1952
|
}) {
|
|
1943
|
-
if (!
|
|
1953
|
+
if (!isCustomReasoning(reasoning)) {
|
|
1944
1954
|
return void 0;
|
|
1945
1955
|
}
|
|
1946
1956
|
if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
|
|
@@ -1955,7 +1965,7 @@ function resolveGemini3ThinkingConfig({
|
|
|
1955
1965
|
if (reasoning === "none") {
|
|
1956
1966
|
return { thinkingLevel: "minimal" };
|
|
1957
1967
|
}
|
|
1958
|
-
const thinkingLevel =
|
|
1968
|
+
const thinkingLevel = mapReasoningToProviderEffort({
|
|
1959
1969
|
reasoning,
|
|
1960
1970
|
effortMap: {
|
|
1961
1971
|
minimal: "minimal",
|
|
@@ -1979,7 +1989,7 @@ function resolveGemini25ThinkingConfig({
|
|
|
1979
1989
|
if (reasoning === "none") {
|
|
1980
1990
|
return { thinkingBudget: 0 };
|
|
1981
1991
|
}
|
|
1982
|
-
const thinkingBudget =
|
|
1992
|
+
const thinkingBudget = mapReasoningToProviderBudget({
|
|
1983
1993
|
reasoning,
|
|
1984
1994
|
maxOutputTokens: getMaxOutputTokensForGemini25Model(),
|
|
1985
1995
|
maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
|
|
@@ -2085,270 +2095,286 @@ function extractSources({
|
|
|
2085
2095
|
}
|
|
2086
2096
|
return sources.length > 0 ? sources : void 0;
|
|
2087
2097
|
}
|
|
2088
|
-
var getGroundingMetadataSchema = () =>
|
|
2089
|
-
webSearchQueries:
|
|
2090
|
-
imageSearchQueries:
|
|
2091
|
-
retrievalQueries:
|
|
2092
|
-
searchEntryPoint:
|
|
2093
|
-
groundingChunks:
|
|
2094
|
-
|
|
2095
|
-
web:
|
|
2096
|
-
image:
|
|
2097
|
-
sourceUri:
|
|
2098
|
-
imageUri:
|
|
2099
|
-
title:
|
|
2100
|
-
domain:
|
|
2098
|
+
var getGroundingMetadataSchema = () => z3.object({
|
|
2099
|
+
webSearchQueries: z3.array(z3.string()).nullish(),
|
|
2100
|
+
imageSearchQueries: z3.array(z3.string()).nullish(),
|
|
2101
|
+
retrievalQueries: z3.array(z3.string()).nullish(),
|
|
2102
|
+
searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
|
|
2103
|
+
groundingChunks: z3.array(
|
|
2104
|
+
z3.object({
|
|
2105
|
+
web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(),
|
|
2106
|
+
image: z3.object({
|
|
2107
|
+
sourceUri: z3.string(),
|
|
2108
|
+
imageUri: z3.string(),
|
|
2109
|
+
title: z3.string().nullish(),
|
|
2110
|
+
domain: z3.string().nullish()
|
|
2101
2111
|
}).nullish(),
|
|
2102
|
-
retrievedContext:
|
|
2103
|
-
uri:
|
|
2104
|
-
title:
|
|
2105
|
-
text:
|
|
2106
|
-
fileSearchStore:
|
|
2112
|
+
retrievedContext: z3.object({
|
|
2113
|
+
uri: z3.string().nullish(),
|
|
2114
|
+
title: z3.string().nullish(),
|
|
2115
|
+
text: z3.string().nullish(),
|
|
2116
|
+
fileSearchStore: z3.string().nullish()
|
|
2107
2117
|
}).nullish(),
|
|
2108
|
-
maps:
|
|
2109
|
-
uri:
|
|
2110
|
-
title:
|
|
2111
|
-
text:
|
|
2112
|
-
placeId:
|
|
2118
|
+
maps: z3.object({
|
|
2119
|
+
uri: z3.string().nullish(),
|
|
2120
|
+
title: z3.string().nullish(),
|
|
2121
|
+
text: z3.string().nullish(),
|
|
2122
|
+
placeId: z3.string().nullish()
|
|
2113
2123
|
}).nullish()
|
|
2114
2124
|
})
|
|
2115
2125
|
).nullish(),
|
|
2116
|
-
groundingSupports:
|
|
2117
|
-
|
|
2118
|
-
segment:
|
|
2119
|
-
startIndex:
|
|
2120
|
-
endIndex:
|
|
2121
|
-
text:
|
|
2126
|
+
groundingSupports: z3.array(
|
|
2127
|
+
z3.object({
|
|
2128
|
+
segment: z3.object({
|
|
2129
|
+
startIndex: z3.number().nullish(),
|
|
2130
|
+
endIndex: z3.number().nullish(),
|
|
2131
|
+
text: z3.string().nullish()
|
|
2122
2132
|
}).nullish(),
|
|
2123
|
-
segment_text:
|
|
2124
|
-
groundingChunkIndices:
|
|
2125
|
-
supportChunkIndices:
|
|
2126
|
-
confidenceScores:
|
|
2127
|
-
confidenceScore:
|
|
2133
|
+
segment_text: z3.string().nullish(),
|
|
2134
|
+
groundingChunkIndices: z3.array(z3.number()).nullish(),
|
|
2135
|
+
supportChunkIndices: z3.array(z3.number()).nullish(),
|
|
2136
|
+
confidenceScores: z3.array(z3.number()).nullish(),
|
|
2137
|
+
confidenceScore: z3.array(z3.number()).nullish()
|
|
2128
2138
|
})
|
|
2129
2139
|
).nullish(),
|
|
2130
|
-
retrievalMetadata:
|
|
2131
|
-
|
|
2132
|
-
webDynamicRetrievalScore:
|
|
2140
|
+
retrievalMetadata: z3.union([
|
|
2141
|
+
z3.object({
|
|
2142
|
+
webDynamicRetrievalScore: z3.number()
|
|
2133
2143
|
}),
|
|
2134
|
-
|
|
2144
|
+
z3.object({})
|
|
2135
2145
|
]).nullish()
|
|
2136
2146
|
});
|
|
2137
|
-
var partialArgSchema =
|
|
2138
|
-
jsonPath:
|
|
2139
|
-
stringValue:
|
|
2140
|
-
numberValue:
|
|
2141
|
-
boolValue:
|
|
2142
|
-
nullValue:
|
|
2143
|
-
willContinue:
|
|
2147
|
+
var partialArgSchema = z3.object({
|
|
2148
|
+
jsonPath: z3.string(),
|
|
2149
|
+
stringValue: z3.string().nullish(),
|
|
2150
|
+
numberValue: z3.number().nullish(),
|
|
2151
|
+
boolValue: z3.boolean().nullish(),
|
|
2152
|
+
nullValue: z3.unknown().nullish(),
|
|
2153
|
+
willContinue: z3.boolean().nullish()
|
|
2144
2154
|
});
|
|
2145
|
-
var getContentSchema = () =>
|
|
2146
|
-
parts:
|
|
2147
|
-
|
|
2155
|
+
var getContentSchema = () => z3.object({
|
|
2156
|
+
parts: z3.array(
|
|
2157
|
+
z3.union([
|
|
2148
2158
|
// note: order matters since text can be fully empty
|
|
2149
|
-
|
|
2150
|
-
functionCall:
|
|
2151
|
-
name:
|
|
2152
|
-
args:
|
|
2153
|
-
partialArgs:
|
|
2154
|
-
willContinue:
|
|
2159
|
+
z3.object({
|
|
2160
|
+
functionCall: z3.object({
|
|
2161
|
+
name: z3.string().nullish(),
|
|
2162
|
+
args: z3.unknown().nullish(),
|
|
2163
|
+
partialArgs: z3.array(partialArgSchema).nullish(),
|
|
2164
|
+
willContinue: z3.boolean().nullish()
|
|
2155
2165
|
}),
|
|
2156
|
-
thoughtSignature:
|
|
2166
|
+
thoughtSignature: z3.string().nullish()
|
|
2157
2167
|
}),
|
|
2158
|
-
|
|
2159
|
-
inlineData:
|
|
2160
|
-
mimeType:
|
|
2161
|
-
data:
|
|
2168
|
+
z3.object({
|
|
2169
|
+
inlineData: z3.object({
|
|
2170
|
+
mimeType: z3.string(),
|
|
2171
|
+
data: z3.string()
|
|
2162
2172
|
}),
|
|
2163
|
-
thought:
|
|
2164
|
-
thoughtSignature:
|
|
2173
|
+
thought: z3.boolean().nullish(),
|
|
2174
|
+
thoughtSignature: z3.string().nullish()
|
|
2165
2175
|
}),
|
|
2166
|
-
|
|
2167
|
-
toolCall:
|
|
2168
|
-
toolType:
|
|
2169
|
-
args:
|
|
2170
|
-
id:
|
|
2176
|
+
z3.object({
|
|
2177
|
+
toolCall: z3.object({
|
|
2178
|
+
toolType: z3.string(),
|
|
2179
|
+
args: z3.unknown().nullish(),
|
|
2180
|
+
id: z3.string()
|
|
2171
2181
|
}),
|
|
2172
|
-
thoughtSignature:
|
|
2182
|
+
thoughtSignature: z3.string().nullish()
|
|
2173
2183
|
}),
|
|
2174
|
-
|
|
2175
|
-
toolResponse:
|
|
2176
|
-
toolType:
|
|
2177
|
-
response:
|
|
2178
|
-
id:
|
|
2184
|
+
z3.object({
|
|
2185
|
+
toolResponse: z3.object({
|
|
2186
|
+
toolType: z3.string(),
|
|
2187
|
+
response: z3.unknown().nullish(),
|
|
2188
|
+
id: z3.string()
|
|
2179
2189
|
}),
|
|
2180
|
-
thoughtSignature:
|
|
2190
|
+
thoughtSignature: z3.string().nullish()
|
|
2181
2191
|
}),
|
|
2182
|
-
|
|
2183
|
-
executableCode:
|
|
2184
|
-
language:
|
|
2185
|
-
code:
|
|
2192
|
+
z3.object({
|
|
2193
|
+
executableCode: z3.object({
|
|
2194
|
+
language: z3.string(),
|
|
2195
|
+
code: z3.string()
|
|
2186
2196
|
}).nullish(),
|
|
2187
|
-
codeExecutionResult:
|
|
2188
|
-
outcome:
|
|
2189
|
-
output:
|
|
2197
|
+
codeExecutionResult: z3.object({
|
|
2198
|
+
outcome: z3.string(),
|
|
2199
|
+
output: z3.string().nullish()
|
|
2190
2200
|
}).nullish(),
|
|
2191
|
-
text:
|
|
2192
|
-
thought:
|
|
2193
|
-
thoughtSignature:
|
|
2201
|
+
text: z3.string().nullish(),
|
|
2202
|
+
thought: z3.boolean().nullish(),
|
|
2203
|
+
thoughtSignature: z3.string().nullish()
|
|
2194
2204
|
})
|
|
2195
2205
|
])
|
|
2196
2206
|
).nullish()
|
|
2197
2207
|
});
|
|
2198
|
-
var getSafetyRatingSchema = () =>
|
|
2199
|
-
category:
|
|
2200
|
-
probability:
|
|
2201
|
-
probabilityScore:
|
|
2202
|
-
severity:
|
|
2203
|
-
severityScore:
|
|
2204
|
-
blocked:
|
|
2208
|
+
var getSafetyRatingSchema = () => z3.object({
|
|
2209
|
+
category: z3.string().nullish(),
|
|
2210
|
+
probability: z3.string().nullish(),
|
|
2211
|
+
probabilityScore: z3.number().nullish(),
|
|
2212
|
+
severity: z3.string().nullish(),
|
|
2213
|
+
severityScore: z3.number().nullish(),
|
|
2214
|
+
blocked: z3.boolean().nullish()
|
|
2205
2215
|
});
|
|
2206
|
-
var tokenDetailsSchema =
|
|
2207
|
-
|
|
2208
|
-
modality:
|
|
2209
|
-
tokenCount:
|
|
2216
|
+
var tokenDetailsSchema = z3.array(
|
|
2217
|
+
z3.object({
|
|
2218
|
+
modality: z3.string(),
|
|
2219
|
+
tokenCount: z3.number()
|
|
2210
2220
|
})
|
|
2211
2221
|
).nullish();
|
|
2212
|
-
var usageSchema =
|
|
2213
|
-
cachedContentTokenCount:
|
|
2214
|
-
thoughtsTokenCount:
|
|
2215
|
-
promptTokenCount:
|
|
2216
|
-
candidatesTokenCount:
|
|
2217
|
-
totalTokenCount:
|
|
2222
|
+
var usageSchema = z3.object({
|
|
2223
|
+
cachedContentTokenCount: z3.number().nullish(),
|
|
2224
|
+
thoughtsTokenCount: z3.number().nullish(),
|
|
2225
|
+
promptTokenCount: z3.number().nullish(),
|
|
2226
|
+
candidatesTokenCount: z3.number().nullish(),
|
|
2227
|
+
totalTokenCount: z3.number().nullish(),
|
|
2218
2228
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2219
|
-
trafficType:
|
|
2229
|
+
trafficType: z3.string().nullish(),
|
|
2220
2230
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2221
2231
|
promptTokensDetails: tokenDetailsSchema,
|
|
2222
2232
|
candidatesTokensDetails: tokenDetailsSchema
|
|
2223
2233
|
});
|
|
2224
|
-
var getUrlContextMetadataSchema = () =>
|
|
2225
|
-
urlMetadata:
|
|
2226
|
-
|
|
2227
|
-
retrievedUrl:
|
|
2228
|
-
urlRetrievalStatus:
|
|
2234
|
+
var getUrlContextMetadataSchema = () => z3.object({
|
|
2235
|
+
urlMetadata: z3.array(
|
|
2236
|
+
z3.object({
|
|
2237
|
+
retrievedUrl: z3.string(),
|
|
2238
|
+
urlRetrievalStatus: z3.string()
|
|
2229
2239
|
})
|
|
2230
2240
|
).nullish()
|
|
2231
2241
|
});
|
|
2232
|
-
var responseSchema = (
|
|
2233
|
-
() => (
|
|
2234
|
-
|
|
2235
|
-
candidates:
|
|
2236
|
-
|
|
2237
|
-
content: getContentSchema().nullish().or(
|
|
2238
|
-
finishReason:
|
|
2239
|
-
finishMessage:
|
|
2240
|
-
safetyRatings:
|
|
2242
|
+
var responseSchema = lazySchema3(
|
|
2243
|
+
() => zodSchema3(
|
|
2244
|
+
z3.object({
|
|
2245
|
+
candidates: z3.array(
|
|
2246
|
+
z3.object({
|
|
2247
|
+
content: getContentSchema().nullish().or(z3.object({}).strict()),
|
|
2248
|
+
finishReason: z3.string().nullish(),
|
|
2249
|
+
finishMessage: z3.string().nullish(),
|
|
2250
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
|
|
2241
2251
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2242
2252
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2243
2253
|
})
|
|
2244
2254
|
),
|
|
2245
2255
|
usageMetadata: usageSchema.nullish(),
|
|
2246
|
-
promptFeedback:
|
|
2247
|
-
blockReason:
|
|
2248
|
-
safetyRatings:
|
|
2256
|
+
promptFeedback: z3.object({
|
|
2257
|
+
blockReason: z3.string().nullish(),
|
|
2258
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
|
|
2249
2259
|
}).nullish(),
|
|
2250
|
-
serviceTier:
|
|
2260
|
+
serviceTier: z3.string().nullish()
|
|
2251
2261
|
})
|
|
2252
2262
|
)
|
|
2253
2263
|
);
|
|
2254
|
-
var chunkSchema = (
|
|
2255
|
-
() => (
|
|
2256
|
-
|
|
2257
|
-
candidates:
|
|
2258
|
-
|
|
2264
|
+
var chunkSchema = lazySchema3(
|
|
2265
|
+
() => zodSchema3(
|
|
2266
|
+
z3.object({
|
|
2267
|
+
candidates: z3.array(
|
|
2268
|
+
z3.object({
|
|
2259
2269
|
content: getContentSchema().nullish(),
|
|
2260
|
-
finishReason:
|
|
2261
|
-
finishMessage:
|
|
2262
|
-
safetyRatings:
|
|
2270
|
+
finishReason: z3.string().nullish(),
|
|
2271
|
+
finishMessage: z3.string().nullish(),
|
|
2272
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
|
|
2263
2273
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2264
2274
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2265
2275
|
})
|
|
2266
2276
|
).nullish(),
|
|
2267
2277
|
usageMetadata: usageSchema.nullish(),
|
|
2268
|
-
promptFeedback:
|
|
2269
|
-
blockReason:
|
|
2270
|
-
safetyRatings:
|
|
2278
|
+
promptFeedback: z3.object({
|
|
2279
|
+
blockReason: z3.string().nullish(),
|
|
2280
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
|
|
2271
2281
|
}).nullish(),
|
|
2272
|
-
serviceTier:
|
|
2282
|
+
serviceTier: z3.string().nullish()
|
|
2273
2283
|
})
|
|
2274
2284
|
)
|
|
2275
2285
|
);
|
|
2276
2286
|
|
|
2277
2287
|
// src/tool/code-execution.ts
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
var codeExecution =
|
|
2288
|
+
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
2289
|
+
import { z as z4 } from "zod/v4";
|
|
2290
|
+
var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
2281
2291
|
id: "google.code_execution",
|
|
2282
|
-
inputSchema:
|
|
2283
|
-
language:
|
|
2284
|
-
code:
|
|
2292
|
+
inputSchema: z4.object({
|
|
2293
|
+
language: z4.string().describe("The programming language of the code."),
|
|
2294
|
+
code: z4.string().describe("The code to be executed.")
|
|
2285
2295
|
}),
|
|
2286
|
-
outputSchema:
|
|
2287
|
-
outcome:
|
|
2288
|
-
output:
|
|
2296
|
+
outputSchema: z4.object({
|
|
2297
|
+
outcome: z4.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
2298
|
+
output: z4.string().describe("The output from the code execution.")
|
|
2289
2299
|
})
|
|
2290
2300
|
});
|
|
2291
2301
|
|
|
2292
2302
|
// src/tool/enterprise-web-search.ts
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2303
|
+
import {
|
|
2304
|
+
createProviderToolFactory,
|
|
2305
|
+
lazySchema as lazySchema4,
|
|
2306
|
+
zodSchema as zodSchema4
|
|
2307
|
+
} from "@ai-sdk/provider-utils";
|
|
2308
|
+
import { z as z5 } from "zod/v4";
|
|
2309
|
+
var enterpriseWebSearch = createProviderToolFactory({
|
|
2296
2310
|
id: "google.enterprise_web_search",
|
|
2297
|
-
inputSchema: (
|
|
2311
|
+
inputSchema: lazySchema4(() => zodSchema4(z5.object({})))
|
|
2298
2312
|
});
|
|
2299
2313
|
|
|
2300
2314
|
// src/tool/file-search.ts
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2315
|
+
import {
|
|
2316
|
+
createProviderToolFactory as createProviderToolFactory2,
|
|
2317
|
+
lazySchema as lazySchema5,
|
|
2318
|
+
zodSchema as zodSchema5
|
|
2319
|
+
} from "@ai-sdk/provider-utils";
|
|
2320
|
+
import { z as z6 } from "zod/v4";
|
|
2321
|
+
var fileSearchArgsBaseSchema = z6.object({
|
|
2304
2322
|
/** The names of the file_search_stores to retrieve from.
|
|
2305
2323
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
2306
2324
|
*/
|
|
2307
|
-
fileSearchStoreNames:
|
|
2325
|
+
fileSearchStoreNames: z6.array(z6.string()).describe(
|
|
2308
2326
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
2309
2327
|
),
|
|
2310
2328
|
/** The number of file search retrieval chunks to retrieve. */
|
|
2311
|
-
topK:
|
|
2329
|
+
topK: z6.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
2312
2330
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
2313
2331
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
2314
2332
|
*/
|
|
2315
|
-
metadataFilter:
|
|
2333
|
+
metadataFilter: z6.string().describe(
|
|
2316
2334
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2317
2335
|
).optional()
|
|
2318
2336
|
}).passthrough();
|
|
2319
|
-
var fileSearchArgsSchema = (
|
|
2320
|
-
() => (
|
|
2337
|
+
var fileSearchArgsSchema = lazySchema5(
|
|
2338
|
+
() => zodSchema5(fileSearchArgsBaseSchema)
|
|
2321
2339
|
);
|
|
2322
|
-
var fileSearch = (
|
|
2340
|
+
var fileSearch = createProviderToolFactory2({
|
|
2323
2341
|
id: "google.file_search",
|
|
2324
2342
|
inputSchema: fileSearchArgsSchema
|
|
2325
2343
|
});
|
|
2326
2344
|
|
|
2327
2345
|
// src/tool/google-maps.ts
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2346
|
+
import {
|
|
2347
|
+
createProviderToolFactory as createProviderToolFactory3,
|
|
2348
|
+
lazySchema as lazySchema6,
|
|
2349
|
+
zodSchema as zodSchema6
|
|
2350
|
+
} from "@ai-sdk/provider-utils";
|
|
2351
|
+
import { z as z7 } from "zod/v4";
|
|
2352
|
+
var googleMaps = createProviderToolFactory3({
|
|
2331
2353
|
id: "google.google_maps",
|
|
2332
|
-
inputSchema: (
|
|
2354
|
+
inputSchema: lazySchema6(() => zodSchema6(z7.object({})))
|
|
2333
2355
|
});
|
|
2334
2356
|
|
|
2335
2357
|
// src/tool/google-search.ts
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2358
|
+
import {
|
|
2359
|
+
createProviderToolFactory as createProviderToolFactory4,
|
|
2360
|
+
lazySchema as lazySchema7,
|
|
2361
|
+
zodSchema as zodSchema7
|
|
2362
|
+
} from "@ai-sdk/provider-utils";
|
|
2363
|
+
import { z as z8 } from "zod/v4";
|
|
2364
|
+
var googleSearchToolArgsBaseSchema = z8.object({
|
|
2365
|
+
searchTypes: z8.object({
|
|
2366
|
+
webSearch: z8.object({}).optional(),
|
|
2367
|
+
imageSearch: z8.object({}).optional()
|
|
2342
2368
|
}).optional(),
|
|
2343
|
-
timeRangeFilter:
|
|
2344
|
-
startTime:
|
|
2345
|
-
endTime:
|
|
2369
|
+
timeRangeFilter: z8.object({
|
|
2370
|
+
startTime: z8.string(),
|
|
2371
|
+
endTime: z8.string()
|
|
2346
2372
|
}).optional()
|
|
2347
2373
|
}).passthrough();
|
|
2348
|
-
var googleSearchToolArgsSchema = (
|
|
2349
|
-
() => (
|
|
2374
|
+
var googleSearchToolArgsSchema = lazySchema7(
|
|
2375
|
+
() => zodSchema7(googleSearchToolArgsBaseSchema)
|
|
2350
2376
|
);
|
|
2351
|
-
var googleSearch = (
|
|
2377
|
+
var googleSearch = createProviderToolFactory4(
|
|
2352
2378
|
{
|
|
2353
2379
|
id: "google.google_search",
|
|
2354
2380
|
inputSchema: googleSearchToolArgsSchema
|
|
@@ -2356,21 +2382,25 @@ var googleSearch = (0, import_provider_utils9.createProviderToolFactory)(
|
|
|
2356
2382
|
);
|
|
2357
2383
|
|
|
2358
2384
|
// src/tool/url-context.ts
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2385
|
+
import {
|
|
2386
|
+
createProviderToolFactory as createProviderToolFactory5,
|
|
2387
|
+
lazySchema as lazySchema8,
|
|
2388
|
+
zodSchema as zodSchema8
|
|
2389
|
+
} from "@ai-sdk/provider-utils";
|
|
2390
|
+
import { z as z9 } from "zod/v4";
|
|
2391
|
+
var urlContext = createProviderToolFactory5({
|
|
2362
2392
|
id: "google.url_context",
|
|
2363
|
-
inputSchema: (
|
|
2393
|
+
inputSchema: lazySchema8(() => zodSchema8(z9.object({})))
|
|
2364
2394
|
});
|
|
2365
2395
|
|
|
2366
2396
|
// src/tool/vertex-rag-store.ts
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
var vertexRagStore = (
|
|
2397
|
+
import { createProviderToolFactory as createProviderToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2398
|
+
import { z as z10 } from "zod/v4";
|
|
2399
|
+
var vertexRagStore = createProviderToolFactory6({
|
|
2370
2400
|
id: "google.vertex_rag_store",
|
|
2371
|
-
inputSchema:
|
|
2372
|
-
ragCorpus:
|
|
2373
|
-
topK:
|
|
2401
|
+
inputSchema: z10.object({
|
|
2402
|
+
ragCorpus: z10.string(),
|
|
2403
|
+
topK: z10.number().optional()
|
|
2374
2404
|
})
|
|
2375
2405
|
});
|
|
2376
2406
|
|
|
@@ -2433,11 +2463,10 @@ var googleTools = {
|
|
|
2433
2463
|
*/
|
|
2434
2464
|
vertexRagStore
|
|
2435
2465
|
};
|
|
2436
|
-
|
|
2437
|
-
0 && (module.exports = {
|
|
2466
|
+
export {
|
|
2438
2467
|
GoogleGenerativeAILanguageModel,
|
|
2439
2468
|
getGroundingMetadataSchema,
|
|
2440
2469
|
getUrlContextMetadataSchema,
|
|
2441
2470
|
googleTools
|
|
2442
|
-
}
|
|
2471
|
+
};
|
|
2443
2472
|
//# sourceMappingURL=index.js.map
|