@ai-sdk/google 3.0.89 → 3.0.91
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 +22 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +165 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -33
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +54 -1
- package/dist/internal/index.d.ts +54 -1
- package/dist/internal/index.js +2919 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +2946 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/convert-to-google-generative-ai-messages.ts +9 -2
- package/src/google-generative-ai-language-model.ts +18 -1
- package/src/google-generative-ai-video-model.ts +11 -10
- package/src/google-provider.ts +39 -0
- package/src/interactions/build-google-interactions-stream-transform.ts +49 -1
- package/src/interactions/convert-google-interactions-usage.ts +22 -0
- package/src/interactions/google-interactions-api.ts +24 -0
- package/src/interactions/google-interactions-language-model.ts +9 -1
- package/src/interactions/google-interactions-provider-metadata.ts +8 -0
- package/src/interactions/parse-google-interactions-outputs.ts +33 -1
- package/src/internal/index.ts +6 -0
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.91" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -517,6 +517,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
517
517
|
});
|
|
518
518
|
break;
|
|
519
519
|
case "image-data":
|
|
520
|
+
case "file-data": {
|
|
521
|
+
const topLevelMediaType = String(contentPart.mediaType).split("/")[0];
|
|
520
522
|
parts.push(
|
|
521
523
|
{
|
|
522
524
|
inlineData: {
|
|
@@ -525,10 +527,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
525
527
|
}
|
|
526
528
|
},
|
|
527
529
|
{
|
|
528
|
-
text:
|
|
530
|
+
text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
|
|
529
531
|
}
|
|
530
532
|
);
|
|
531
533
|
break;
|
|
534
|
+
}
|
|
532
535
|
default:
|
|
533
536
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
534
537
|
break;
|
|
@@ -730,7 +733,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
730
733
|
name: part.toolName,
|
|
731
734
|
response: {
|
|
732
735
|
name: part.toolName,
|
|
733
|
-
content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool execution denied." : output.value
|
|
736
|
+
content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
|
|
734
737
|
}
|
|
735
738
|
}
|
|
736
739
|
});
|
|
@@ -1445,6 +1448,12 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1445
1448
|
}
|
|
1446
1449
|
|
|
1447
1450
|
// src/google-generative-ai-language-model.ts
|
|
1451
|
+
var configurableSafetySettingCategories = [
|
|
1452
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
|
1453
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
1454
|
+
"HARM_CATEGORY_HARASSMENT",
|
|
1455
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1456
|
+
];
|
|
1448
1457
|
var GoogleGenerativeAILanguageModel = class {
|
|
1449
1458
|
constructor(modelId, config) {
|
|
1450
1459
|
this.specificationVersion = "v3";
|
|
@@ -1475,7 +1484,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1475
1484
|
toolChoice,
|
|
1476
1485
|
providerOptions
|
|
1477
1486
|
}, { isStreaming = false } = {}) {
|
|
1478
|
-
var _a, _b;
|
|
1487
|
+
var _a, _b, _c;
|
|
1479
1488
|
const warnings = [];
|
|
1480
1489
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1481
1490
|
let googleOptions = await parseProviderOptions2({
|
|
@@ -1550,6 +1559,11 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1550
1559
|
isVertexProvider
|
|
1551
1560
|
});
|
|
1552
1561
|
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1562
|
+
const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
|
|
1563
|
+
const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
1564
|
+
category,
|
|
1565
|
+
threshold: safetyThreshold
|
|
1566
|
+
})) : void 0;
|
|
1553
1567
|
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
1554
1568
|
...googleToolConfig,
|
|
1555
1569
|
...streamFunctionCallArguments && {
|
|
@@ -1579,7 +1593,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1579
1593
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
1580
1594
|
// so this is needed as an escape hatch:
|
|
1581
1595
|
// TODO convert into provider option
|
|
1582
|
-
((
|
|
1596
|
+
((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
1583
1597
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
1584
1598
|
audioTimestamp: googleOptions.audioTimestamp
|
|
1585
1599
|
},
|
|
@@ -1595,7 +1609,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1595
1609
|
},
|
|
1596
1610
|
contents,
|
|
1597
1611
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
1598
|
-
safetySettings
|
|
1612
|
+
safetySettings,
|
|
1599
1613
|
tools: googleTools2,
|
|
1600
1614
|
toolConfig,
|
|
1601
1615
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
@@ -3012,31 +3026,32 @@ function convertFileToGoogleImage(file, warnings) {
|
|
|
3012
3026
|
}
|
|
3013
3027
|
const base64Data = typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data);
|
|
3014
3028
|
return {
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
data: base64Data
|
|
3018
|
-
}
|
|
3029
|
+
bytesBase64Encoded: base64Data,
|
|
3030
|
+
mimeType: file.mediaType || "image/png"
|
|
3019
3031
|
};
|
|
3020
3032
|
}
|
|
3021
3033
|
function convertProviderReferenceImage(refImg) {
|
|
3022
3034
|
if (refImg.bytesBase64Encoded) {
|
|
3023
3035
|
return {
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3036
|
+
image: {
|
|
3037
|
+
bytesBase64Encoded: refImg.bytesBase64Encoded,
|
|
3038
|
+
mimeType: "image/png"
|
|
3027
3039
|
}
|
|
3028
3040
|
};
|
|
3029
3041
|
}
|
|
3030
3042
|
if (refImg.gcsUri) {
|
|
3031
3043
|
return {
|
|
3032
|
-
|
|
3044
|
+
image: {
|
|
3045
|
+
gcsUri: refImg.gcsUri,
|
|
3046
|
+
mimeType: "image/png"
|
|
3047
|
+
}
|
|
3033
3048
|
};
|
|
3034
3049
|
}
|
|
3035
3050
|
return refImg;
|
|
3036
3051
|
}
|
|
3037
3052
|
function convertInputReferenceImage(file, warnings) {
|
|
3038
3053
|
const image = convertFileToGoogleImage(file, warnings);
|
|
3039
|
-
return image != null ? { image
|
|
3054
|
+
return image != null ? { image } : void 0;
|
|
3040
3055
|
}
|
|
3041
3056
|
var GoogleGenerativeAIVideoModel = class {
|
|
3042
3057
|
constructor(modelId, config) {
|
|
@@ -3326,6 +3341,19 @@ function convertGoogleInteractionsUsage(usage) {
|
|
|
3326
3341
|
raw: usage
|
|
3327
3342
|
};
|
|
3328
3343
|
}
|
|
3344
|
+
function getGoogleInteractionsOutputTokensByModality(usage) {
|
|
3345
|
+
const byModality = usage == null ? void 0 : usage.output_tokens_by_modality;
|
|
3346
|
+
if (byModality == null) {
|
|
3347
|
+
return void 0;
|
|
3348
|
+
}
|
|
3349
|
+
const result = {};
|
|
3350
|
+
for (const entry of byModality) {
|
|
3351
|
+
if ((entry == null ? void 0 : entry.modality) != null && entry.tokens != null) {
|
|
3352
|
+
result[entry.modality] = entry.tokens;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
3356
|
+
}
|
|
3329
3357
|
|
|
3330
3358
|
// src/interactions/extract-google-interactions-sources.ts
|
|
3331
3359
|
var KNOWN_DOC_EXTENSIONS = {
|
|
@@ -3577,7 +3605,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3577
3605
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3578
3606
|
},
|
|
3579
3607
|
transform(chunk, controller) {
|
|
3580
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3608
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3581
3609
|
if (includeRawChunks) {
|
|
3582
3610
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3583
3611
|
}
|
|
@@ -3766,9 +3794,37 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3766
3794
|
}
|
|
3767
3795
|
break;
|
|
3768
3796
|
}
|
|
3797
|
+
if (dtype === "video" && (open.kind === "pending_model_output" || open.kind === "text")) {
|
|
3798
|
+
const videoDelta = event.delta;
|
|
3799
|
+
const google2 = {};
|
|
3800
|
+
if (interactionId != null) google2.interactionId = interactionId;
|
|
3801
|
+
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
3802
|
+
if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
|
|
3803
|
+
controller.enqueue({
|
|
3804
|
+
type: "file",
|
|
3805
|
+
mediaType: (_m = videoDelta.mime_type) != null ? _m : "video/mp4",
|
|
3806
|
+
data: videoDelta.data,
|
|
3807
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3808
|
+
});
|
|
3809
|
+
} else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
|
|
3810
|
+
const uriProviderMetadata = {
|
|
3811
|
+
google: {
|
|
3812
|
+
...interactionId != null ? { interactionId } : {},
|
|
3813
|
+
videoUri: videoDelta.uri
|
|
3814
|
+
}
|
|
3815
|
+
};
|
|
3816
|
+
controller.enqueue({
|
|
3817
|
+
type: "file",
|
|
3818
|
+
mediaType: (_n = videoDelta.mime_type) != null ? _n : "video/mp4",
|
|
3819
|
+
data: "",
|
|
3820
|
+
providerMetadata: uriProviderMetadata
|
|
3821
|
+
});
|
|
3822
|
+
}
|
|
3823
|
+
break;
|
|
3824
|
+
}
|
|
3769
3825
|
const delta = event.delta;
|
|
3770
3826
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3771
|
-
const text = (
|
|
3827
|
+
const text = (_o = delta.text) != null ? _o : "";
|
|
3772
3828
|
if (text.length > 0) {
|
|
3773
3829
|
controller.enqueue({
|
|
3774
3830
|
type: "text-delta",
|
|
@@ -3871,7 +3927,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3871
3927
|
if (open.data != null && open.data.length > 0) {
|
|
3872
3928
|
controller.enqueue({
|
|
3873
3929
|
type: "file",
|
|
3874
|
-
mediaType: (
|
|
3930
|
+
mediaType: (_p = open.mimeType) != null ? _p : "image/png",
|
|
3875
3931
|
data: open.data,
|
|
3876
3932
|
...providerMetadata ? { providerMetadata } : {}
|
|
3877
3933
|
});
|
|
@@ -3884,7 +3940,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3884
3940
|
};
|
|
3885
3941
|
controller.enqueue({
|
|
3886
3942
|
type: "file",
|
|
3887
|
-
mediaType: (
|
|
3943
|
+
mediaType: (_q = open.mimeType) != null ? _q : "image/png",
|
|
3888
3944
|
data: "",
|
|
3889
3945
|
providerMetadata: uriProviderMetadata
|
|
3890
3946
|
});
|
|
@@ -3911,7 +3967,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3911
3967
|
type: "tool-call",
|
|
3912
3968
|
toolCallId: open.toolCallId,
|
|
3913
3969
|
toolName: open.toolName,
|
|
3914
|
-
input: JSON.stringify((
|
|
3970
|
+
input: JSON.stringify((_r = open.arguments) != null ? _r : {}),
|
|
3915
3971
|
providerExecuted: true
|
|
3916
3972
|
});
|
|
3917
3973
|
open.callEmitted = true;
|
|
@@ -3920,7 +3976,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3920
3976
|
type: "tool-result",
|
|
3921
3977
|
toolCallId: open.callId,
|
|
3922
3978
|
toolName: open.toolName,
|
|
3923
|
-
result: (
|
|
3979
|
+
result: (_s = open.result) != null ? _s : null
|
|
3924
3980
|
});
|
|
3925
3981
|
open.resultEmitted = true;
|
|
3926
3982
|
const sources = builtinToolResultToSources({
|
|
@@ -3974,7 +4030,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3974
4030
|
case "error": {
|
|
3975
4031
|
const event = value;
|
|
3976
4032
|
finishStatus = "failed";
|
|
3977
|
-
const errorPayload = (
|
|
4033
|
+
const errorPayload = (_t = event.error) != null ? _t : {
|
|
3978
4034
|
message: "Unknown interaction error"
|
|
3979
4035
|
};
|
|
3980
4036
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -3992,10 +4048,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3992
4048
|
}),
|
|
3993
4049
|
raw: finishStatus
|
|
3994
4050
|
};
|
|
4051
|
+
const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(usage);
|
|
3995
4052
|
const providerMetadata = {
|
|
3996
4053
|
google: {
|
|
3997
4054
|
...interactionId != null ? { interactionId } : {},
|
|
3998
|
-
...serviceTier != null ? { serviceTier } : {}
|
|
4055
|
+
...serviceTier != null ? { serviceTier } : {},
|
|
4056
|
+
...outputTokensByModality != null ? { outputTokensByModality } : {}
|
|
3999
4057
|
}
|
|
4000
4058
|
};
|
|
4001
4059
|
controller.enqueue({
|
|
@@ -4487,9 +4545,16 @@ var contentBlockSchema = () => {
|
|
|
4487
4545
|
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4488
4546
|
uri: z15.string().nullish()
|
|
4489
4547
|
}).loose();
|
|
4548
|
+
const videoContent = z15.object({
|
|
4549
|
+
type: z15.literal("video"),
|
|
4550
|
+
data: z15.string().nullish(),
|
|
4551
|
+
mime_type: z15.string().nullish(),
|
|
4552
|
+
uri: z15.string().nullish()
|
|
4553
|
+
}).loose();
|
|
4490
4554
|
return z15.union([
|
|
4491
4555
|
textContent,
|
|
4492
4556
|
imageContent,
|
|
4557
|
+
videoContent,
|
|
4493
4558
|
z15.object({ type: z15.string() }).loose()
|
|
4494
4559
|
]);
|
|
4495
4560
|
};
|
|
@@ -4636,6 +4701,12 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4636
4701
|
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4637
4702
|
uri: z15.string().nullish()
|
|
4638
4703
|
}).loose();
|
|
4704
|
+
const stepDeltaVideo = z15.object({
|
|
4705
|
+
type: z15.literal("video"),
|
|
4706
|
+
data: z15.string().nullish(),
|
|
4707
|
+
mime_type: z15.string().nullish(),
|
|
4708
|
+
uri: z15.string().nullish()
|
|
4709
|
+
}).loose();
|
|
4639
4710
|
const stepDeltaBuiltinToolCall = z15.object({
|
|
4640
4711
|
type: z15.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4641
4712
|
id: z15.string().nullish(),
|
|
@@ -4658,6 +4729,7 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4658
4729
|
const stepDeltaUnion = z15.union([
|
|
4659
4730
|
stepDeltaText,
|
|
4660
4731
|
stepDeltaImage,
|
|
4732
|
+
stepDeltaVideo,
|
|
4661
4733
|
stepDeltaThoughtSummary,
|
|
4662
4734
|
stepDeltaThoughtSignature,
|
|
4663
4735
|
stepDeltaArgumentsDelta,
|
|
@@ -4949,7 +5021,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
4949
5021
|
generateId: generateId3,
|
|
4950
5022
|
interactionId
|
|
4951
5023
|
}) {
|
|
4952
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5024
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
4953
5025
|
const content = [];
|
|
4954
5026
|
let hasFunctionCall = false;
|
|
4955
5027
|
if (steps == null) {
|
|
@@ -5002,6 +5074,28 @@ function parseGoogleInteractionsOutputs({
|
|
|
5002
5074
|
}
|
|
5003
5075
|
});
|
|
5004
5076
|
}
|
|
5077
|
+
} else if (blockType === "video") {
|
|
5078
|
+
const video = block;
|
|
5079
|
+
if (video.data != null && video.data.length > 0) {
|
|
5080
|
+
content.push({
|
|
5081
|
+
type: "file",
|
|
5082
|
+
mediaType: (_e = video.mime_type) != null ? _e : "video/mp4",
|
|
5083
|
+
data: video.data,
|
|
5084
|
+
...googleProviderMetadata({ interactionId })
|
|
5085
|
+
});
|
|
5086
|
+
} else if (video.uri != null && video.uri.length > 0) {
|
|
5087
|
+
content.push({
|
|
5088
|
+
type: "file",
|
|
5089
|
+
mediaType: (_f = video.mime_type) != null ? _f : "video/mp4",
|
|
5090
|
+
data: "",
|
|
5091
|
+
providerMetadata: {
|
|
5092
|
+
google: {
|
|
5093
|
+
...interactionId != null ? { interactionId } : {},
|
|
5094
|
+
videoUri: video.uri
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
});
|
|
5098
|
+
}
|
|
5005
5099
|
}
|
|
5006
5100
|
}
|
|
5007
5101
|
break;
|
|
@@ -5029,7 +5123,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5029
5123
|
type: "tool-call",
|
|
5030
5124
|
toolCallId: call.id,
|
|
5031
5125
|
toolName: call.name,
|
|
5032
|
-
input: JSON.stringify((
|
|
5126
|
+
input: JSON.stringify((_g = call.arguments) != null ? _g : {}),
|
|
5033
5127
|
...googleProviderMetadata({
|
|
5034
5128
|
signature: call.signature,
|
|
5035
5129
|
interactionId
|
|
@@ -5040,23 +5134,23 @@ function parseGoogleInteractionsOutputs({
|
|
|
5040
5134
|
default: {
|
|
5041
5135
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
5042
5136
|
const call = step;
|
|
5043
|
-
const toolName = type === "mcp_server_tool_call" ? (
|
|
5044
|
-
const input = JSON.stringify((
|
|
5137
|
+
const toolName = type === "mcp_server_tool_call" ? (_h = call.name) != null ? _h : "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
5138
|
+
const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
|
|
5045
5139
|
content.push({
|
|
5046
5140
|
type: "tool-call",
|
|
5047
|
-
toolCallId: (
|
|
5141
|
+
toolCallId: (_j = call.id) != null ? _j : generateId3(),
|
|
5048
5142
|
toolName,
|
|
5049
5143
|
input,
|
|
5050
5144
|
providerExecuted: true
|
|
5051
5145
|
});
|
|
5052
5146
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
5053
5147
|
const result = step;
|
|
5054
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
5148
|
+
const toolName = type === "mcp_server_tool_result" ? (_k = result.name) != null ? _k : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
5055
5149
|
content.push({
|
|
5056
5150
|
type: "tool-result",
|
|
5057
|
-
toolCallId: (
|
|
5151
|
+
toolCallId: (_l = result.call_id) != null ? _l : generateId3(),
|
|
5058
5152
|
toolName,
|
|
5059
|
-
result: (
|
|
5153
|
+
result: (_m = result.result) != null ? _m : null
|
|
5060
5154
|
});
|
|
5061
5155
|
const sources = builtinToolResultToSources({
|
|
5062
5156
|
block: step,
|
|
@@ -5954,10 +6048,14 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5954
6048
|
raw: response.status
|
|
5955
6049
|
};
|
|
5956
6050
|
const serviceTier = (_e = (_d = response.service_tier) != null ? _d : responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _e : void 0;
|
|
6051
|
+
const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(
|
|
6052
|
+
response.usage
|
|
6053
|
+
);
|
|
5957
6054
|
const providerMetadata = {
|
|
5958
6055
|
google: {
|
|
5959
6056
|
...interactionId != null ? { interactionId } : {},
|
|
5960
|
-
...serviceTier != null ? { serviceTier } : {}
|
|
6057
|
+
...serviceTier != null ? { serviceTier } : {},
|
|
6058
|
+
...outputTokensByModality != null ? { outputTokensByModality } : {}
|
|
5961
6059
|
}
|
|
5962
6060
|
};
|
|
5963
6061
|
let timestamp;
|
|
@@ -6121,6 +6219,34 @@ function pruneUndefined(obj) {
|
|
|
6121
6219
|
}
|
|
6122
6220
|
|
|
6123
6221
|
// src/google-provider.ts
|
|
6222
|
+
var supportedExternalUrlMediaTypes = [
|
|
6223
|
+
"text/html",
|
|
6224
|
+
"text/css",
|
|
6225
|
+
"text/plain",
|
|
6226
|
+
"text/xml",
|
|
6227
|
+
"text/csv",
|
|
6228
|
+
"text/rtf",
|
|
6229
|
+
"text/javascript",
|
|
6230
|
+
"application/json",
|
|
6231
|
+
"application/pdf",
|
|
6232
|
+
"image/bmp",
|
|
6233
|
+
"image/jpeg",
|
|
6234
|
+
"image/png",
|
|
6235
|
+
"image/webp",
|
|
6236
|
+
"video/mp4",
|
|
6237
|
+
"video/mpeg",
|
|
6238
|
+
"video/quicktime",
|
|
6239
|
+
"video/avi",
|
|
6240
|
+
"video/x-flv",
|
|
6241
|
+
"video/mpg",
|
|
6242
|
+
"video/webm",
|
|
6243
|
+
"video/wmv",
|
|
6244
|
+
"video/3gpp"
|
|
6245
|
+
];
|
|
6246
|
+
var externalHttpsUrlPattern = /^https:\/\/.*$/;
|
|
6247
|
+
function supportsExternalFileUrls(modelId) {
|
|
6248
|
+
return /(^|\/)gemini-/.test(modelId) && !/(^|\/)gemini-2\.0/.test(modelId);
|
|
6249
|
+
}
|
|
6124
6250
|
function createGoogleGenerativeAI(options = {}) {
|
|
6125
6251
|
var _a, _b;
|
|
6126
6252
|
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
@@ -6153,7 +6279,13 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6153
6279
|
`^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
|
|
6154
6280
|
),
|
|
6155
6281
|
new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
|
|
6156
|
-
]
|
|
6282
|
+
],
|
|
6283
|
+
...supportsExternalFileUrls(modelId) ? Object.fromEntries(
|
|
6284
|
+
supportedExternalUrlMediaTypes.map((mediaType) => [
|
|
6285
|
+
mediaType,
|
|
6286
|
+
[externalHttpsUrlPattern]
|
|
6287
|
+
])
|
|
6288
|
+
) : {}
|
|
6157
6289
|
}),
|
|
6158
6290
|
fetch: options.fetch
|
|
6159
6291
|
});
|