@ai-sdk/google 3.0.88 → 3.0.90
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 +20 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +140 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -25
- 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 +2902 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +2930 -3
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/convert-to-google-generative-ai-messages.ts +3 -3
- package/src/google-generative-ai-embedding-model.ts +1 -1
- 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/convert-to-google-interactions-input.ts +2 -2
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.90
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b585445: Backport Gemini Interactions video output parsing and per-modality output token breakdown for AI SDK v6.
|
|
8
|
+
- 1825ecc: Backport `vertex.interactions()` for the Gemini Interactions API on Vertex AI for AI SDK v6.
|
|
9
|
+
- afee362: Pass documented Gemini external HTTPS file URLs through without downloading them.
|
|
10
|
+
- 327642b: fix: more precise default message for tool execution denial
|
|
11
|
+
- Updated dependencies [d559de9]
|
|
12
|
+
- @ai-sdk/provider-utils@4.0.37
|
|
13
|
+
|
|
14
|
+
## 3.0.89
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 0952964: Prevent prototype pollution when synchronously parsing provider JSON inputs and expose `secureJsonParse` from provider-utils.
|
|
19
|
+
- f0bfb31: Fix Google embedding batch size to respect the Gemini API limit of 100 requests per batch.
|
|
20
|
+
- Updated dependencies [0952964]
|
|
21
|
+
- @ai-sdk/provider-utils@4.0.36
|
|
22
|
+
|
|
3
23
|
## 3.0.88
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -373,6 +373,13 @@ type GoogleInteractionsProviderMetadata = {
|
|
|
373
373
|
* Service tier used for this interaction (passthrough for observability).
|
|
374
374
|
*/
|
|
375
375
|
serviceTier?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Output token counts keyed by modality (e.g. `{ video: 57920 }`), sourced
|
|
378
|
+
* from the Interactions API `output_tokens_by_modality`. Present only when
|
|
379
|
+
* the response reports a breakdown. Preview surface for per-modality billing;
|
|
380
|
+
* may be promoted to a first-class usage field later.
|
|
381
|
+
*/
|
|
382
|
+
outputTokensByModality?: Record<string, number>;
|
|
376
383
|
/**
|
|
377
384
|
* Per-block signature hash for backend validation. Set by the SDK on output
|
|
378
385
|
* reasoning / tool-call parts and round-tripped on input parts.
|
package/dist/index.d.ts
CHANGED
|
@@ -373,6 +373,13 @@ type GoogleInteractionsProviderMetadata = {
|
|
|
373
373
|
* Service tier used for this interaction (passthrough for observability).
|
|
374
374
|
*/
|
|
375
375
|
serviceTier?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Output token counts keyed by modality (e.g. `{ video: 57920 }`), sourced
|
|
378
|
+
* from the Interactions API `output_tokens_by_modality`. Present only when
|
|
379
|
+
* the response reports a breakdown. Preview surface for per-modality billing;
|
|
380
|
+
* may be promoted to a first-class usage field later.
|
|
381
|
+
*/
|
|
382
|
+
outputTokensByModality?: Record<string, number>;
|
|
376
383
|
/**
|
|
377
384
|
* Per-block signature hash for backend validation. Set by the SDK on output
|
|
378
385
|
* reasoning / tool-call parts and round-tripped on input parts.
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.90" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -122,7 +122,7 @@ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
|
|
|
122
122
|
var GoogleGenerativeAIEmbeddingModel = class {
|
|
123
123
|
constructor(modelId, config) {
|
|
124
124
|
this.specificationVersion = "v3";
|
|
125
|
-
this.maxEmbeddingsPerCall =
|
|
125
|
+
this.maxEmbeddingsPerCall = 100;
|
|
126
126
|
this.supportsParallelCalls = true;
|
|
127
127
|
this.modelId = modelId;
|
|
128
128
|
this.config = config;
|
|
@@ -635,7 +635,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
635
635
|
return {
|
|
636
636
|
toolCall: {
|
|
637
637
|
toolType: serverToolType,
|
|
638
|
-
args: typeof part.input === "string" ?
|
|
638
|
+
args: typeof part.input === "string" ? (0, import_provider_utils4.secureJsonParse)(part.input) : part.input,
|
|
639
639
|
id: serverToolCallId
|
|
640
640
|
},
|
|
641
641
|
thoughtSignature: effectiveThoughtSignature
|
|
@@ -724,7 +724,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
724
724
|
name: part.toolName,
|
|
725
725
|
response: {
|
|
726
726
|
name: part.toolName,
|
|
727
|
-
content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool execution denied." : output.value
|
|
727
|
+
content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
730
|
});
|
|
@@ -3263,6 +3263,19 @@ function convertGoogleInteractionsUsage(usage) {
|
|
|
3263
3263
|
raw: usage
|
|
3264
3264
|
};
|
|
3265
3265
|
}
|
|
3266
|
+
function getGoogleInteractionsOutputTokensByModality(usage) {
|
|
3267
|
+
const byModality = usage == null ? void 0 : usage.output_tokens_by_modality;
|
|
3268
|
+
if (byModality == null) {
|
|
3269
|
+
return void 0;
|
|
3270
|
+
}
|
|
3271
|
+
const result = {};
|
|
3272
|
+
for (const entry of byModality) {
|
|
3273
|
+
if ((entry == null ? void 0 : entry.modality) != null && entry.tokens != null) {
|
|
3274
|
+
result[entry.modality] = entry.tokens;
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
3278
|
+
}
|
|
3266
3279
|
|
|
3267
3280
|
// src/interactions/extract-google-interactions-sources.ts
|
|
3268
3281
|
var KNOWN_DOC_EXTENSIONS = {
|
|
@@ -3514,7 +3527,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3514
3527
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3515
3528
|
},
|
|
3516
3529
|
transform(chunk, controller) {
|
|
3517
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3530
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3518
3531
|
if (includeRawChunks) {
|
|
3519
3532
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3520
3533
|
}
|
|
@@ -3703,9 +3716,37 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3703
3716
|
}
|
|
3704
3717
|
break;
|
|
3705
3718
|
}
|
|
3719
|
+
if (dtype === "video" && (open.kind === "pending_model_output" || open.kind === "text")) {
|
|
3720
|
+
const videoDelta = event.delta;
|
|
3721
|
+
const google2 = {};
|
|
3722
|
+
if (interactionId != null) google2.interactionId = interactionId;
|
|
3723
|
+
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
3724
|
+
if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
|
|
3725
|
+
controller.enqueue({
|
|
3726
|
+
type: "file",
|
|
3727
|
+
mediaType: (_m = videoDelta.mime_type) != null ? _m : "video/mp4",
|
|
3728
|
+
data: videoDelta.data,
|
|
3729
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3730
|
+
});
|
|
3731
|
+
} else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
|
|
3732
|
+
const uriProviderMetadata = {
|
|
3733
|
+
google: {
|
|
3734
|
+
...interactionId != null ? { interactionId } : {},
|
|
3735
|
+
videoUri: videoDelta.uri
|
|
3736
|
+
}
|
|
3737
|
+
};
|
|
3738
|
+
controller.enqueue({
|
|
3739
|
+
type: "file",
|
|
3740
|
+
mediaType: (_n = videoDelta.mime_type) != null ? _n : "video/mp4",
|
|
3741
|
+
data: "",
|
|
3742
|
+
providerMetadata: uriProviderMetadata
|
|
3743
|
+
});
|
|
3744
|
+
}
|
|
3745
|
+
break;
|
|
3746
|
+
}
|
|
3706
3747
|
const delta = event.delta;
|
|
3707
3748
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3708
|
-
const text = (
|
|
3749
|
+
const text = (_o = delta.text) != null ? _o : "";
|
|
3709
3750
|
if (text.length > 0) {
|
|
3710
3751
|
controller.enqueue({
|
|
3711
3752
|
type: "text-delta",
|
|
@@ -3808,7 +3849,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3808
3849
|
if (open.data != null && open.data.length > 0) {
|
|
3809
3850
|
controller.enqueue({
|
|
3810
3851
|
type: "file",
|
|
3811
|
-
mediaType: (
|
|
3852
|
+
mediaType: (_p = open.mimeType) != null ? _p : "image/png",
|
|
3812
3853
|
data: open.data,
|
|
3813
3854
|
...providerMetadata ? { providerMetadata } : {}
|
|
3814
3855
|
});
|
|
@@ -3821,7 +3862,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3821
3862
|
};
|
|
3822
3863
|
controller.enqueue({
|
|
3823
3864
|
type: "file",
|
|
3824
|
-
mediaType: (
|
|
3865
|
+
mediaType: (_q = open.mimeType) != null ? _q : "image/png",
|
|
3825
3866
|
data: "",
|
|
3826
3867
|
providerMetadata: uriProviderMetadata
|
|
3827
3868
|
});
|
|
@@ -3848,7 +3889,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3848
3889
|
type: "tool-call",
|
|
3849
3890
|
toolCallId: open.toolCallId,
|
|
3850
3891
|
toolName: open.toolName,
|
|
3851
|
-
input: JSON.stringify((
|
|
3892
|
+
input: JSON.stringify((_r = open.arguments) != null ? _r : {}),
|
|
3852
3893
|
providerExecuted: true
|
|
3853
3894
|
});
|
|
3854
3895
|
open.callEmitted = true;
|
|
@@ -3857,7 +3898,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3857
3898
|
type: "tool-result",
|
|
3858
3899
|
toolCallId: open.callId,
|
|
3859
3900
|
toolName: open.toolName,
|
|
3860
|
-
result: (
|
|
3901
|
+
result: (_s = open.result) != null ? _s : null
|
|
3861
3902
|
});
|
|
3862
3903
|
open.resultEmitted = true;
|
|
3863
3904
|
const sources = builtinToolResultToSources({
|
|
@@ -3911,7 +3952,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3911
3952
|
case "error": {
|
|
3912
3953
|
const event = value;
|
|
3913
3954
|
finishStatus = "failed";
|
|
3914
|
-
const errorPayload = (
|
|
3955
|
+
const errorPayload = (_t = event.error) != null ? _t : {
|
|
3915
3956
|
message: "Unknown interaction error"
|
|
3916
3957
|
};
|
|
3917
3958
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -3929,10 +3970,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3929
3970
|
}),
|
|
3930
3971
|
raw: finishStatus
|
|
3931
3972
|
};
|
|
3973
|
+
const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(usage);
|
|
3932
3974
|
const providerMetadata = {
|
|
3933
3975
|
google: {
|
|
3934
3976
|
...interactionId != null ? { interactionId } : {},
|
|
3935
|
-
...serviceTier != null ? { serviceTier } : {}
|
|
3977
|
+
...serviceTier != null ? { serviceTier } : {},
|
|
3978
|
+
...outputTokensByModality != null ? { outputTokensByModality } : {}
|
|
3936
3979
|
}
|
|
3937
3980
|
};
|
|
3938
3981
|
controller.enqueue({
|
|
@@ -4186,7 +4229,7 @@ function compactPromptForPreviousInteraction({
|
|
|
4186
4229
|
}
|
|
4187
4230
|
function safeParseToolArgs(input) {
|
|
4188
4231
|
try {
|
|
4189
|
-
const parsed =
|
|
4232
|
+
const parsed = (0, import_provider_utils16.secureJsonParse)(input);
|
|
4190
4233
|
if (parsed != null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
4191
4234
|
return parsed;
|
|
4192
4235
|
}
|
|
@@ -4421,9 +4464,16 @@ var contentBlockSchema = () => {
|
|
|
4421
4464
|
resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4422
4465
|
uri: import_v415.z.string().nullish()
|
|
4423
4466
|
}).loose();
|
|
4467
|
+
const videoContent = import_v415.z.object({
|
|
4468
|
+
type: import_v415.z.literal("video"),
|
|
4469
|
+
data: import_v415.z.string().nullish(),
|
|
4470
|
+
mime_type: import_v415.z.string().nullish(),
|
|
4471
|
+
uri: import_v415.z.string().nullish()
|
|
4472
|
+
}).loose();
|
|
4424
4473
|
return import_v415.z.union([
|
|
4425
4474
|
textContent,
|
|
4426
4475
|
imageContent,
|
|
4476
|
+
videoContent,
|
|
4427
4477
|
import_v415.z.object({ type: import_v415.z.string() }).loose()
|
|
4428
4478
|
]);
|
|
4429
4479
|
};
|
|
@@ -4570,6 +4620,12 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4570
4620
|
resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4571
4621
|
uri: import_v415.z.string().nullish()
|
|
4572
4622
|
}).loose();
|
|
4623
|
+
const stepDeltaVideo = import_v415.z.object({
|
|
4624
|
+
type: import_v415.z.literal("video"),
|
|
4625
|
+
data: import_v415.z.string().nullish(),
|
|
4626
|
+
mime_type: import_v415.z.string().nullish(),
|
|
4627
|
+
uri: import_v415.z.string().nullish()
|
|
4628
|
+
}).loose();
|
|
4573
4629
|
const stepDeltaBuiltinToolCall = import_v415.z.object({
|
|
4574
4630
|
type: import_v415.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4575
4631
|
id: import_v415.z.string().nullish(),
|
|
@@ -4592,6 +4648,7 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4592
4648
|
const stepDeltaUnion = import_v415.z.union([
|
|
4593
4649
|
stepDeltaText,
|
|
4594
4650
|
stepDeltaImage,
|
|
4651
|
+
stepDeltaVideo,
|
|
4595
4652
|
stepDeltaThoughtSummary,
|
|
4596
4653
|
stepDeltaThoughtSignature,
|
|
4597
4654
|
stepDeltaArgumentsDelta,
|
|
@@ -4880,7 +4937,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
4880
4937
|
generateId: generateId3,
|
|
4881
4938
|
interactionId
|
|
4882
4939
|
}) {
|
|
4883
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4940
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
4884
4941
|
const content = [];
|
|
4885
4942
|
let hasFunctionCall = false;
|
|
4886
4943
|
if (steps == null) {
|
|
@@ -4933,6 +4990,28 @@ function parseGoogleInteractionsOutputs({
|
|
|
4933
4990
|
}
|
|
4934
4991
|
});
|
|
4935
4992
|
}
|
|
4993
|
+
} else if (blockType === "video") {
|
|
4994
|
+
const video = block;
|
|
4995
|
+
if (video.data != null && video.data.length > 0) {
|
|
4996
|
+
content.push({
|
|
4997
|
+
type: "file",
|
|
4998
|
+
mediaType: (_e = video.mime_type) != null ? _e : "video/mp4",
|
|
4999
|
+
data: video.data,
|
|
5000
|
+
...googleProviderMetadata({ interactionId })
|
|
5001
|
+
});
|
|
5002
|
+
} else if (video.uri != null && video.uri.length > 0) {
|
|
5003
|
+
content.push({
|
|
5004
|
+
type: "file",
|
|
5005
|
+
mediaType: (_f = video.mime_type) != null ? _f : "video/mp4",
|
|
5006
|
+
data: "",
|
|
5007
|
+
providerMetadata: {
|
|
5008
|
+
google: {
|
|
5009
|
+
...interactionId != null ? { interactionId } : {},
|
|
5010
|
+
videoUri: video.uri
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
});
|
|
5014
|
+
}
|
|
4936
5015
|
}
|
|
4937
5016
|
}
|
|
4938
5017
|
break;
|
|
@@ -4960,7 +5039,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
4960
5039
|
type: "tool-call",
|
|
4961
5040
|
toolCallId: call.id,
|
|
4962
5041
|
toolName: call.name,
|
|
4963
|
-
input: JSON.stringify((
|
|
5042
|
+
input: JSON.stringify((_g = call.arguments) != null ? _g : {}),
|
|
4964
5043
|
...googleProviderMetadata({
|
|
4965
5044
|
signature: call.signature,
|
|
4966
5045
|
interactionId
|
|
@@ -4971,23 +5050,23 @@ function parseGoogleInteractionsOutputs({
|
|
|
4971
5050
|
default: {
|
|
4972
5051
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
4973
5052
|
const call = step;
|
|
4974
|
-
const toolName = type === "mcp_server_tool_call" ? (
|
|
4975
|
-
const input = JSON.stringify((
|
|
5053
|
+
const toolName = type === "mcp_server_tool_call" ? (_h = call.name) != null ? _h : "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
5054
|
+
const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
|
|
4976
5055
|
content.push({
|
|
4977
5056
|
type: "tool-call",
|
|
4978
|
-
toolCallId: (
|
|
5057
|
+
toolCallId: (_j = call.id) != null ? _j : generateId3(),
|
|
4979
5058
|
toolName,
|
|
4980
5059
|
input,
|
|
4981
5060
|
providerExecuted: true
|
|
4982
5061
|
});
|
|
4983
5062
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
4984
5063
|
const result = step;
|
|
4985
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
5064
|
+
const toolName = type === "mcp_server_tool_result" ? (_k = result.name) != null ? _k : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
4986
5065
|
content.push({
|
|
4987
5066
|
type: "tool-result",
|
|
4988
|
-
toolCallId: (
|
|
5067
|
+
toolCallId: (_l = result.call_id) != null ? _l : generateId3(),
|
|
4989
5068
|
toolName,
|
|
4990
|
-
result: (
|
|
5069
|
+
result: (_m = result.result) != null ? _m : null
|
|
4991
5070
|
});
|
|
4992
5071
|
const sources = builtinToolResultToSources({
|
|
4993
5072
|
block: step,
|
|
@@ -5871,10 +5950,14 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5871
5950
|
raw: response.status
|
|
5872
5951
|
};
|
|
5873
5952
|
const serviceTier = (_e = (_d = response.service_tier) != null ? _d : responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _e : void 0;
|
|
5953
|
+
const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(
|
|
5954
|
+
response.usage
|
|
5955
|
+
);
|
|
5874
5956
|
const providerMetadata = {
|
|
5875
5957
|
google: {
|
|
5876
5958
|
...interactionId != null ? { interactionId } : {},
|
|
5877
|
-
...serviceTier != null ? { serviceTier } : {}
|
|
5959
|
+
...serviceTier != null ? { serviceTier } : {},
|
|
5960
|
+
...outputTokensByModality != null ? { outputTokensByModality } : {}
|
|
5878
5961
|
}
|
|
5879
5962
|
};
|
|
5880
5963
|
let timestamp;
|
|
@@ -6038,6 +6121,34 @@ function pruneUndefined(obj) {
|
|
|
6038
6121
|
}
|
|
6039
6122
|
|
|
6040
6123
|
// src/google-provider.ts
|
|
6124
|
+
var supportedExternalUrlMediaTypes = [
|
|
6125
|
+
"text/html",
|
|
6126
|
+
"text/css",
|
|
6127
|
+
"text/plain",
|
|
6128
|
+
"text/xml",
|
|
6129
|
+
"text/csv",
|
|
6130
|
+
"text/rtf",
|
|
6131
|
+
"text/javascript",
|
|
6132
|
+
"application/json",
|
|
6133
|
+
"application/pdf",
|
|
6134
|
+
"image/bmp",
|
|
6135
|
+
"image/jpeg",
|
|
6136
|
+
"image/png",
|
|
6137
|
+
"image/webp",
|
|
6138
|
+
"video/mp4",
|
|
6139
|
+
"video/mpeg",
|
|
6140
|
+
"video/quicktime",
|
|
6141
|
+
"video/avi",
|
|
6142
|
+
"video/x-flv",
|
|
6143
|
+
"video/mpg",
|
|
6144
|
+
"video/webm",
|
|
6145
|
+
"video/wmv",
|
|
6146
|
+
"video/3gpp"
|
|
6147
|
+
];
|
|
6148
|
+
var externalHttpsUrlPattern = /^https:\/\/.*$/;
|
|
6149
|
+
function supportsExternalFileUrls(modelId) {
|
|
6150
|
+
return /(^|\/)gemini-/.test(modelId) && !/(^|\/)gemini-2\.0/.test(modelId);
|
|
6151
|
+
}
|
|
6041
6152
|
function createGoogleGenerativeAI(options = {}) {
|
|
6042
6153
|
var _a, _b;
|
|
6043
6154
|
const baseURL = (_a = (0, import_provider_utils23.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
@@ -6070,7 +6181,13 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6070
6181
|
`^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
|
|
6071
6182
|
),
|
|
6072
6183
|
new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
|
|
6073
|
-
]
|
|
6184
|
+
],
|
|
6185
|
+
...supportsExternalFileUrls(modelId) ? Object.fromEntries(
|
|
6186
|
+
supportedExternalUrlMediaTypes.map((mediaType) => [
|
|
6187
|
+
mediaType,
|
|
6188
|
+
[externalHttpsUrlPattern]
|
|
6189
|
+
])
|
|
6190
|
+
) : {}
|
|
6074
6191
|
}),
|
|
6075
6192
|
fetch: options.fetch
|
|
6076
6193
|
});
|