@ai-sdk/google 4.0.0-beta.8 → 4.0.0-canary.50
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 +351 -4
- package/README.md +6 -4
- package/dist/index.d.ts +97 -54
- package/dist/index.js +1644 -580
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +66 -26
- package/dist/internal/index.js +1258 -450
- package/dist/internal/index.js.map +1 -1
- package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +46 -40
- package/package.json +13 -14
- package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +12 -5
- package/src/convert-json-schema-to-openapi-schema.ts +1 -1
- package/src/convert-to-google-messages.ts +577 -0
- package/src/{google-generative-ai-embedding-options.ts → google-embedding-model-options.ts} +2 -2
- package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +31 -18
- package/src/google-error.ts +1 -1
- package/src/google-files.ts +225 -0
- package/src/google-image-model-options.ts +23 -0
- package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +74 -62
- package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
- package/src/google-json-accumulator.ts +336 -0
- package/src/{google-generative-ai-options.ts → google-language-model-options.ts} +32 -5
- package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +609 -214
- package/src/google-prepare-tools.ts +72 -12
- package/src/google-prompt.ts +82 -0
- package/src/google-provider.ts +63 -54
- package/src/google-video-model-options.ts +43 -0
- package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +17 -56
- package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +2 -1
- package/src/index.ts +28 -9
- package/src/internal/index.ts +2 -2
- package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +3 -3
- package/src/tool/code-execution.ts +2 -2
- package/src/tool/enterprise-web-search.ts +9 -3
- package/src/tool/file-search.ts +5 -7
- package/src/tool/google-maps.ts +3 -2
- package/src/tool/google-search.ts +10 -11
- package/src/tool/url-context.ts +4 -2
- package/src/tool/vertex-rag-store.ts +9 -6
- package/dist/index.d.mts +0 -384
- package/dist/index.mjs +0 -2519
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -287
- package/dist/internal/index.mjs +0 -1708
- package/dist/internal/index.mjs.map +0 -1
- package/src/convert-to-google-generative-ai-messages.ts +0 -239
- package/src/google-generative-ai-prompt.ts +0 -47
package/dist/internal/index.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// src/internal/index.ts
|
|
21
|
-
var internal_exports = {};
|
|
22
|
-
__export(internal_exports, {
|
|
23
|
-
GoogleGenerativeAILanguageModel: () => GoogleGenerativeAILanguageModel,
|
|
24
|
-
getGroundingMetadataSchema: () => getGroundingMetadataSchema,
|
|
25
|
-
getUrlContextMetadataSchema: () => getUrlContextMetadataSchema,
|
|
26
|
-
googleTools: () => googleTools
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(internal_exports);
|
|
1
|
+
// src/google-language-model.ts
|
|
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";
|
|
29
20
|
|
|
30
|
-
// src/google-
|
|
31
|
-
|
|
32
|
-
var import_v43 = require("zod/v4");
|
|
33
|
-
|
|
34
|
-
// src/convert-google-generative-ai-usage.ts
|
|
35
|
-
function convertGoogleGenerativeAIUsage(usage) {
|
|
21
|
+
// src/convert-google-usage.ts
|
|
22
|
+
function convertGoogleUsage(usage) {
|
|
36
23
|
var _a, _b, _c, _d;
|
|
37
24
|
if (usage == null) {
|
|
38
25
|
return {
|
|
@@ -186,21 +173,147 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
186
173
|
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
187
174
|
}
|
|
188
175
|
|
|
189
|
-
// src/convert-to-google-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
// src/convert-to-google-messages.ts
|
|
177
|
+
import {
|
|
178
|
+
UnsupportedFunctionalityError
|
|
179
|
+
} from "@ai-sdk/provider";
|
|
180
|
+
import {
|
|
181
|
+
convertToBase64,
|
|
182
|
+
isFullMediaType,
|
|
183
|
+
resolveFullMediaType,
|
|
184
|
+
resolveProviderReference
|
|
185
|
+
} from "@ai-sdk/provider-utils";
|
|
186
|
+
var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
|
|
187
|
+
function parseBase64DataUrl(value) {
|
|
188
|
+
const match = dataUrlRegex.exec(value);
|
|
189
|
+
if (match == null) {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
mediaType: match[1],
|
|
194
|
+
data: match[2]
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function convertUrlToolResultPart(url) {
|
|
198
|
+
const parsedDataUrl = parseBase64DataUrl(url);
|
|
199
|
+
if (parsedDataUrl == null) {
|
|
200
|
+
return void 0;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
inlineData: {
|
|
204
|
+
mimeType: parsedDataUrl.mediaType,
|
|
205
|
+
data: parsedDataUrl.data
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function appendToolResultParts(parts, toolName, outputValue) {
|
|
210
|
+
const functionResponseParts = [];
|
|
211
|
+
const responseTextParts = [];
|
|
212
|
+
for (const contentPart of outputValue) {
|
|
213
|
+
switch (contentPart.type) {
|
|
214
|
+
case "text": {
|
|
215
|
+
responseTextParts.push(contentPart.text);
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case "file-data": {
|
|
219
|
+
functionResponseParts.push({
|
|
220
|
+
inlineData: {
|
|
221
|
+
mimeType: contentPart.mediaType,
|
|
222
|
+
data: contentPart.data
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case "file-url": {
|
|
228
|
+
const functionResponsePart = convertUrlToolResultPart(
|
|
229
|
+
contentPart.url
|
|
230
|
+
);
|
|
231
|
+
if (functionResponsePart != null) {
|
|
232
|
+
functionResponseParts.push(functionResponsePart);
|
|
233
|
+
} else {
|
|
234
|
+
responseTextParts.push(JSON.stringify(contentPart));
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
default: {
|
|
239
|
+
responseTextParts.push(JSON.stringify(contentPart));
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
parts.push({
|
|
245
|
+
functionResponse: {
|
|
246
|
+
name: toolName,
|
|
247
|
+
response: {
|
|
248
|
+
name: toolName,
|
|
249
|
+
content: responseTextParts.length > 0 ? responseTextParts.join("\n") : "Tool executed successfully."
|
|
250
|
+
},
|
|
251
|
+
...functionResponseParts.length > 0 ? { parts: functionResponseParts } : {}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function appendLegacyToolResultParts(parts, toolName, outputValue) {
|
|
256
|
+
for (const contentPart of outputValue) {
|
|
257
|
+
switch (contentPart.type) {
|
|
258
|
+
case "text":
|
|
259
|
+
parts.push({
|
|
260
|
+
functionResponse: {
|
|
261
|
+
name: toolName,
|
|
262
|
+
response: {
|
|
263
|
+
name: toolName,
|
|
264
|
+
content: contentPart.text
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
break;
|
|
269
|
+
case "file-data":
|
|
270
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
271
|
+
parts.push(
|
|
272
|
+
{
|
|
273
|
+
inlineData: {
|
|
274
|
+
mimeType: contentPart.mediaType,
|
|
275
|
+
data: contentPart.data
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
text: "Tool executed successfully and returned this image as a response"
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
} else {
|
|
283
|
+
parts.push({ text: JSON.stringify(contentPart) });
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
default:
|
|
287
|
+
parts.push({ text: JSON.stringify(contentPart) });
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function convertToGoogleMessages(prompt, options) {
|
|
293
|
+
var _a, _b, _c, _d;
|
|
194
294
|
const systemInstructionParts = [];
|
|
195
295
|
const contents = [];
|
|
196
296
|
let systemMessagesAllowed = true;
|
|
197
297
|
const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
|
|
198
|
-
const
|
|
298
|
+
const providerOptionsNames = (_b = options == null ? void 0 : options.providerOptionsNames) != null ? _b : ["google"];
|
|
299
|
+
const isVertexLike = !providerOptionsNames.includes("google");
|
|
300
|
+
const supportsFunctionResponseParts = (_c = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _c : true;
|
|
301
|
+
const readProviderOpts = (part) => {
|
|
302
|
+
var _a2, _b2, _c2, _d2, _e;
|
|
303
|
+
for (const name of providerOptionsNames) {
|
|
304
|
+
const v = (_a2 = part.providerOptions) == null ? void 0 : _a2[name];
|
|
305
|
+
if (v != null) return v;
|
|
306
|
+
}
|
|
307
|
+
if (isVertexLike) {
|
|
308
|
+
return (_b2 = part.providerOptions) == null ? void 0 : _b2.google;
|
|
309
|
+
}
|
|
310
|
+
return (_e = (_c2 = part.providerOptions) == null ? void 0 : _c2.googleVertex) != null ? _e : (_d2 = part.providerOptions) == null ? void 0 : _d2.vertex;
|
|
311
|
+
};
|
|
199
312
|
for (const { role, content } of prompt) {
|
|
200
313
|
switch (role) {
|
|
201
314
|
case "system": {
|
|
202
315
|
if (!systemMessagesAllowed) {
|
|
203
|
-
throw new
|
|
316
|
+
throw new UnsupportedFunctionalityError({
|
|
204
317
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
205
318
|
});
|
|
206
319
|
}
|
|
@@ -217,20 +330,54 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
217
330
|
break;
|
|
218
331
|
}
|
|
219
332
|
case "file": {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
333
|
+
switch (part.data.type) {
|
|
334
|
+
case "url": {
|
|
335
|
+
parts.push({
|
|
336
|
+
fileData: {
|
|
337
|
+
mimeType: resolveFullMediaType({ part }),
|
|
338
|
+
fileUri: part.data.url.toString()
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
case "reference": {
|
|
344
|
+
if (isVertexLike) {
|
|
345
|
+
throw new UnsupportedFunctionalityError({
|
|
346
|
+
functionality: "file parts with provider references"
|
|
347
|
+
});
|
|
231
348
|
}
|
|
349
|
+
parts.push({
|
|
350
|
+
fileData: {
|
|
351
|
+
mimeType: resolveFullMediaType({ part }),
|
|
352
|
+
fileUri: resolveProviderReference({
|
|
353
|
+
reference: part.data.reference,
|
|
354
|
+
provider: "google"
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "text": {
|
|
361
|
+
parts.push({
|
|
362
|
+
inlineData: {
|
|
363
|
+
mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
|
|
364
|
+
data: convertToBase64(
|
|
365
|
+
new TextEncoder().encode(part.data.text)
|
|
366
|
+
)
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
break;
|
|
232
370
|
}
|
|
233
|
-
|
|
371
|
+
case "data": {
|
|
372
|
+
parts.push({
|
|
373
|
+
inlineData: {
|
|
374
|
+
mimeType: resolveFullMediaType({ part }),
|
|
375
|
+
data: convertToBase64(part.data.data)
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
234
381
|
break;
|
|
235
382
|
}
|
|
236
383
|
}
|
|
@@ -243,8 +390,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
243
390
|
contents.push({
|
|
244
391
|
role: "model",
|
|
245
392
|
parts: content.map((part) => {
|
|
246
|
-
|
|
247
|
-
const providerOpts = (_d = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) != null ? _d : providerOptionsName !== "google" ? (_b2 = part.providerOptions) == null ? void 0 : _b2.google : (_c2 = part.providerOptions) == null ? void 0 : _c2.vertex;
|
|
393
|
+
const providerOpts = readProviderOpts(part);
|
|
248
394
|
const thoughtSignature = (providerOpts == null ? void 0 : providerOpts.thoughtSignature) != null ? String(providerOpts.thoughtSignature) : void 0;
|
|
249
395
|
switch (part.type) {
|
|
250
396
|
case "text": {
|
|
@@ -260,22 +406,89 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
260
406
|
thoughtSignature
|
|
261
407
|
};
|
|
262
408
|
}
|
|
409
|
+
case "reasoning-file": {
|
|
410
|
+
switch (part.data.type) {
|
|
411
|
+
case "url": {
|
|
412
|
+
throw new UnsupportedFunctionalityError({
|
|
413
|
+
functionality: "File data URLs in assistant messages are not supported"
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
case "data": {
|
|
417
|
+
return {
|
|
418
|
+
inlineData: {
|
|
419
|
+
mimeType: part.mediaType,
|
|
420
|
+
data: convertToBase64(part.data.data)
|
|
421
|
+
},
|
|
422
|
+
thought: true,
|
|
423
|
+
thoughtSignature
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
263
429
|
case "file": {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
430
|
+
switch (part.data.type) {
|
|
431
|
+
case "url": {
|
|
432
|
+
throw new UnsupportedFunctionalityError({
|
|
433
|
+
functionality: "File data URLs in assistant messages are not supported"
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
case "reference": {
|
|
437
|
+
if (isVertexLike) {
|
|
438
|
+
throw new UnsupportedFunctionalityError({
|
|
439
|
+
functionality: "file parts with provider references"
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
fileData: {
|
|
444
|
+
mimeType: part.mediaType,
|
|
445
|
+
fileUri: resolveProviderReference({
|
|
446
|
+
reference: part.data.reference,
|
|
447
|
+
provider: "google"
|
|
448
|
+
})
|
|
449
|
+
},
|
|
450
|
+
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
451
|
+
thoughtSignature
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
case "text": {
|
|
455
|
+
return {
|
|
456
|
+
inlineData: {
|
|
457
|
+
mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
|
|
458
|
+
data: convertToBase64(
|
|
459
|
+
new TextEncoder().encode(part.data.text)
|
|
460
|
+
)
|
|
461
|
+
},
|
|
462
|
+
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
463
|
+
thoughtSignature
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
case "data": {
|
|
467
|
+
return {
|
|
468
|
+
inlineData: {
|
|
469
|
+
mimeType: part.mediaType,
|
|
470
|
+
data: convertToBase64(part.data.data)
|
|
471
|
+
},
|
|
472
|
+
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
473
|
+
thoughtSignature
|
|
474
|
+
};
|
|
475
|
+
}
|
|
268
476
|
}
|
|
269
|
-
|
|
270
|
-
inlineData: {
|
|
271
|
-
mimeType: part.mediaType,
|
|
272
|
-
data: (0, import_provider_utils.convertToBase64)(part.data)
|
|
273
|
-
},
|
|
274
|
-
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
275
|
-
thoughtSignature
|
|
276
|
-
};
|
|
477
|
+
break;
|
|
277
478
|
}
|
|
278
479
|
case "tool-call": {
|
|
480
|
+
const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
481
|
+
const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
|
|
482
|
+
if (serverToolCallId && serverToolType) {
|
|
483
|
+
return {
|
|
484
|
+
toolCall: {
|
|
485
|
+
toolType: serverToolType,
|
|
486
|
+
args: typeof part.input === "string" ? JSON.parse(part.input) : part.input,
|
|
487
|
+
id: serverToolCallId
|
|
488
|
+
},
|
|
489
|
+
thoughtSignature
|
|
490
|
+
};
|
|
491
|
+
}
|
|
279
492
|
return {
|
|
280
493
|
functionCall: {
|
|
281
494
|
name: part.toolName,
|
|
@@ -284,6 +497,21 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
284
497
|
thoughtSignature
|
|
285
498
|
};
|
|
286
499
|
}
|
|
500
|
+
case "tool-result": {
|
|
501
|
+
const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
502
|
+
const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
|
|
503
|
+
if (serverToolCallId && serverToolType) {
|
|
504
|
+
return {
|
|
505
|
+
toolResponse: {
|
|
506
|
+
toolType: serverToolType,
|
|
507
|
+
response: part.output.type === "json" ? part.output.value : {},
|
|
508
|
+
id: serverToolCallId
|
|
509
|
+
},
|
|
510
|
+
thoughtSignature
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
return void 0;
|
|
514
|
+
}
|
|
287
515
|
}
|
|
288
516
|
}).filter((part) => part !== void 0)
|
|
289
517
|
});
|
|
@@ -296,38 +524,32 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
296
524
|
if (part.type === "tool-approval-response") {
|
|
297
525
|
continue;
|
|
298
526
|
}
|
|
527
|
+
const partProviderOpts = readProviderOpts(part);
|
|
528
|
+
const serverToolCallId = (partProviderOpts == null ? void 0 : partProviderOpts.serverToolCallId) != null ? String(partProviderOpts.serverToolCallId) : void 0;
|
|
529
|
+
const serverToolType = (partProviderOpts == null ? void 0 : partProviderOpts.serverToolType) != null ? String(partProviderOpts.serverToolType) : void 0;
|
|
530
|
+
if (serverToolCallId && serverToolType) {
|
|
531
|
+
const serverThoughtSignature = (partProviderOpts == null ? void 0 : partProviderOpts.thoughtSignature) != null ? String(partProviderOpts.thoughtSignature) : void 0;
|
|
532
|
+
if (contents.length > 0) {
|
|
533
|
+
const lastContent = contents[contents.length - 1];
|
|
534
|
+
if (lastContent.role === "model") {
|
|
535
|
+
lastContent.parts.push({
|
|
536
|
+
toolResponse: {
|
|
537
|
+
toolType: serverToolType,
|
|
538
|
+
response: part.output.type === "json" ? part.output.value : {},
|
|
539
|
+
id: serverToolCallId
|
|
540
|
+
},
|
|
541
|
+
thoughtSignature: serverThoughtSignature
|
|
542
|
+
});
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
299
547
|
const output = part.output;
|
|
300
548
|
if (output.type === "content") {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
functionResponse: {
|
|
306
|
-
name: part.toolName,
|
|
307
|
-
response: {
|
|
308
|
-
name: part.toolName,
|
|
309
|
-
content: contentPart.text
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
break;
|
|
314
|
-
case "image-data":
|
|
315
|
-
parts.push(
|
|
316
|
-
{
|
|
317
|
-
inlineData: {
|
|
318
|
-
mimeType: contentPart.mediaType,
|
|
319
|
-
data: contentPart.data
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
text: "Tool executed successfully and returned this image as a response"
|
|
324
|
-
}
|
|
325
|
-
);
|
|
326
|
-
break;
|
|
327
|
-
default:
|
|
328
|
-
parts.push({ text: JSON.stringify(contentPart) });
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
549
|
+
if (supportsFunctionResponseParts) {
|
|
550
|
+
appendToolResultParts(parts, part.toolName, output.value);
|
|
551
|
+
} else {
|
|
552
|
+
appendLegacyToolResultParts(parts, part.toolName, output.value);
|
|
331
553
|
}
|
|
332
554
|
} else {
|
|
333
555
|
parts.push({
|
|
@@ -335,7 +557,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
335
557
|
name: part.toolName,
|
|
336
558
|
response: {
|
|
337
559
|
name: part.toolName,
|
|
338
|
-
content: output.type === "execution-denied" ? (
|
|
560
|
+
content: output.type === "execution-denied" ? (_d = output.reason) != null ? _d : "Tool call execution denied." : output.value
|
|
339
561
|
}
|
|
340
562
|
}
|
|
341
563
|
});
|
|
@@ -365,58 +587,65 @@ function getModelPath(modelId) {
|
|
|
365
587
|
}
|
|
366
588
|
|
|
367
589
|
// src/google-error.ts
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
590
|
+
import {
|
|
591
|
+
createJsonErrorResponseHandler,
|
|
592
|
+
lazySchema,
|
|
593
|
+
zodSchema
|
|
594
|
+
} from "@ai-sdk/provider-utils";
|
|
595
|
+
import { z } from "zod/v4";
|
|
596
|
+
var googleErrorDataSchema = lazySchema(
|
|
597
|
+
() => zodSchema(
|
|
598
|
+
z.object({
|
|
599
|
+
error: z.object({
|
|
600
|
+
code: z.number().nullable(),
|
|
601
|
+
message: z.string(),
|
|
602
|
+
status: z.string()
|
|
377
603
|
})
|
|
378
604
|
})
|
|
379
605
|
)
|
|
380
606
|
);
|
|
381
|
-
var googleFailedResponseHandler =
|
|
607
|
+
var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
382
608
|
errorSchema: googleErrorDataSchema,
|
|
383
609
|
errorToMessage: (data) => data.error.message
|
|
384
610
|
});
|
|
385
611
|
|
|
386
|
-
// src/google-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
612
|
+
// src/google-language-model-options.ts
|
|
613
|
+
import {
|
|
614
|
+
lazySchema as lazySchema2,
|
|
615
|
+
zodSchema as zodSchema2
|
|
616
|
+
} from "@ai-sdk/provider-utils";
|
|
617
|
+
import { z as z2 } from "zod/v4";
|
|
618
|
+
var googleLanguageModelOptions = lazySchema2(
|
|
619
|
+
() => zodSchema2(
|
|
620
|
+
z2.object({
|
|
621
|
+
responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
|
|
622
|
+
thinkingConfig: z2.object({
|
|
623
|
+
thinkingBudget: z2.number().optional(),
|
|
624
|
+
includeThoughts: z2.boolean().optional(),
|
|
396
625
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
397
|
-
thinkingLevel:
|
|
626
|
+
thinkingLevel: z2.enum(["minimal", "low", "medium", "high"]).optional()
|
|
398
627
|
}).optional(),
|
|
399
628
|
/**
|
|
400
629
|
* Optional.
|
|
401
630
|
* The name of the cached content used as context to serve the prediction.
|
|
402
631
|
* Format: cachedContents/{cachedContent}
|
|
403
632
|
*/
|
|
404
|
-
cachedContent:
|
|
633
|
+
cachedContent: z2.string().optional(),
|
|
405
634
|
/**
|
|
406
635
|
* Optional. Enable structured output. Default is true.
|
|
407
636
|
*
|
|
408
637
|
* This is useful when the JSON Schema contains elements that are
|
|
409
638
|
* not supported by the OpenAPI schema version that
|
|
410
|
-
* Google
|
|
639
|
+
* Google uses. You can use this to disable
|
|
411
640
|
* structured outputs if you need to.
|
|
412
641
|
*/
|
|
413
|
-
structuredOutputs:
|
|
642
|
+
structuredOutputs: z2.boolean().optional(),
|
|
414
643
|
/**
|
|
415
644
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
416
645
|
*/
|
|
417
|
-
safetySettings:
|
|
418
|
-
|
|
419
|
-
category:
|
|
646
|
+
safetySettings: z2.array(
|
|
647
|
+
z2.object({
|
|
648
|
+
category: z2.enum([
|
|
420
649
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
421
650
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
422
651
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -424,7 +653,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
424
653
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
425
654
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
426
655
|
]),
|
|
427
|
-
threshold:
|
|
656
|
+
threshold: z2.enum([
|
|
428
657
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
429
658
|
"BLOCK_LOW_AND_ABOVE",
|
|
430
659
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -434,7 +663,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
434
663
|
])
|
|
435
664
|
})
|
|
436
665
|
).optional(),
|
|
437
|
-
threshold:
|
|
666
|
+
threshold: z2.enum([
|
|
438
667
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
439
668
|
"BLOCK_LOW_AND_ABOVE",
|
|
440
669
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -447,19 +676,19 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
447
676
|
*
|
|
448
677
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
449
678
|
*/
|
|
450
|
-
audioTimestamp:
|
|
679
|
+
audioTimestamp: z2.boolean().optional(),
|
|
451
680
|
/**
|
|
452
681
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
453
682
|
*
|
|
454
683
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
455
684
|
*/
|
|
456
|
-
labels:
|
|
685
|
+
labels: z2.record(z2.string(), z2.string()).optional(),
|
|
457
686
|
/**
|
|
458
687
|
* Optional. If specified, the media resolution specified will be used.
|
|
459
688
|
*
|
|
460
689
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
461
690
|
*/
|
|
462
|
-
mediaResolution:
|
|
691
|
+
mediaResolution: z2.enum([
|
|
463
692
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
464
693
|
"MEDIA_RESOLUTION_LOW",
|
|
465
694
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -470,8 +699,8 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
470
699
|
*
|
|
471
700
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
472
701
|
*/
|
|
473
|
-
imageConfig:
|
|
474
|
-
aspectRatio:
|
|
702
|
+
imageConfig: z2.object({
|
|
703
|
+
aspectRatio: z2.enum([
|
|
475
704
|
"1:1",
|
|
476
705
|
"2:3",
|
|
477
706
|
"3:2",
|
|
@@ -487,7 +716,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
487
716
|
"1:4",
|
|
488
717
|
"4:1"
|
|
489
718
|
]).optional(),
|
|
490
|
-
imageSize:
|
|
719
|
+
imageSize: z2.enum(["1K", "2K", "4K", "512"]).optional()
|
|
491
720
|
}).optional(),
|
|
492
721
|
/**
|
|
493
722
|
* Optional. Configuration for grounding retrieval.
|
|
@@ -495,24 +724,47 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
495
724
|
*
|
|
496
725
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
497
726
|
*/
|
|
498
|
-
retrievalConfig:
|
|
499
|
-
latLng:
|
|
500
|
-
latitude:
|
|
501
|
-
longitude:
|
|
727
|
+
retrievalConfig: z2.object({
|
|
728
|
+
latLng: z2.object({
|
|
729
|
+
latitude: z2.number(),
|
|
730
|
+
longitude: z2.number()
|
|
502
731
|
}).optional()
|
|
503
|
-
}).optional()
|
|
732
|
+
}).optional(),
|
|
733
|
+
/**
|
|
734
|
+
* Optional. When set to true, function call arguments will be streamed
|
|
735
|
+
* incrementally via partialArgs in streaming responses. Only supported
|
|
736
|
+
* on the Vertex AI API (not the Gemini API) and only for Gemini 3+
|
|
737
|
+
* models.
|
|
738
|
+
*
|
|
739
|
+
* @default false
|
|
740
|
+
*
|
|
741
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
742
|
+
*/
|
|
743
|
+
streamFunctionCallArguments: z2.boolean().optional(),
|
|
744
|
+
/**
|
|
745
|
+
* Optional. The service tier to use for the request.
|
|
746
|
+
*/
|
|
747
|
+
serviceTier: z2.enum(["standard", "flex", "priority"]).optional()
|
|
504
748
|
})
|
|
505
749
|
)
|
|
506
750
|
);
|
|
751
|
+
var VertexServiceTierMap = {
|
|
752
|
+
standard: "SERVICE_TIER_STANDARD",
|
|
753
|
+
flex: "SERVICE_TIER_FLEX",
|
|
754
|
+
priority: "SERVICE_TIER_PRIORITY"
|
|
755
|
+
};
|
|
507
756
|
|
|
508
757
|
// src/google-prepare-tools.ts
|
|
509
|
-
|
|
758
|
+
import {
|
|
759
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
760
|
+
} from "@ai-sdk/provider";
|
|
510
761
|
function prepareTools({
|
|
511
762
|
tools,
|
|
512
763
|
toolChoice,
|
|
513
|
-
modelId
|
|
764
|
+
modelId,
|
|
765
|
+
isVertexProvider = false
|
|
514
766
|
}) {
|
|
515
|
-
var _a;
|
|
767
|
+
var _a, _b;
|
|
516
768
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
517
769
|
const toolWarnings = [];
|
|
518
770
|
const isLatest = [
|
|
@@ -521,13 +773,14 @@ function prepareTools({
|
|
|
521
773
|
"gemini-pro-latest"
|
|
522
774
|
].some((id) => id === modelId);
|
|
523
775
|
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
776
|
+
const isGemini3orNewer = modelId.includes("gemini-3");
|
|
524
777
|
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
525
778
|
if (tools == null) {
|
|
526
779
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
527
780
|
}
|
|
528
781
|
const hasFunctionTools = tools.some((tool) => tool.type === "function");
|
|
529
782
|
const hasProviderTools = tools.some((tool) => tool.type === "provider");
|
|
530
|
-
if (hasFunctionTools && hasProviderTools) {
|
|
783
|
+
if (hasFunctionTools && hasProviderTools && !isGemini3orNewer) {
|
|
531
784
|
toolWarnings.push({
|
|
532
785
|
type: "unsupported",
|
|
533
786
|
feature: `combination of function and provider-defined tools`
|
|
@@ -578,7 +831,7 @@ function prepareTools({
|
|
|
578
831
|
toolWarnings.push({
|
|
579
832
|
type: "unsupported",
|
|
580
833
|
feature: `provider-defined tool ${tool.id}`,
|
|
581
|
-
details: "The code execution
|
|
834
|
+
details: "The code execution tool is not supported with other Gemini models than Gemini 2."
|
|
582
835
|
});
|
|
583
836
|
}
|
|
584
837
|
break;
|
|
@@ -632,6 +885,47 @@ function prepareTools({
|
|
|
632
885
|
break;
|
|
633
886
|
}
|
|
634
887
|
});
|
|
888
|
+
if (hasFunctionTools && isGemini3orNewer && googleTools2.length > 0) {
|
|
889
|
+
const functionDeclarations2 = [];
|
|
890
|
+
for (const tool of tools) {
|
|
891
|
+
if (tool.type === "function") {
|
|
892
|
+
functionDeclarations2.push({
|
|
893
|
+
name: tool.name,
|
|
894
|
+
description: (_a = tool.description) != null ? _a : "",
|
|
895
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
const combinedToolConfig = {
|
|
900
|
+
functionCallingConfig: { mode: "VALIDATED" },
|
|
901
|
+
...!isVertexProvider && {
|
|
902
|
+
includeServerSideToolInvocations: true
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
if (toolChoice != null) {
|
|
906
|
+
switch (toolChoice.type) {
|
|
907
|
+
case "auto":
|
|
908
|
+
break;
|
|
909
|
+
case "none":
|
|
910
|
+
combinedToolConfig.functionCallingConfig = { mode: "NONE" };
|
|
911
|
+
break;
|
|
912
|
+
case "required":
|
|
913
|
+
combinedToolConfig.functionCallingConfig = { mode: "ANY" };
|
|
914
|
+
break;
|
|
915
|
+
case "tool":
|
|
916
|
+
combinedToolConfig.functionCallingConfig = {
|
|
917
|
+
mode: "ANY",
|
|
918
|
+
allowedFunctionNames: [toolChoice.toolName]
|
|
919
|
+
};
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
tools: [...googleTools2, { functionDeclarations: functionDeclarations2 }],
|
|
925
|
+
toolConfig: combinedToolConfig,
|
|
926
|
+
toolWarnings
|
|
927
|
+
};
|
|
928
|
+
}
|
|
635
929
|
return {
|
|
636
930
|
tools: googleTools2.length > 0 ? googleTools2 : void 0,
|
|
637
931
|
toolConfig: void 0,
|
|
@@ -645,7 +939,7 @@ function prepareTools({
|
|
|
645
939
|
case "function":
|
|
646
940
|
functionDeclarations.push({
|
|
647
941
|
name: tool.name,
|
|
648
|
-
description: (
|
|
942
|
+
description: (_b = tool.description) != null ? _b : "",
|
|
649
943
|
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
650
944
|
});
|
|
651
945
|
if (tool.strict === true) {
|
|
@@ -708,15 +1002,238 @@ function prepareTools({
|
|
|
708
1002
|
};
|
|
709
1003
|
default: {
|
|
710
1004
|
const _exhaustiveCheck = type;
|
|
711
|
-
throw new
|
|
1005
|
+
throw new UnsupportedFunctionalityError2({
|
|
712
1006
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
713
1007
|
});
|
|
714
1008
|
}
|
|
715
1009
|
}
|
|
716
1010
|
}
|
|
717
1011
|
|
|
718
|
-
// src/
|
|
719
|
-
|
|
1012
|
+
// src/google-json-accumulator.ts
|
|
1013
|
+
var GoogleJSONAccumulator = class {
|
|
1014
|
+
constructor() {
|
|
1015
|
+
this.accumulatedArgs = {};
|
|
1016
|
+
this.jsonText = "";
|
|
1017
|
+
/**
|
|
1018
|
+
* Stack representing the currently "open" containers in the JSON output.
|
|
1019
|
+
* Entry 0 is always the root `{` object once the first value is written.
|
|
1020
|
+
*/
|
|
1021
|
+
this.pathStack = [];
|
|
1022
|
+
/**
|
|
1023
|
+
* Whether a string value is currently "open" (willContinue was true),
|
|
1024
|
+
* meaning the closing quote has not yet been emitted.
|
|
1025
|
+
*/
|
|
1026
|
+
this.stringOpen = false;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Input: [{jsonPath:"$.brightness",numberValue:50}]
|
|
1030
|
+
* Output: { currentJSON:{brightness:50}, textDelta:'{"brightness":50' }
|
|
1031
|
+
*/
|
|
1032
|
+
processPartialArgs(partialArgs) {
|
|
1033
|
+
let delta = "";
|
|
1034
|
+
for (const arg of partialArgs) {
|
|
1035
|
+
const rawPath = arg.jsonPath.replace(/^\$\./, "");
|
|
1036
|
+
if (!rawPath) continue;
|
|
1037
|
+
const segments = parsePath(rawPath);
|
|
1038
|
+
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
1039
|
+
const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
|
|
1040
|
+
if (isStringContinuation) {
|
|
1041
|
+
const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
|
|
1042
|
+
setNestedValue(
|
|
1043
|
+
this.accumulatedArgs,
|
|
1044
|
+
segments,
|
|
1045
|
+
existingValue + arg.stringValue
|
|
1046
|
+
);
|
|
1047
|
+
delta += escaped;
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
const resolved = resolvePartialArgValue(arg);
|
|
1051
|
+
if (resolved == null) continue;
|
|
1052
|
+
setNestedValue(this.accumulatedArgs, segments, resolved.value);
|
|
1053
|
+
delta += this.emitNavigationTo(segments, arg, resolved.json);
|
|
1054
|
+
}
|
|
1055
|
+
this.jsonText += delta;
|
|
1056
|
+
return {
|
|
1057
|
+
currentJSON: this.accumulatedArgs,
|
|
1058
|
+
textDelta: delta
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Input: jsonText='{"brightness":50', accumulatedArgs={brightness:50}
|
|
1063
|
+
* Output: { finalJSON:'{"brightness":50}', closingDelta:'}' }
|
|
1064
|
+
*/
|
|
1065
|
+
finalize() {
|
|
1066
|
+
const finalArgs = JSON.stringify(this.accumulatedArgs);
|
|
1067
|
+
const closingDelta = finalArgs.slice(this.jsonText.length);
|
|
1068
|
+
return { finalJSON: finalArgs, closingDelta };
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
|
|
1072
|
+
* Output: '{' (first call) or '' (subsequent calls)
|
|
1073
|
+
*/
|
|
1074
|
+
ensureRoot() {
|
|
1075
|
+
if (this.pathStack.length === 0) {
|
|
1076
|
+
this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
|
|
1077
|
+
return "{";
|
|
1078
|
+
}
|
|
1079
|
+
return "";
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Emits the JSON text fragment needed to navigate from the current open
|
|
1083
|
+
* path to the new leaf at `targetSegments`, then writes the value.
|
|
1084
|
+
*
|
|
1085
|
+
* Input: targetSegments=["recipe","name"], arg={jsonPath:"$.recipe.name",stringValue:"Lasagna"}, valueJson='"Lasagna"'
|
|
1086
|
+
* Output: '{"recipe":{"name":"Lasagna"'
|
|
1087
|
+
*/
|
|
1088
|
+
emitNavigationTo(targetSegments, arg, valueJson) {
|
|
1089
|
+
let fragment = "";
|
|
1090
|
+
if (this.stringOpen) {
|
|
1091
|
+
fragment += '"';
|
|
1092
|
+
this.stringOpen = false;
|
|
1093
|
+
}
|
|
1094
|
+
fragment += this.ensureRoot();
|
|
1095
|
+
const targetContainerSegments = targetSegments.slice(0, -1);
|
|
1096
|
+
const leafSegment = targetSegments[targetSegments.length - 1];
|
|
1097
|
+
const commonDepth = this.findCommonStackDepth(targetContainerSegments);
|
|
1098
|
+
fragment += this.closeDownTo(commonDepth);
|
|
1099
|
+
fragment += this.openDownTo(targetContainerSegments, leafSegment);
|
|
1100
|
+
fragment += this.emitLeaf(leafSegment, arg, valueJson);
|
|
1101
|
+
return fragment;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Returns the stack depth to preserve when navigating to a new target
|
|
1105
|
+
* container path. Always >= 1 (the root is never popped).
|
|
1106
|
+
*
|
|
1107
|
+
* Input: stack=[root,"recipe","ingredients",0], target=["recipe","ingredients",1]
|
|
1108
|
+
* Output: 3 (keep root+"recipe"+"ingredients")
|
|
1109
|
+
*/
|
|
1110
|
+
findCommonStackDepth(targetContainer) {
|
|
1111
|
+
const maxDepth = Math.min(
|
|
1112
|
+
this.pathStack.length - 1,
|
|
1113
|
+
targetContainer.length
|
|
1114
|
+
);
|
|
1115
|
+
let common = 0;
|
|
1116
|
+
for (let i = 0; i < maxDepth; i++) {
|
|
1117
|
+
if (this.pathStack[i + 1].segment === targetContainer[i]) {
|
|
1118
|
+
common++;
|
|
1119
|
+
} else {
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return common + 1;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Closes containers from the current stack depth back down to `targetDepth`.
|
|
1127
|
+
*
|
|
1128
|
+
* Input: this.pathStack=[root,"recipe","ingredients",0], targetDepth=3
|
|
1129
|
+
* Output: '}'
|
|
1130
|
+
*/
|
|
1131
|
+
closeDownTo(targetDepth) {
|
|
1132
|
+
let fragment = "";
|
|
1133
|
+
while (this.pathStack.length > targetDepth) {
|
|
1134
|
+
const entry = this.pathStack.pop();
|
|
1135
|
+
fragment += entry.isArray ? "]" : "}";
|
|
1136
|
+
}
|
|
1137
|
+
return fragment;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Opens containers from the current stack depth down to the full target
|
|
1141
|
+
* container path, emitting opening `{`, `[`, keys, and commas as needed.
|
|
1142
|
+
* `leafSegment` is used to determine if the innermost container is an array.
|
|
1143
|
+
*
|
|
1144
|
+
* Input: this.pathStack=[root], targetContainer=["recipe","ingredients"], leafSegment=0
|
|
1145
|
+
* Output: '"recipe":{"ingredients":['
|
|
1146
|
+
*/
|
|
1147
|
+
openDownTo(targetContainer, leafSegment) {
|
|
1148
|
+
let fragment = "";
|
|
1149
|
+
const startIdx = this.pathStack.length - 1;
|
|
1150
|
+
for (let i = startIdx; i < targetContainer.length; i++) {
|
|
1151
|
+
const seg = targetContainer[i];
|
|
1152
|
+
const parentEntry = this.pathStack[this.pathStack.length - 1];
|
|
1153
|
+
if (parentEntry.childCount > 0) {
|
|
1154
|
+
fragment += ",";
|
|
1155
|
+
}
|
|
1156
|
+
parentEntry.childCount++;
|
|
1157
|
+
if (typeof seg === "string") {
|
|
1158
|
+
fragment += `${JSON.stringify(seg)}:`;
|
|
1159
|
+
}
|
|
1160
|
+
const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
|
|
1161
|
+
const isArray = typeof childSeg === "number";
|
|
1162
|
+
fragment += isArray ? "[" : "{";
|
|
1163
|
+
this.pathStack.push({ segment: seg, isArray, childCount: 0 });
|
|
1164
|
+
}
|
|
1165
|
+
return fragment;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Emits the comma, key, and value for a leaf entry in the current container.
|
|
1169
|
+
*
|
|
1170
|
+
* Input: leafSegment="name", arg={stringValue:"Lasagna"}, valueJson='"Lasagna"'
|
|
1171
|
+
* Output: '"name":"Lasagna"' (or ',"name":"Lasagna"' if container.childCount > 0)
|
|
1172
|
+
*/
|
|
1173
|
+
emitLeaf(leafSegment, arg, valueJson) {
|
|
1174
|
+
let fragment = "";
|
|
1175
|
+
const container = this.pathStack[this.pathStack.length - 1];
|
|
1176
|
+
if (container.childCount > 0) {
|
|
1177
|
+
fragment += ",";
|
|
1178
|
+
}
|
|
1179
|
+
container.childCount++;
|
|
1180
|
+
if (typeof leafSegment === "string") {
|
|
1181
|
+
fragment += `${JSON.stringify(leafSegment)}:`;
|
|
1182
|
+
}
|
|
1183
|
+
if (arg.stringValue != null && arg.willContinue) {
|
|
1184
|
+
fragment += valueJson.slice(0, -1);
|
|
1185
|
+
this.stringOpen = true;
|
|
1186
|
+
} else {
|
|
1187
|
+
fragment += valueJson;
|
|
1188
|
+
}
|
|
1189
|
+
return fragment;
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
function parsePath(rawPath) {
|
|
1193
|
+
const segments = [];
|
|
1194
|
+
for (const part of rawPath.split(".")) {
|
|
1195
|
+
const bracketIdx = part.indexOf("[");
|
|
1196
|
+
if (bracketIdx === -1) {
|
|
1197
|
+
segments.push(part);
|
|
1198
|
+
} else {
|
|
1199
|
+
if (bracketIdx > 0) segments.push(part.slice(0, bracketIdx));
|
|
1200
|
+
for (const m of part.matchAll(/\[(\d+)\]/g)) {
|
|
1201
|
+
segments.push(parseInt(m[1], 10));
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return segments;
|
|
1206
|
+
}
|
|
1207
|
+
function getNestedValue(obj, segments) {
|
|
1208
|
+
let current = obj;
|
|
1209
|
+
for (const seg of segments) {
|
|
1210
|
+
if (current == null || typeof current !== "object") return void 0;
|
|
1211
|
+
current = current[seg];
|
|
1212
|
+
}
|
|
1213
|
+
return current;
|
|
1214
|
+
}
|
|
1215
|
+
function setNestedValue(obj, segments, value) {
|
|
1216
|
+
let current = obj;
|
|
1217
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
1218
|
+
const seg = segments[i];
|
|
1219
|
+
const nextSeg = segments[i + 1];
|
|
1220
|
+
if (current[seg] == null) {
|
|
1221
|
+
current[seg] = typeof nextSeg === "number" ? [] : {};
|
|
1222
|
+
}
|
|
1223
|
+
current = current[seg];
|
|
1224
|
+
}
|
|
1225
|
+
current[segments[segments.length - 1]] = value;
|
|
1226
|
+
}
|
|
1227
|
+
function resolvePartialArgValue(arg) {
|
|
1228
|
+
var _a, _b;
|
|
1229
|
+
const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
|
|
1230
|
+
if (value != null) return { value, json: JSON.stringify(value) };
|
|
1231
|
+
if ("nullValue" in arg) return { value: null, json: "null" };
|
|
1232
|
+
return void 0;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// src/map-google-finish-reason.ts
|
|
1236
|
+
function mapGoogleFinishReason({
|
|
720
1237
|
finishReason,
|
|
721
1238
|
hasToolCalls
|
|
722
1239
|
}) {
|
|
@@ -741,14 +1258,23 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
741
1258
|
}
|
|
742
1259
|
}
|
|
743
1260
|
|
|
744
|
-
// src/google-
|
|
745
|
-
var
|
|
1261
|
+
// src/google-language-model.ts
|
|
1262
|
+
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
746
1263
|
constructor(modelId, config) {
|
|
747
|
-
this.specificationVersion = "
|
|
1264
|
+
this.specificationVersion = "v4";
|
|
748
1265
|
var _a;
|
|
749
1266
|
this.modelId = modelId;
|
|
750
1267
|
this.config = config;
|
|
751
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1268
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
1269
|
+
}
|
|
1270
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
1271
|
+
return serializeModelOptions({
|
|
1272
|
+
modelId: model.modelId,
|
|
1273
|
+
config: model.config
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
1277
|
+
return new _GoogleLanguageModel(options.modelId, options.config);
|
|
752
1278
|
}
|
|
753
1279
|
get provider() {
|
|
754
1280
|
return this.config.provider;
|
|
@@ -770,36 +1296,54 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
770
1296
|
seed,
|
|
771
1297
|
tools,
|
|
772
1298
|
toolChoice,
|
|
1299
|
+
reasoning,
|
|
773
1300
|
providerOptions
|
|
774
|
-
}) {
|
|
775
|
-
var _a;
|
|
1301
|
+
}, { isStreaming = false } = {}) {
|
|
1302
|
+
var _a, _b;
|
|
776
1303
|
const warnings = [];
|
|
777
|
-
const
|
|
778
|
-
let googleOptions
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
1304
|
+
const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
|
|
1305
|
+
let googleOptions;
|
|
1306
|
+
for (const name of providerOptionsNames) {
|
|
1307
|
+
googleOptions = await parseProviderOptions({
|
|
1308
|
+
provider: name,
|
|
1309
|
+
providerOptions,
|
|
1310
|
+
schema: googleLanguageModelOptions
|
|
1311
|
+
});
|
|
1312
|
+
if (googleOptions != null) break;
|
|
1313
|
+
}
|
|
1314
|
+
if (googleOptions == null && !providerOptionsNames.includes("google")) {
|
|
1315
|
+
googleOptions = await parseProviderOptions({
|
|
785
1316
|
provider: "google",
|
|
786
1317
|
providerOptions,
|
|
787
1318
|
schema: googleLanguageModelOptions
|
|
788
1319
|
});
|
|
789
1320
|
}
|
|
1321
|
+
const isVertexProvider = this.config.provider.startsWith("google.vertex.");
|
|
790
1322
|
if ((tools == null ? void 0 : tools.some(
|
|
791
1323
|
(tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
|
|
792
|
-
)) && !
|
|
1324
|
+
)) && !isVertexProvider) {
|
|
793
1325
|
warnings.push({
|
|
794
1326
|
type: "other",
|
|
795
1327
|
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
|
|
796
1328
|
});
|
|
797
1329
|
}
|
|
1330
|
+
if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
|
|
1331
|
+
warnings.push({
|
|
1332
|
+
type: "other",
|
|
1333
|
+
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1337
|
+
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
1338
|
+
sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
|
|
1339
|
+
}
|
|
798
1340
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1341
|
+
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1342
|
+
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1343
|
+
isGemmaModel,
|
|
1344
|
+
providerOptionsNames,
|
|
1345
|
+
supportsFunctionResponseParts
|
|
1346
|
+
});
|
|
803
1347
|
const {
|
|
804
1348
|
tools: googleTools2,
|
|
805
1349
|
toolConfig: googleToolConfig,
|
|
@@ -807,8 +1351,28 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
807
1351
|
} = prepareTools({
|
|
808
1352
|
tools,
|
|
809
1353
|
toolChoice,
|
|
810
|
-
modelId: this.modelId
|
|
1354
|
+
modelId: this.modelId,
|
|
1355
|
+
isVertexProvider
|
|
1356
|
+
});
|
|
1357
|
+
const resolvedThinking = resolveThinkingConfig({
|
|
1358
|
+
reasoning,
|
|
1359
|
+
modelId: this.modelId,
|
|
1360
|
+
warnings
|
|
811
1361
|
});
|
|
1362
|
+
const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
|
|
1363
|
+
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1364
|
+
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
1365
|
+
...googleToolConfig,
|
|
1366
|
+
...streamFunctionCallArguments && {
|
|
1367
|
+
functionCallingConfig: {
|
|
1368
|
+
...googleToolConfig == null ? void 0 : googleToolConfig.functionCallingConfig,
|
|
1369
|
+
streamFunctionCallArguments: true
|
|
1370
|
+
}
|
|
1371
|
+
},
|
|
1372
|
+
...(googleOptions == null ? void 0 : googleOptions.retrievalConfig) && {
|
|
1373
|
+
retrievalConfig: googleOptions.retrievalConfig
|
|
1374
|
+
}
|
|
1375
|
+
} : void 0;
|
|
812
1376
|
return {
|
|
813
1377
|
args: {
|
|
814
1378
|
generationConfig: {
|
|
@@ -826,13 +1390,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
826
1390
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
827
1391
|
// so this is needed as an escape hatch:
|
|
828
1392
|
// TODO convert into provider option
|
|
829
|
-
((
|
|
1393
|
+
((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
830
1394
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
831
1395
|
audioTimestamp: googleOptions.audioTimestamp
|
|
832
1396
|
},
|
|
833
1397
|
// provider options:
|
|
834
1398
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
|
835
|
-
thinkingConfig
|
|
1399
|
+
thinkingConfig,
|
|
836
1400
|
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
|
|
837
1401
|
mediaResolution: googleOptions.mediaResolution
|
|
838
1402
|
},
|
|
@@ -844,36 +1408,37 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
844
1408
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
845
1409
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
846
1410
|
tools: googleTools2,
|
|
847
|
-
toolConfig
|
|
848
|
-
...googleToolConfig,
|
|
849
|
-
retrievalConfig: googleOptions.retrievalConfig
|
|
850
|
-
} : googleToolConfig,
|
|
1411
|
+
toolConfig,
|
|
851
1412
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
852
|
-
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
1413
|
+
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1414
|
+
serviceTier: sanitizedServiceTier
|
|
853
1415
|
},
|
|
854
1416
|
warnings: [...warnings, ...toolWarnings],
|
|
855
|
-
|
|
1417
|
+
providerOptionsNames
|
|
856
1418
|
};
|
|
857
1419
|
}
|
|
858
1420
|
async doGenerate(options) {
|
|
859
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
860
|
-
const { args, warnings,
|
|
861
|
-
const
|
|
862
|
-
|
|
1421
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1422
|
+
const { args, warnings, providerOptionsNames } = await this.getArgs(options);
|
|
1423
|
+
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1424
|
+
providerOptionsNames.map((name) => [name, payload])
|
|
1425
|
+
);
|
|
1426
|
+
const mergedHeaders = combineHeaders(
|
|
1427
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
863
1428
|
options.headers
|
|
864
1429
|
);
|
|
865
1430
|
const {
|
|
866
1431
|
responseHeaders,
|
|
867
1432
|
value: response,
|
|
868
1433
|
rawValue: rawResponse
|
|
869
|
-
} = await
|
|
1434
|
+
} = await postJsonToApi({
|
|
870
1435
|
url: `${this.config.baseURL}/${getModelPath(
|
|
871
1436
|
this.modelId
|
|
872
1437
|
)}:generateContent`,
|
|
873
1438
|
headers: mergedHeaders,
|
|
874
1439
|
body: args,
|
|
875
1440
|
failedResponseHandler: googleFailedResponseHandler,
|
|
876
|
-
successfulResponseHandler:
|
|
1441
|
+
successfulResponseHandler: createJsonResponseHandler(responseSchema),
|
|
877
1442
|
abortSignal: options.abortSignal,
|
|
878
1443
|
fetch: this.config.fetch
|
|
879
1444
|
});
|
|
@@ -882,6 +1447,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
882
1447
|
const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
|
|
883
1448
|
const usageMetadata = response.usageMetadata;
|
|
884
1449
|
let lastCodeExecutionToolCallId;
|
|
1450
|
+
let lastServerToolCallId;
|
|
885
1451
|
for (const part of parts) {
|
|
886
1452
|
if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
|
|
887
1453
|
const toolCallId = this.config.generateId();
|
|
@@ -906,11 +1472,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
906
1472
|
});
|
|
907
1473
|
lastCodeExecutionToolCallId = void 0;
|
|
908
1474
|
} else if ("text" in part && part.text != null) {
|
|
909
|
-
const thoughtSignatureMetadata = part.thoughtSignature ? {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
} : void 0;
|
|
1475
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
|
|
1476
|
+
thoughtSignature: part.thoughtSignature
|
|
1477
|
+
}) : void 0;
|
|
914
1478
|
if (part.text.length === 0) {
|
|
915
1479
|
if (thoughtSignatureMetadata != null && content.length > 0) {
|
|
916
1480
|
const lastContent = content[content.length - 1];
|
|
@@ -923,65 +1487,95 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
923
1487
|
providerMetadata: thoughtSignatureMetadata
|
|
924
1488
|
});
|
|
925
1489
|
}
|
|
926
|
-
} else if ("functionCall" in part) {
|
|
1490
|
+
} else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
|
|
927
1491
|
content.push({
|
|
928
1492
|
type: "tool-call",
|
|
929
1493
|
toolCallId: this.config.generateId(),
|
|
930
1494
|
toolName: part.functionCall.name,
|
|
931
1495
|
input: JSON.stringify(part.functionCall.args),
|
|
932
|
-
providerMetadata: part.thoughtSignature ? {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
936
|
-
} : void 0
|
|
1496
|
+
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1497
|
+
thoughtSignature: part.thoughtSignature
|
|
1498
|
+
}) : void 0
|
|
937
1499
|
});
|
|
938
1500
|
} else if ("inlineData" in part) {
|
|
939
1501
|
const hasThought = part.thought === true;
|
|
940
1502
|
const hasThoughtSignature = !!part.thoughtSignature;
|
|
941
1503
|
content.push({
|
|
942
|
-
type: "file",
|
|
943
|
-
data: part.inlineData.data,
|
|
1504
|
+
type: hasThought ? "reasoning-file" : "file",
|
|
1505
|
+
data: { type: "data", data: part.inlineData.data },
|
|
944
1506
|
mediaType: part.inlineData.mimeType,
|
|
945
|
-
providerMetadata:
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
|
|
949
|
-
}
|
|
950
|
-
} : void 0
|
|
1507
|
+
providerMetadata: hasThoughtSignature ? wrapProviderMetadata({
|
|
1508
|
+
thoughtSignature: part.thoughtSignature
|
|
1509
|
+
}) : void 0
|
|
951
1510
|
});
|
|
1511
|
+
} else if ("toolCall" in part && part.toolCall) {
|
|
1512
|
+
const toolCallId = (_e = part.toolCall.id) != null ? _e : this.config.generateId();
|
|
1513
|
+
lastServerToolCallId = toolCallId;
|
|
1514
|
+
content.push({
|
|
1515
|
+
type: "tool-call",
|
|
1516
|
+
toolCallId,
|
|
1517
|
+
toolName: `server:${part.toolCall.toolType}`,
|
|
1518
|
+
input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
|
|
1519
|
+
providerExecuted: true,
|
|
1520
|
+
dynamic: true,
|
|
1521
|
+
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1522
|
+
thoughtSignature: part.thoughtSignature,
|
|
1523
|
+
serverToolCallId: toolCallId,
|
|
1524
|
+
serverToolType: part.toolCall.toolType
|
|
1525
|
+
}) : wrapProviderMetadata({
|
|
1526
|
+
serverToolCallId: toolCallId,
|
|
1527
|
+
serverToolType: part.toolCall.toolType
|
|
1528
|
+
})
|
|
1529
|
+
});
|
|
1530
|
+
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1531
|
+
const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : this.config.generateId();
|
|
1532
|
+
content.push({
|
|
1533
|
+
type: "tool-result",
|
|
1534
|
+
toolCallId: responseToolCallId,
|
|
1535
|
+
toolName: `server:${part.toolResponse.toolType}`,
|
|
1536
|
+
result: (_h = part.toolResponse.response) != null ? _h : {},
|
|
1537
|
+
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1538
|
+
thoughtSignature: part.thoughtSignature,
|
|
1539
|
+
serverToolCallId: responseToolCallId,
|
|
1540
|
+
serverToolType: part.toolResponse.toolType
|
|
1541
|
+
}) : wrapProviderMetadata({
|
|
1542
|
+
serverToolCallId: responseToolCallId,
|
|
1543
|
+
serverToolType: part.toolResponse.toolType
|
|
1544
|
+
})
|
|
1545
|
+
});
|
|
1546
|
+
lastServerToolCallId = void 0;
|
|
952
1547
|
}
|
|
953
1548
|
}
|
|
954
|
-
const sources = (
|
|
1549
|
+
const sources = (_i = extractSources({
|
|
955
1550
|
groundingMetadata: candidate.groundingMetadata,
|
|
956
1551
|
generateId: this.config.generateId
|
|
957
|
-
})) != null ?
|
|
1552
|
+
})) != null ? _i : [];
|
|
958
1553
|
for (const source of sources) {
|
|
959
1554
|
content.push(source);
|
|
960
1555
|
}
|
|
961
1556
|
return {
|
|
962
1557
|
content,
|
|
963
1558
|
finishReason: {
|
|
964
|
-
unified:
|
|
1559
|
+
unified: mapGoogleFinishReason({
|
|
965
1560
|
finishReason: candidate.finishReason,
|
|
966
1561
|
// Only count client-executed tool calls for finish reason determination.
|
|
967
1562
|
hasToolCalls: content.some(
|
|
968
1563
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
969
1564
|
)
|
|
970
1565
|
}),
|
|
971
|
-
raw: (
|
|
1566
|
+
raw: (_j = candidate.finishReason) != null ? _j : void 0
|
|
972
1567
|
},
|
|
973
|
-
usage:
|
|
1568
|
+
usage: convertGoogleUsage(usageMetadata),
|
|
974
1569
|
warnings,
|
|
975
|
-
providerMetadata: {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
},
|
|
1570
|
+
providerMetadata: wrapProviderMetadata({
|
|
1571
|
+
promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
|
|
1572
|
+
groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
|
|
1573
|
+
urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
|
|
1574
|
+
safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
|
|
1575
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1576
|
+
finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
|
|
1577
|
+
serviceTier: (_p = response.serviceTier) != null ? _p : null
|
|
1578
|
+
}),
|
|
985
1579
|
request: { body: args },
|
|
986
1580
|
response: {
|
|
987
1581
|
// TODO timestamp, model id, id
|
|
@@ -991,19 +1585,25 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
991
1585
|
};
|
|
992
1586
|
}
|
|
993
1587
|
async doStream(options) {
|
|
994
|
-
const { args, warnings,
|
|
995
|
-
|
|
996
|
-
|
|
1588
|
+
const { args, warnings, providerOptionsNames } = await this.getArgs(
|
|
1589
|
+
options,
|
|
1590
|
+
{ isStreaming: true }
|
|
1591
|
+
);
|
|
1592
|
+
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1593
|
+
providerOptionsNames.map((name) => [name, payload])
|
|
1594
|
+
);
|
|
1595
|
+
const headers = combineHeaders(
|
|
1596
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
997
1597
|
options.headers
|
|
998
1598
|
);
|
|
999
|
-
const { responseHeaders, value: response } = await
|
|
1599
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
1000
1600
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1001
1601
|
this.modelId
|
|
1002
1602
|
)}:streamGenerateContent?alt=sse`,
|
|
1003
1603
|
headers,
|
|
1004
1604
|
body: args,
|
|
1005
1605
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1006
|
-
successfulResponseHandler:
|
|
1606
|
+
successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
|
|
1007
1607
|
abortSignal: options.abortSignal,
|
|
1008
1608
|
fetch: this.config.fetch
|
|
1009
1609
|
});
|
|
@@ -1015,6 +1615,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1015
1615
|
let providerMetadata = void 0;
|
|
1016
1616
|
let lastGroundingMetadata = null;
|
|
1017
1617
|
let lastUrlContextMetadata = null;
|
|
1618
|
+
let serviceTier = null;
|
|
1018
1619
|
const generateId2 = this.config.generateId;
|
|
1019
1620
|
let hasToolCalls = false;
|
|
1020
1621
|
let currentTextBlockId = null;
|
|
@@ -1022,6 +1623,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1022
1623
|
let blockCounter = 0;
|
|
1023
1624
|
const emittedSourceUrls = /* @__PURE__ */ new Set();
|
|
1024
1625
|
let lastCodeExecutionToolCallId;
|
|
1626
|
+
let lastServerToolCallId;
|
|
1627
|
+
const activeStreamingToolCalls = [];
|
|
1025
1628
|
return {
|
|
1026
1629
|
stream: response.pipeThrough(
|
|
1027
1630
|
new TransformStream({
|
|
@@ -1029,7 +1632,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1029
1632
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1030
1633
|
},
|
|
1031
1634
|
transform(chunk, controller) {
|
|
1032
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1635
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1033
1636
|
if (options.includeRawChunks) {
|
|
1034
1637
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1035
1638
|
}
|
|
@@ -1042,6 +1645,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1042
1645
|
if (usageMetadata != null) {
|
|
1043
1646
|
usage = usageMetadata;
|
|
1044
1647
|
}
|
|
1648
|
+
if (value.serviceTier != null) {
|
|
1649
|
+
serviceTier = value.serviceTier;
|
|
1650
|
+
}
|
|
1045
1651
|
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1046
1652
|
if (candidate == null) {
|
|
1047
1653
|
return;
|
|
@@ -1093,11 +1699,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1093
1699
|
lastCodeExecutionToolCallId = void 0;
|
|
1094
1700
|
}
|
|
1095
1701
|
} else if ("text" in part && part.text != null) {
|
|
1096
|
-
const thoughtSignatureMetadata = part.thoughtSignature ? {
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
} : void 0;
|
|
1702
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
|
|
1703
|
+
thoughtSignature: part.thoughtSignature
|
|
1704
|
+
}) : void 0;
|
|
1101
1705
|
if (part.text.length === 0) {
|
|
1102
1706
|
if (thoughtSignatureMetadata != null && currentTextBlockId !== null) {
|
|
1103
1707
|
controller.enqueue({
|
|
@@ -1169,50 +1773,151 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1169
1773
|
}
|
|
1170
1774
|
const hasThought = part.thought === true;
|
|
1171
1775
|
const hasThoughtSignature = !!part.thoughtSignature;
|
|
1172
|
-
const fileMeta =
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
|
|
1176
|
-
}
|
|
1177
|
-
} : void 0;
|
|
1776
|
+
const fileMeta = hasThoughtSignature ? wrapProviderMetadata({
|
|
1777
|
+
thoughtSignature: part.thoughtSignature
|
|
1778
|
+
}) : void 0;
|
|
1178
1779
|
controller.enqueue({
|
|
1179
|
-
type: "file",
|
|
1780
|
+
type: hasThought ? "reasoning-file" : "file",
|
|
1180
1781
|
mediaType: part.inlineData.mimeType,
|
|
1181
|
-
data: part.inlineData.data,
|
|
1782
|
+
data: { type: "data", data: part.inlineData.data },
|
|
1182
1783
|
providerMetadata: fileMeta
|
|
1183
1784
|
});
|
|
1785
|
+
} else if ("toolCall" in part && part.toolCall) {
|
|
1786
|
+
const toolCallId = (_e = part.toolCall.id) != null ? _e : generateId2();
|
|
1787
|
+
lastServerToolCallId = toolCallId;
|
|
1788
|
+
const serverMeta = wrapProviderMetadata({
|
|
1789
|
+
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
1790
|
+
serverToolCallId: toolCallId,
|
|
1791
|
+
serverToolType: part.toolCall.toolType
|
|
1792
|
+
});
|
|
1793
|
+
controller.enqueue({
|
|
1794
|
+
type: "tool-call",
|
|
1795
|
+
toolCallId,
|
|
1796
|
+
toolName: `server:${part.toolCall.toolType}`,
|
|
1797
|
+
input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
|
|
1798
|
+
providerExecuted: true,
|
|
1799
|
+
dynamic: true,
|
|
1800
|
+
providerMetadata: serverMeta
|
|
1801
|
+
});
|
|
1802
|
+
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1803
|
+
const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : generateId2();
|
|
1804
|
+
const serverMeta = wrapProviderMetadata({
|
|
1805
|
+
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
1806
|
+
serverToolCallId: responseToolCallId,
|
|
1807
|
+
serverToolType: part.toolResponse.toolType
|
|
1808
|
+
});
|
|
1809
|
+
controller.enqueue({
|
|
1810
|
+
type: "tool-result",
|
|
1811
|
+
toolCallId: responseToolCallId,
|
|
1812
|
+
toolName: `server:${part.toolResponse.toolType}`,
|
|
1813
|
+
result: (_h = part.toolResponse.response) != null ? _h : {},
|
|
1814
|
+
providerMetadata: serverMeta
|
|
1815
|
+
});
|
|
1816
|
+
lastServerToolCallId = void 0;
|
|
1184
1817
|
}
|
|
1185
1818
|
}
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1819
|
+
for (const part of parts) {
|
|
1820
|
+
if (!("functionCall" in part)) continue;
|
|
1821
|
+
const providerMeta = part.thoughtSignature ? wrapProviderMetadata({
|
|
1822
|
+
thoughtSignature: part.thoughtSignature
|
|
1823
|
+
}) : void 0;
|
|
1824
|
+
const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
|
|
1825
|
+
const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
|
|
1826
|
+
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1827
|
+
if (isStreamingChunk) {
|
|
1828
|
+
if (part.functionCall.name != null && part.functionCall.willContinue === true) {
|
|
1829
|
+
const toolCallId = generateId2();
|
|
1830
|
+
const accumulator = new GoogleJSONAccumulator();
|
|
1831
|
+
activeStreamingToolCalls.push({
|
|
1832
|
+
toolCallId,
|
|
1833
|
+
toolName: part.functionCall.name,
|
|
1834
|
+
accumulator,
|
|
1835
|
+
providerMetadata: providerMeta
|
|
1836
|
+
});
|
|
1837
|
+
controller.enqueue({
|
|
1838
|
+
type: "tool-input-start",
|
|
1839
|
+
id: toolCallId,
|
|
1840
|
+
toolName: part.functionCall.name,
|
|
1841
|
+
providerMetadata: providerMeta
|
|
1842
|
+
});
|
|
1843
|
+
if (part.functionCall.partialArgs != null) {
|
|
1844
|
+
const { textDelta } = accumulator.processPartialArgs(
|
|
1845
|
+
part.functionCall.partialArgs
|
|
1846
|
+
);
|
|
1847
|
+
if (textDelta.length > 0) {
|
|
1848
|
+
controller.enqueue({
|
|
1849
|
+
type: "tool-input-delta",
|
|
1850
|
+
id: toolCallId,
|
|
1851
|
+
delta: textDelta,
|
|
1852
|
+
providerMetadata: providerMeta
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
1857
|
+
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
1858
|
+
const { textDelta } = active.accumulator.processPartialArgs(
|
|
1859
|
+
part.functionCall.partialArgs
|
|
1860
|
+
);
|
|
1861
|
+
if (textDelta.length > 0) {
|
|
1862
|
+
controller.enqueue({
|
|
1863
|
+
type: "tool-input-delta",
|
|
1864
|
+
id: active.toolCallId,
|
|
1865
|
+
delta: textDelta,
|
|
1866
|
+
providerMetadata: providerMeta
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
1871
|
+
const active = activeStreamingToolCalls.pop();
|
|
1872
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1873
|
+
if (closingDelta.length > 0) {
|
|
1874
|
+
controller.enqueue({
|
|
1875
|
+
type: "tool-input-delta",
|
|
1876
|
+
id: active.toolCallId,
|
|
1877
|
+
delta: closingDelta,
|
|
1878
|
+
providerMetadata: active.providerMetadata
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
controller.enqueue({
|
|
1882
|
+
type: "tool-input-end",
|
|
1883
|
+
id: active.toolCallId,
|
|
1884
|
+
providerMetadata: active.providerMetadata
|
|
1885
|
+
});
|
|
1886
|
+
controller.enqueue({
|
|
1887
|
+
type: "tool-call",
|
|
1888
|
+
toolCallId: active.toolCallId,
|
|
1889
|
+
toolName: active.toolName,
|
|
1890
|
+
input: finalJSON,
|
|
1891
|
+
providerMetadata: active.providerMetadata
|
|
1892
|
+
});
|
|
1893
|
+
hasToolCalls = true;
|
|
1894
|
+
} else if (isCompleteCall) {
|
|
1895
|
+
const toolCallId = generateId2();
|
|
1896
|
+
const toolName = part.functionCall.name;
|
|
1897
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_i = part.functionCall.args) != null ? _i : {});
|
|
1193
1898
|
controller.enqueue({
|
|
1194
1899
|
type: "tool-input-start",
|
|
1195
|
-
id:
|
|
1196
|
-
toolName
|
|
1197
|
-
providerMetadata:
|
|
1900
|
+
id: toolCallId,
|
|
1901
|
+
toolName,
|
|
1902
|
+
providerMetadata: providerMeta
|
|
1198
1903
|
});
|
|
1199
1904
|
controller.enqueue({
|
|
1200
1905
|
type: "tool-input-delta",
|
|
1201
|
-
id:
|
|
1202
|
-
delta:
|
|
1203
|
-
providerMetadata:
|
|
1906
|
+
id: toolCallId,
|
|
1907
|
+
delta: args2,
|
|
1908
|
+
providerMetadata: providerMeta
|
|
1204
1909
|
});
|
|
1205
1910
|
controller.enqueue({
|
|
1206
1911
|
type: "tool-input-end",
|
|
1207
|
-
id:
|
|
1208
|
-
providerMetadata:
|
|
1912
|
+
id: toolCallId,
|
|
1913
|
+
providerMetadata: providerMeta
|
|
1209
1914
|
});
|
|
1210
1915
|
controller.enqueue({
|
|
1211
1916
|
type: "tool-call",
|
|
1212
|
-
toolCallId
|
|
1213
|
-
toolName
|
|
1214
|
-
input:
|
|
1215
|
-
providerMetadata:
|
|
1917
|
+
toolCallId,
|
|
1918
|
+
toolName,
|
|
1919
|
+
input: args2,
|
|
1920
|
+
providerMetadata: providerMeta
|
|
1216
1921
|
});
|
|
1217
1922
|
hasToolCalls = true;
|
|
1218
1923
|
}
|
|
@@ -1220,22 +1925,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1220
1925
|
}
|
|
1221
1926
|
if (candidate.finishReason != null) {
|
|
1222
1927
|
finishReason = {
|
|
1223
|
-
unified:
|
|
1928
|
+
unified: mapGoogleFinishReason({
|
|
1224
1929
|
finishReason: candidate.finishReason,
|
|
1225
1930
|
hasToolCalls
|
|
1226
1931
|
}),
|
|
1227
1932
|
raw: candidate.finishReason
|
|
1228
1933
|
};
|
|
1229
|
-
providerMetadata = {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
};
|
|
1934
|
+
providerMetadata = wrapProviderMetadata({
|
|
1935
|
+
promptFeedback: (_j = value.promptFeedback) != null ? _j : null,
|
|
1936
|
+
groundingMetadata: lastGroundingMetadata,
|
|
1937
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
1938
|
+
safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null,
|
|
1939
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1940
|
+
finishMessage: (_l = candidate.finishMessage) != null ? _l : null,
|
|
1941
|
+
serviceTier
|
|
1942
|
+
});
|
|
1239
1943
|
}
|
|
1240
1944
|
},
|
|
1241
1945
|
flush(controller) {
|
|
@@ -1254,7 +1958,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1254
1958
|
controller.enqueue({
|
|
1255
1959
|
type: "finish",
|
|
1256
1960
|
finishReason,
|
|
1257
|
-
usage:
|
|
1961
|
+
usage: convertGoogleUsage(usage),
|
|
1258
1962
|
providerMetadata
|
|
1259
1963
|
});
|
|
1260
1964
|
}
|
|
@@ -1265,25 +1969,74 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1265
1969
|
};
|
|
1266
1970
|
}
|
|
1267
1971
|
};
|
|
1268
|
-
function
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1972
|
+
function isGemini3Model(modelId) {
|
|
1973
|
+
return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
|
|
1974
|
+
}
|
|
1975
|
+
function getMaxOutputTokensForGemini25Model() {
|
|
1976
|
+
return 65536;
|
|
1977
|
+
}
|
|
1978
|
+
function getMaxThinkingTokensForGemini25Model(modelId) {
|
|
1979
|
+
const id = modelId.toLowerCase();
|
|
1980
|
+
if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) {
|
|
1981
|
+
return 32768;
|
|
1982
|
+
}
|
|
1983
|
+
return 24576;
|
|
1984
|
+
}
|
|
1985
|
+
function resolveThinkingConfig({
|
|
1986
|
+
reasoning,
|
|
1987
|
+
modelId,
|
|
1988
|
+
warnings
|
|
1272
1989
|
}) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1990
|
+
if (!isCustomReasoning(reasoning)) {
|
|
1991
|
+
return void 0;
|
|
1992
|
+
}
|
|
1993
|
+
if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
|
|
1994
|
+
return resolveGemini3ThinkingConfig({ reasoning, warnings });
|
|
1995
|
+
}
|
|
1996
|
+
return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
|
|
1997
|
+
}
|
|
1998
|
+
function resolveGemini3ThinkingConfig({
|
|
1999
|
+
reasoning,
|
|
2000
|
+
warnings
|
|
2001
|
+
}) {
|
|
2002
|
+
if (reasoning === "none") {
|
|
2003
|
+
return { thinkingLevel: "minimal" };
|
|
2004
|
+
}
|
|
2005
|
+
const thinkingLevel = mapReasoningToProviderEffort({
|
|
2006
|
+
reasoning,
|
|
2007
|
+
effortMap: {
|
|
2008
|
+
minimal: "minimal",
|
|
2009
|
+
low: "low",
|
|
2010
|
+
medium: "medium",
|
|
2011
|
+
high: "high",
|
|
2012
|
+
xhigh: "high"
|
|
2013
|
+
},
|
|
2014
|
+
warnings
|
|
2015
|
+
});
|
|
2016
|
+
if (thinkingLevel == null) {
|
|
2017
|
+
return void 0;
|
|
2018
|
+
}
|
|
2019
|
+
return { thinkingLevel };
|
|
2020
|
+
}
|
|
2021
|
+
function resolveGemini25ThinkingConfig({
|
|
2022
|
+
reasoning,
|
|
2023
|
+
modelId,
|
|
2024
|
+
warnings
|
|
2025
|
+
}) {
|
|
2026
|
+
if (reasoning === "none") {
|
|
2027
|
+
return { thinkingBudget: 0 };
|
|
2028
|
+
}
|
|
2029
|
+
const thinkingBudget = mapReasoningToProviderBudget({
|
|
2030
|
+
reasoning,
|
|
2031
|
+
maxOutputTokens: getMaxOutputTokensForGemini25Model(),
|
|
2032
|
+
maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
|
|
2033
|
+
minReasoningBudget: 0,
|
|
2034
|
+
warnings
|
|
2035
|
+
});
|
|
2036
|
+
if (thinkingBudget == null) {
|
|
2037
|
+
return void 0;
|
|
2038
|
+
}
|
|
2039
|
+
return { thinkingBudget };
|
|
1287
2040
|
}
|
|
1288
2041
|
function extractSources({
|
|
1289
2042
|
groundingMetadata,
|
|
@@ -1379,256 +2132,312 @@ function extractSources({
|
|
|
1379
2132
|
}
|
|
1380
2133
|
return sources.length > 0 ? sources : void 0;
|
|
1381
2134
|
}
|
|
1382
|
-
var getGroundingMetadataSchema = () =>
|
|
1383
|
-
webSearchQueries:
|
|
1384
|
-
imageSearchQueries:
|
|
1385
|
-
retrievalQueries:
|
|
1386
|
-
searchEntryPoint:
|
|
1387
|
-
groundingChunks:
|
|
1388
|
-
|
|
1389
|
-
web:
|
|
1390
|
-
image:
|
|
1391
|
-
sourceUri:
|
|
1392
|
-
imageUri:
|
|
1393
|
-
title:
|
|
1394
|
-
domain:
|
|
2135
|
+
var getGroundingMetadataSchema = () => z3.object({
|
|
2136
|
+
webSearchQueries: z3.array(z3.string()).nullish(),
|
|
2137
|
+
imageSearchQueries: z3.array(z3.string()).nullish(),
|
|
2138
|
+
retrievalQueries: z3.array(z3.string()).nullish(),
|
|
2139
|
+
searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
|
|
2140
|
+
groundingChunks: z3.array(
|
|
2141
|
+
z3.object({
|
|
2142
|
+
web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(),
|
|
2143
|
+
image: z3.object({
|
|
2144
|
+
sourceUri: z3.string(),
|
|
2145
|
+
imageUri: z3.string(),
|
|
2146
|
+
title: z3.string().nullish(),
|
|
2147
|
+
domain: z3.string().nullish()
|
|
1395
2148
|
}).nullish(),
|
|
1396
|
-
retrievedContext:
|
|
1397
|
-
uri:
|
|
1398
|
-
title:
|
|
1399
|
-
text:
|
|
1400
|
-
fileSearchStore:
|
|
2149
|
+
retrievedContext: z3.object({
|
|
2150
|
+
uri: z3.string().nullish(),
|
|
2151
|
+
title: z3.string().nullish(),
|
|
2152
|
+
text: z3.string().nullish(),
|
|
2153
|
+
fileSearchStore: z3.string().nullish()
|
|
1401
2154
|
}).nullish(),
|
|
1402
|
-
maps:
|
|
1403
|
-
uri:
|
|
1404
|
-
title:
|
|
1405
|
-
text:
|
|
1406
|
-
placeId:
|
|
2155
|
+
maps: z3.object({
|
|
2156
|
+
uri: z3.string().nullish(),
|
|
2157
|
+
title: z3.string().nullish(),
|
|
2158
|
+
text: z3.string().nullish(),
|
|
2159
|
+
placeId: z3.string().nullish()
|
|
1407
2160
|
}).nullish()
|
|
1408
2161
|
})
|
|
1409
2162
|
).nullish(),
|
|
1410
|
-
groundingSupports:
|
|
1411
|
-
|
|
1412
|
-
segment:
|
|
1413
|
-
startIndex:
|
|
1414
|
-
endIndex:
|
|
1415
|
-
text:
|
|
2163
|
+
groundingSupports: z3.array(
|
|
2164
|
+
z3.object({
|
|
2165
|
+
segment: z3.object({
|
|
2166
|
+
startIndex: z3.number().nullish(),
|
|
2167
|
+
endIndex: z3.number().nullish(),
|
|
2168
|
+
text: z3.string().nullish()
|
|
1416
2169
|
}).nullish(),
|
|
1417
|
-
segment_text:
|
|
1418
|
-
groundingChunkIndices:
|
|
1419
|
-
supportChunkIndices:
|
|
1420
|
-
confidenceScores:
|
|
1421
|
-
confidenceScore:
|
|
2170
|
+
segment_text: z3.string().nullish(),
|
|
2171
|
+
groundingChunkIndices: z3.array(z3.number()).nullish(),
|
|
2172
|
+
supportChunkIndices: z3.array(z3.number()).nullish(),
|
|
2173
|
+
confidenceScores: z3.array(z3.number()).nullish(),
|
|
2174
|
+
confidenceScore: z3.array(z3.number()).nullish()
|
|
1422
2175
|
})
|
|
1423
2176
|
).nullish(),
|
|
1424
|
-
retrievalMetadata:
|
|
1425
|
-
|
|
1426
|
-
webDynamicRetrievalScore:
|
|
2177
|
+
retrievalMetadata: z3.union([
|
|
2178
|
+
z3.object({
|
|
2179
|
+
webDynamicRetrievalScore: z3.number()
|
|
1427
2180
|
}),
|
|
1428
|
-
|
|
2181
|
+
z3.object({})
|
|
1429
2182
|
]).nullish()
|
|
1430
2183
|
});
|
|
1431
|
-
var
|
|
1432
|
-
|
|
1433
|
-
|
|
2184
|
+
var partialArgSchema = z3.object({
|
|
2185
|
+
jsonPath: z3.string(),
|
|
2186
|
+
stringValue: z3.string().nullish(),
|
|
2187
|
+
numberValue: z3.number().nullish(),
|
|
2188
|
+
boolValue: z3.boolean().nullish(),
|
|
2189
|
+
nullValue: z3.unknown().nullish(),
|
|
2190
|
+
willContinue: z3.boolean().nullish()
|
|
2191
|
+
});
|
|
2192
|
+
var getContentSchema = () => z3.object({
|
|
2193
|
+
parts: z3.array(
|
|
2194
|
+
z3.union([
|
|
1434
2195
|
// note: order matters since text can be fully empty
|
|
1435
|
-
|
|
1436
|
-
functionCall:
|
|
1437
|
-
name:
|
|
1438
|
-
args:
|
|
2196
|
+
z3.object({
|
|
2197
|
+
functionCall: z3.object({
|
|
2198
|
+
name: z3.string().nullish(),
|
|
2199
|
+
args: z3.unknown().nullish(),
|
|
2200
|
+
partialArgs: z3.array(partialArgSchema).nullish(),
|
|
2201
|
+
willContinue: z3.boolean().nullish()
|
|
2202
|
+
}),
|
|
2203
|
+
thoughtSignature: z3.string().nullish()
|
|
2204
|
+
}),
|
|
2205
|
+
z3.object({
|
|
2206
|
+
inlineData: z3.object({
|
|
2207
|
+
mimeType: z3.string(),
|
|
2208
|
+
data: z3.string()
|
|
2209
|
+
}),
|
|
2210
|
+
thought: z3.boolean().nullish(),
|
|
2211
|
+
thoughtSignature: z3.string().nullish()
|
|
2212
|
+
}),
|
|
2213
|
+
z3.object({
|
|
2214
|
+
toolCall: z3.object({
|
|
2215
|
+
toolType: z3.string(),
|
|
2216
|
+
args: z3.unknown().nullish(),
|
|
2217
|
+
id: z3.string()
|
|
1439
2218
|
}),
|
|
1440
|
-
thoughtSignature:
|
|
2219
|
+
thoughtSignature: z3.string().nullish()
|
|
1441
2220
|
}),
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
2221
|
+
z3.object({
|
|
2222
|
+
toolResponse: z3.object({
|
|
2223
|
+
toolType: z3.string(),
|
|
2224
|
+
response: z3.unknown().nullish(),
|
|
2225
|
+
id: z3.string()
|
|
1446
2226
|
}),
|
|
1447
|
-
|
|
1448
|
-
thoughtSignature: import_v43.z.string().nullish()
|
|
2227
|
+
thoughtSignature: z3.string().nullish()
|
|
1449
2228
|
}),
|
|
1450
|
-
|
|
1451
|
-
executableCode:
|
|
1452
|
-
language:
|
|
1453
|
-
code:
|
|
2229
|
+
z3.object({
|
|
2230
|
+
executableCode: z3.object({
|
|
2231
|
+
language: z3.string(),
|
|
2232
|
+
code: z3.string()
|
|
1454
2233
|
}).nullish(),
|
|
1455
|
-
codeExecutionResult:
|
|
1456
|
-
outcome:
|
|
1457
|
-
output:
|
|
2234
|
+
codeExecutionResult: z3.object({
|
|
2235
|
+
outcome: z3.string(),
|
|
2236
|
+
output: z3.string().nullish()
|
|
1458
2237
|
}).nullish(),
|
|
1459
|
-
text:
|
|
1460
|
-
thought:
|
|
1461
|
-
thoughtSignature:
|
|
2238
|
+
text: z3.string().nullish(),
|
|
2239
|
+
thought: z3.boolean().nullish(),
|
|
2240
|
+
thoughtSignature: z3.string().nullish()
|
|
1462
2241
|
})
|
|
1463
2242
|
])
|
|
1464
2243
|
).nullish()
|
|
1465
2244
|
});
|
|
1466
|
-
var getSafetyRatingSchema = () =>
|
|
1467
|
-
category:
|
|
1468
|
-
probability:
|
|
1469
|
-
probabilityScore:
|
|
1470
|
-
severity:
|
|
1471
|
-
severityScore:
|
|
1472
|
-
blocked:
|
|
2245
|
+
var getSafetyRatingSchema = () => z3.object({
|
|
2246
|
+
category: z3.string().nullish(),
|
|
2247
|
+
probability: z3.string().nullish(),
|
|
2248
|
+
probabilityScore: z3.number().nullish(),
|
|
2249
|
+
severity: z3.string().nullish(),
|
|
2250
|
+
severityScore: z3.number().nullish(),
|
|
2251
|
+
blocked: z3.boolean().nullish()
|
|
1473
2252
|
});
|
|
1474
|
-
var
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
2253
|
+
var tokenDetailsSchema = z3.array(
|
|
2254
|
+
z3.object({
|
|
2255
|
+
modality: z3.string(),
|
|
2256
|
+
tokenCount: z3.number()
|
|
2257
|
+
})
|
|
2258
|
+
).nullish();
|
|
2259
|
+
var usageSchema = z3.object({
|
|
2260
|
+
cachedContentTokenCount: z3.number().nullish(),
|
|
2261
|
+
thoughtsTokenCount: z3.number().nullish(),
|
|
2262
|
+
promptTokenCount: z3.number().nullish(),
|
|
2263
|
+
candidatesTokenCount: z3.number().nullish(),
|
|
2264
|
+
totalTokenCount: z3.number().nullish(),
|
|
1480
2265
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
1481
|
-
trafficType:
|
|
2266
|
+
trafficType: z3.string().nullish(),
|
|
2267
|
+
// https://ai.google.dev/api/generate-content#Modality
|
|
2268
|
+
promptTokensDetails: tokenDetailsSchema,
|
|
2269
|
+
candidatesTokensDetails: tokenDetailsSchema
|
|
1482
2270
|
});
|
|
1483
|
-
var getUrlContextMetadataSchema = () =>
|
|
1484
|
-
urlMetadata:
|
|
1485
|
-
|
|
1486
|
-
retrievedUrl:
|
|
1487
|
-
urlRetrievalStatus:
|
|
2271
|
+
var getUrlContextMetadataSchema = () => z3.object({
|
|
2272
|
+
urlMetadata: z3.array(
|
|
2273
|
+
z3.object({
|
|
2274
|
+
retrievedUrl: z3.string(),
|
|
2275
|
+
urlRetrievalStatus: z3.string()
|
|
1488
2276
|
})
|
|
1489
2277
|
).nullish()
|
|
1490
2278
|
});
|
|
1491
|
-
var responseSchema = (
|
|
1492
|
-
() => (
|
|
1493
|
-
|
|
1494
|
-
candidates:
|
|
1495
|
-
|
|
1496
|
-
content: getContentSchema().nullish().or(
|
|
1497
|
-
finishReason:
|
|
1498
|
-
finishMessage:
|
|
1499
|
-
safetyRatings:
|
|
2279
|
+
var responseSchema = lazySchema3(
|
|
2280
|
+
() => zodSchema3(
|
|
2281
|
+
z3.object({
|
|
2282
|
+
candidates: z3.array(
|
|
2283
|
+
z3.object({
|
|
2284
|
+
content: getContentSchema().nullish().or(z3.object({}).strict()),
|
|
2285
|
+
finishReason: z3.string().nullish(),
|
|
2286
|
+
finishMessage: z3.string().nullish(),
|
|
2287
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
|
|
1500
2288
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
1501
2289
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
1502
2290
|
})
|
|
1503
2291
|
),
|
|
1504
2292
|
usageMetadata: usageSchema.nullish(),
|
|
1505
|
-
promptFeedback:
|
|
1506
|
-
blockReason:
|
|
1507
|
-
safetyRatings:
|
|
1508
|
-
}).nullish()
|
|
2293
|
+
promptFeedback: z3.object({
|
|
2294
|
+
blockReason: z3.string().nullish(),
|
|
2295
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
|
|
2296
|
+
}).nullish(),
|
|
2297
|
+
serviceTier: z3.string().nullish()
|
|
1509
2298
|
})
|
|
1510
2299
|
)
|
|
1511
2300
|
);
|
|
1512
|
-
var chunkSchema = (
|
|
1513
|
-
() => (
|
|
1514
|
-
|
|
1515
|
-
candidates:
|
|
1516
|
-
|
|
2301
|
+
var chunkSchema = lazySchema3(
|
|
2302
|
+
() => zodSchema3(
|
|
2303
|
+
z3.object({
|
|
2304
|
+
candidates: z3.array(
|
|
2305
|
+
z3.object({
|
|
1517
2306
|
content: getContentSchema().nullish(),
|
|
1518
|
-
finishReason:
|
|
1519
|
-
finishMessage:
|
|
1520
|
-
safetyRatings:
|
|
2307
|
+
finishReason: z3.string().nullish(),
|
|
2308
|
+
finishMessage: z3.string().nullish(),
|
|
2309
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
|
|
1521
2310
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
1522
2311
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
1523
2312
|
})
|
|
1524
2313
|
).nullish(),
|
|
1525
2314
|
usageMetadata: usageSchema.nullish(),
|
|
1526
|
-
promptFeedback:
|
|
1527
|
-
blockReason:
|
|
1528
|
-
safetyRatings:
|
|
1529
|
-
}).nullish()
|
|
2315
|
+
promptFeedback: z3.object({
|
|
2316
|
+
blockReason: z3.string().nullish(),
|
|
2317
|
+
safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
|
|
2318
|
+
}).nullish(),
|
|
2319
|
+
serviceTier: z3.string().nullish()
|
|
1530
2320
|
})
|
|
1531
2321
|
)
|
|
1532
2322
|
);
|
|
1533
2323
|
|
|
1534
2324
|
// src/tool/code-execution.ts
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
var codeExecution = (
|
|
2325
|
+
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
2326
|
+
import { z as z4 } from "zod/v4";
|
|
2327
|
+
var codeExecution = createProviderExecutedToolFactory({
|
|
1538
2328
|
id: "google.code_execution",
|
|
1539
|
-
inputSchema:
|
|
1540
|
-
language:
|
|
1541
|
-
code:
|
|
2329
|
+
inputSchema: z4.object({
|
|
2330
|
+
language: z4.string().describe("The programming language of the code."),
|
|
2331
|
+
code: z4.string().describe("The code to be executed.")
|
|
1542
2332
|
}),
|
|
1543
|
-
outputSchema:
|
|
1544
|
-
outcome:
|
|
1545
|
-
output:
|
|
2333
|
+
outputSchema: z4.object({
|
|
2334
|
+
outcome: z4.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
2335
|
+
output: z4.string().describe("The output from the code execution.")
|
|
1546
2336
|
})
|
|
1547
2337
|
});
|
|
1548
2338
|
|
|
1549
2339
|
// src/tool/enterprise-web-search.ts
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
2340
|
+
import {
|
|
2341
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
2342
|
+
lazySchema as lazySchema4,
|
|
2343
|
+
zodSchema as zodSchema4
|
|
2344
|
+
} from "@ai-sdk/provider-utils";
|
|
2345
|
+
import { z as z5 } from "zod/v4";
|
|
2346
|
+
var enterpriseWebSearch = createProviderExecutedToolFactory2({
|
|
1553
2347
|
id: "google.enterprise_web_search",
|
|
1554
|
-
inputSchema: (
|
|
2348
|
+
inputSchema: lazySchema4(() => zodSchema4(z5.object({}))),
|
|
2349
|
+
outputSchema: lazySchema4(() => zodSchema4(z5.object({})))
|
|
1555
2350
|
});
|
|
1556
2351
|
|
|
1557
2352
|
// src/tool/file-search.ts
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
2353
|
+
import {
|
|
2354
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
2355
|
+
lazySchema as lazySchema5,
|
|
2356
|
+
zodSchema as zodSchema5
|
|
2357
|
+
} from "@ai-sdk/provider-utils";
|
|
2358
|
+
import { z as z6 } from "zod/v4";
|
|
2359
|
+
var fileSearchArgsBaseSchema = z6.object({
|
|
1561
2360
|
/** The names of the file_search_stores to retrieve from.
|
|
1562
2361
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
1563
2362
|
*/
|
|
1564
|
-
fileSearchStoreNames:
|
|
2363
|
+
fileSearchStoreNames: z6.array(z6.string()).describe(
|
|
1565
2364
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
1566
2365
|
),
|
|
1567
2366
|
/** The number of file search retrieval chunks to retrieve. */
|
|
1568
|
-
topK:
|
|
2367
|
+
topK: z6.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
1569
2368
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
1570
2369
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
1571
2370
|
*/
|
|
1572
|
-
metadataFilter:
|
|
2371
|
+
metadataFilter: z6.string().describe(
|
|
1573
2372
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
1574
2373
|
).optional()
|
|
1575
2374
|
}).passthrough();
|
|
1576
|
-
var
|
|
1577
|
-
() => (0, import_provider_utils7.zodSchema)(fileSearchArgsBaseSchema)
|
|
1578
|
-
);
|
|
1579
|
-
var fileSearch = (0, import_provider_utils7.createProviderToolFactory)({
|
|
2375
|
+
var fileSearch = createProviderExecutedToolFactory3({
|
|
1580
2376
|
id: "google.file_search",
|
|
1581
|
-
inputSchema:
|
|
2377
|
+
inputSchema: lazySchema5(() => zodSchema5(z6.object({}))),
|
|
2378
|
+
outputSchema: lazySchema5(() => zodSchema5(z6.object({})))
|
|
1582
2379
|
});
|
|
1583
2380
|
|
|
1584
2381
|
// src/tool/google-maps.ts
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
2382
|
+
import {
|
|
2383
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
2384
|
+
lazySchema as lazySchema6,
|
|
2385
|
+
zodSchema as zodSchema6
|
|
2386
|
+
} from "@ai-sdk/provider-utils";
|
|
2387
|
+
import { z as z7 } from "zod/v4";
|
|
2388
|
+
var googleMaps = createProviderExecutedToolFactory4({
|
|
1588
2389
|
id: "google.google_maps",
|
|
1589
|
-
inputSchema: (
|
|
2390
|
+
inputSchema: lazySchema6(() => zodSchema6(z7.object({}))),
|
|
2391
|
+
outputSchema: lazySchema6(() => zodSchema6(z7.object({})))
|
|
1590
2392
|
});
|
|
1591
2393
|
|
|
1592
2394
|
// src/tool/google-search.ts
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
2395
|
+
import {
|
|
2396
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
2397
|
+
lazySchema as lazySchema7,
|
|
2398
|
+
zodSchema as zodSchema7
|
|
2399
|
+
} from "@ai-sdk/provider-utils";
|
|
2400
|
+
import { z as z8 } from "zod/v4";
|
|
2401
|
+
var googleSearchToolArgsBaseSchema = z8.object({
|
|
2402
|
+
searchTypes: z8.object({
|
|
2403
|
+
webSearch: z8.object({}).optional(),
|
|
2404
|
+
imageSearch: z8.object({}).optional()
|
|
1599
2405
|
}).optional(),
|
|
1600
|
-
timeRangeFilter:
|
|
1601
|
-
startTime:
|
|
1602
|
-
endTime:
|
|
2406
|
+
timeRangeFilter: z8.object({
|
|
2407
|
+
startTime: z8.string(),
|
|
2408
|
+
endTime: z8.string()
|
|
1603
2409
|
}).optional()
|
|
1604
2410
|
}).passthrough();
|
|
1605
|
-
var
|
|
1606
|
-
|
|
1607
|
-
)
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
id: "google.google_search",
|
|
1611
|
-
inputSchema: googleSearchToolArgsSchema
|
|
1612
|
-
}
|
|
1613
|
-
);
|
|
2411
|
+
var googleSearch = createProviderExecutedToolFactory5({
|
|
2412
|
+
id: "google.google_search",
|
|
2413
|
+
inputSchema: lazySchema7(() => zodSchema7(z8.object({}))),
|
|
2414
|
+
outputSchema: lazySchema7(() => zodSchema7(z8.object({})))
|
|
2415
|
+
});
|
|
1614
2416
|
|
|
1615
2417
|
// src/tool/url-context.ts
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
2418
|
+
import {
|
|
2419
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
2420
|
+
lazySchema as lazySchema8,
|
|
2421
|
+
zodSchema as zodSchema8
|
|
2422
|
+
} from "@ai-sdk/provider-utils";
|
|
2423
|
+
import { z as z9 } from "zod/v4";
|
|
2424
|
+
var urlContext = createProviderExecutedToolFactory6({
|
|
1619
2425
|
id: "google.url_context",
|
|
1620
|
-
inputSchema: (
|
|
2426
|
+
inputSchema: lazySchema8(() => zodSchema8(z9.object({}))),
|
|
2427
|
+
outputSchema: lazySchema8(() => zodSchema8(z9.object({})))
|
|
1621
2428
|
});
|
|
1622
2429
|
|
|
1623
2430
|
// src/tool/vertex-rag-store.ts
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
2431
|
+
import {
|
|
2432
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
2433
|
+
lazySchema as lazySchema9,
|
|
2434
|
+
zodSchema as zodSchema9
|
|
2435
|
+
} from "@ai-sdk/provider-utils";
|
|
2436
|
+
import { z as z10 } from "zod/v4";
|
|
2437
|
+
var vertexRagStore = createProviderExecutedToolFactory7({
|
|
1627
2438
|
id: "google.vertex_rag_store",
|
|
1628
|
-
inputSchema:
|
|
1629
|
-
|
|
1630
|
-
topK: import_v410.z.number().optional()
|
|
1631
|
-
})
|
|
2439
|
+
inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
|
|
2440
|
+
outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
|
|
1632
2441
|
});
|
|
1633
2442
|
|
|
1634
2443
|
// src/google-tools.ts
|
|
@@ -1690,11 +2499,10 @@ var googleTools = {
|
|
|
1690
2499
|
*/
|
|
1691
2500
|
vertexRagStore
|
|
1692
2501
|
};
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
GoogleGenerativeAILanguageModel,
|
|
2502
|
+
export {
|
|
2503
|
+
GoogleLanguageModel,
|
|
1696
2504
|
getGroundingMetadataSchema,
|
|
1697
2505
|
getUrlContextMetadataSchema,
|
|
1698
2506
|
googleTools
|
|
1699
|
-
}
|
|
2507
|
+
};
|
|
1700
2508
|
//# sourceMappingURL=index.js.map
|