@ai-sdk/google 4.0.67 → 4.0.69
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 +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +412 -185
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +7 -1
- package/dist/internal/index.js +107 -15
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/download-tool-result-files.ts +124 -0
- package/src/google-batch.ts +193 -12
- package/src/google-language-model.ts +27 -8
- package/src/google-provider.ts +4 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.69" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -254,7 +254,8 @@ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
|
|
254
254
|
// src/google-batch.ts
|
|
255
255
|
import {
|
|
256
256
|
InvalidArgumentError,
|
|
257
|
-
InvalidResponseDataError
|
|
257
|
+
InvalidResponseDataError,
|
|
258
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
258
259
|
} from "@ai-sdk/provider";
|
|
259
260
|
import {
|
|
260
261
|
combineHeaders as combineHeaders3,
|
|
@@ -263,15 +264,17 @@ import {
|
|
|
263
264
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
264
265
|
generateId as generateId2,
|
|
265
266
|
getFromApi,
|
|
266
|
-
lazySchema as
|
|
267
|
+
lazySchema as lazySchema8,
|
|
267
268
|
normalizeBatchRequestCounts,
|
|
269
|
+
parseProviderOptions as parseProviderOptions3,
|
|
268
270
|
postJsonToApi as postJsonToApi3,
|
|
269
271
|
postToApi,
|
|
270
272
|
resolve as resolve3,
|
|
271
273
|
safeValidateTypes,
|
|
272
|
-
zodSchema as
|
|
274
|
+
zodSchema as zodSchema8,
|
|
275
|
+
convertToBase64 as convertToBase642
|
|
273
276
|
} from "@ai-sdk/provider-utils";
|
|
274
|
-
import { z as
|
|
277
|
+
import { z as z8 } from "zod/v4";
|
|
275
278
|
|
|
276
279
|
// src/get-model-path.ts
|
|
277
280
|
function getModelPath(modelId) {
|
|
@@ -1067,6 +1070,90 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
1067
1070
|
};
|
|
1068
1071
|
}
|
|
1069
1072
|
|
|
1073
|
+
// src/download-tool-result-files.ts
|
|
1074
|
+
import {
|
|
1075
|
+
detectMediaType,
|
|
1076
|
+
downloadBlob,
|
|
1077
|
+
isFullMediaType as isFullMediaType2
|
|
1078
|
+
} from "@ai-sdk/provider-utils";
|
|
1079
|
+
async function downloadToolResultFiles(prompt, {
|
|
1080
|
+
abortSignal,
|
|
1081
|
+
maxBytes
|
|
1082
|
+
}) {
|
|
1083
|
+
const result = [];
|
|
1084
|
+
for (const message of prompt) {
|
|
1085
|
+
if (message.role === "assistant") {
|
|
1086
|
+
const content = [];
|
|
1087
|
+
for (const part of message.content) {
|
|
1088
|
+
content.push(
|
|
1089
|
+
part.type === "tool-result" ? {
|
|
1090
|
+
...part,
|
|
1091
|
+
output: await downloadToolResultOutput(part.output, {
|
|
1092
|
+
abortSignal,
|
|
1093
|
+
maxBytes
|
|
1094
|
+
})
|
|
1095
|
+
} : part
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
result.push({ ...message, content });
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1101
|
+
if (message.role === "tool") {
|
|
1102
|
+
const content = [];
|
|
1103
|
+
for (const part of message.content) {
|
|
1104
|
+
if (part.type !== "tool-result") {
|
|
1105
|
+
content.push(part);
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
content.push({
|
|
1109
|
+
...part,
|
|
1110
|
+
output: await downloadToolResultOutput(part.output, {
|
|
1111
|
+
abortSignal,
|
|
1112
|
+
maxBytes
|
|
1113
|
+
})
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
result.push({ ...message, content });
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
result.push(message);
|
|
1120
|
+
}
|
|
1121
|
+
return result;
|
|
1122
|
+
}
|
|
1123
|
+
async function downloadToolResultOutput(output, {
|
|
1124
|
+
abortSignal,
|
|
1125
|
+
maxBytes
|
|
1126
|
+
}) {
|
|
1127
|
+
if (output.type !== "content") {
|
|
1128
|
+
return output;
|
|
1129
|
+
}
|
|
1130
|
+
const value = [];
|
|
1131
|
+
for (const part of output.value) {
|
|
1132
|
+
if (part.type !== "file" || part.data.type !== "url") {
|
|
1133
|
+
value.push(part);
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
const blob = await downloadBlob(part.data.url.toString(), {
|
|
1137
|
+
abortSignal,
|
|
1138
|
+
maxBytes
|
|
1139
|
+
});
|
|
1140
|
+
const data = new Uint8Array(await blob.arrayBuffer());
|
|
1141
|
+
const detectedMediaType = detectMediaType({
|
|
1142
|
+
data,
|
|
1143
|
+
topLevelType: "image"
|
|
1144
|
+
});
|
|
1145
|
+
value.push({
|
|
1146
|
+
...part,
|
|
1147
|
+
data: { type: "data", data },
|
|
1148
|
+
mediaType: detectedMediaType != null ? detectedMediaType : blob.type && !isFullMediaType2(part.mediaType) ? blob.type : part.mediaType
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
return {
|
|
1152
|
+
...output,
|
|
1153
|
+
value
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1070
1157
|
// src/google-language-model-options.ts
|
|
1071
1158
|
import {
|
|
1072
1159
|
lazySchema as lazySchema4,
|
|
@@ -1855,7 +1942,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1855
1942
|
tools,
|
|
1856
1943
|
toolChoice,
|
|
1857
1944
|
reasoning,
|
|
1858
|
-
providerOptions
|
|
1945
|
+
providerOptions,
|
|
1946
|
+
abortSignal
|
|
1859
1947
|
},
|
|
1860
1948
|
isStreaming = false
|
|
1861
1949
|
}) {
|
|
@@ -1952,14 +2040,21 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1952
2040
|
});
|
|
1953
2041
|
}
|
|
1954
2042
|
const { usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
1955
|
-
const
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2043
|
+
const promptWithDownloadedToolResultFiles = config.downloadToolResultFiles ? await downloadToolResultFiles(prompt, {
|
|
2044
|
+
abortSignal,
|
|
2045
|
+
maxBytes: config.downloadToolResultFiles.maxBytes
|
|
2046
|
+
}) : prompt;
|
|
2047
|
+
const { contents, systemInstruction } = convertToGoogleMessages(
|
|
2048
|
+
promptWithDownloadedToolResultFiles,
|
|
2049
|
+
{
|
|
2050
|
+
isGemmaModel,
|
|
2051
|
+
isGemini3Model: usesGemini3Features,
|
|
2052
|
+
onWarning: (warning) => warnings.push(warning),
|
|
2053
|
+
providerOptionsNames,
|
|
2054
|
+
supportsFunctionResponseParts: usesGemini3Features,
|
|
2055
|
+
includeFunctionCallIds: !isVertexProvider
|
|
2056
|
+
}
|
|
2057
|
+
);
|
|
1963
2058
|
const {
|
|
1964
2059
|
tools: googleTools2,
|
|
1965
2060
|
toolConfig: googleToolConfig,
|
|
@@ -3066,86 +3161,142 @@ var chunkSchema = lazySchema5(
|
|
|
3066
3161
|
)
|
|
3067
3162
|
);
|
|
3068
3163
|
|
|
3164
|
+
// src/google-image-model-options.ts
|
|
3165
|
+
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
3166
|
+
import { z as z7 } from "zod/v4";
|
|
3167
|
+
|
|
3168
|
+
// src/tool/google-search.ts
|
|
3169
|
+
import {
|
|
3170
|
+
createProviderExecutedToolFactory,
|
|
3171
|
+
lazySchema as lazySchema6,
|
|
3172
|
+
zodSchema as zodSchema6
|
|
3173
|
+
} from "@ai-sdk/provider-utils";
|
|
3174
|
+
import { z as z6 } from "zod/v4";
|
|
3175
|
+
var googleSearchToolArgsBaseSchema = z6.looseObject({
|
|
3176
|
+
searchTypes: z6.object({
|
|
3177
|
+
webSearch: z6.object({}).optional(),
|
|
3178
|
+
imageSearch: z6.object({}).optional()
|
|
3179
|
+
}).optional(),
|
|
3180
|
+
timeRangeFilter: z6.object({
|
|
3181
|
+
startTime: z6.string(),
|
|
3182
|
+
endTime: z6.string()
|
|
3183
|
+
}).optional()
|
|
3184
|
+
});
|
|
3185
|
+
var googleSearch = createProviderExecutedToolFactory({
|
|
3186
|
+
id: "google.google_search",
|
|
3187
|
+
inputSchema: lazySchema6(() => zodSchema6(z6.object({}))),
|
|
3188
|
+
outputSchema: lazySchema6(() => zodSchema6(z6.object({})))
|
|
3189
|
+
});
|
|
3190
|
+
|
|
3191
|
+
// src/google-image-model-options.ts
|
|
3192
|
+
var googleImageModelOptionsSchema = lazySchema7(
|
|
3193
|
+
() => zodSchema7(
|
|
3194
|
+
z7.object({
|
|
3195
|
+
/**
|
|
3196
|
+
* Enable Google Search grounding for Gemini image models. The value is
|
|
3197
|
+
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
3198
|
+
* tool on the underlying language-model call. Pass `{}` for defaults.
|
|
3199
|
+
*
|
|
3200
|
+
* `generateImage` does not accept a `tools` parameter, so this is the
|
|
3201
|
+
* dedicated escape hatch for grounding image generation the same way
|
|
3202
|
+
* `generateText` does.
|
|
3203
|
+
*/
|
|
3204
|
+
googleSearch: googleSearchToolArgsBaseSchema.optional()
|
|
3205
|
+
})
|
|
3206
|
+
)
|
|
3207
|
+
);
|
|
3208
|
+
|
|
3069
3209
|
// src/google-batch.ts
|
|
3070
3210
|
var googleBatchInputFileMaxBytes = 2 * 1024 * 1024 * 1024;
|
|
3071
3211
|
var googleBatchInlineCreationMaxBytes = 2e7;
|
|
3072
3212
|
var supportedGoogleBatchContentTypes = /* @__PURE__ */ new Set(["text", "reasoning", "source", "tool-call", "tool-result"]);
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3213
|
+
function assertSupportedBatchRequests(requests) {
|
|
3214
|
+
for (const request of requests) {
|
|
3215
|
+
const requestType = request.type;
|
|
3216
|
+
if (requestType !== "text" && requestType !== "image") {
|
|
3217
|
+
throw new UnsupportedFunctionalityError4({
|
|
3218
|
+
functionality: `batch request type: ${requestType}`,
|
|
3219
|
+
message: `The Google Batch API does not support batch requests with type "${requestType}".`
|
|
3220
|
+
});
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
var googleRpcStatusSchema = z8.object({
|
|
3225
|
+
code: z8.union([z8.number(), z8.string()]).nullish(),
|
|
3226
|
+
message: z8.string().nullish(),
|
|
3227
|
+
status: z8.string().nullish()
|
|
3077
3228
|
});
|
|
3078
|
-
var googleBatchStatsSchema =
|
|
3079
|
-
requestCount:
|
|
3080
|
-
successfulRequestCount:
|
|
3081
|
-
failedRequestCount:
|
|
3082
|
-
pendingRequestCount:
|
|
3229
|
+
var googleBatchStatsSchema = z8.object({
|
|
3230
|
+
requestCount: z8.union([z8.string(), z8.number()]).nullish(),
|
|
3231
|
+
successfulRequestCount: z8.union([z8.string(), z8.number()]).nullish(),
|
|
3232
|
+
failedRequestCount: z8.union([z8.string(), z8.number()]).nullish(),
|
|
3233
|
+
pendingRequestCount: z8.union([z8.string(), z8.number()]).nullish()
|
|
3083
3234
|
});
|
|
3084
|
-
var googleBatchOutputSchema =
|
|
3085
|
-
responsesFile:
|
|
3086
|
-
inlinedResponses:
|
|
3087
|
-
inlinedResponses:
|
|
3088
|
-
|
|
3089
|
-
metadata:
|
|
3090
|
-
key:
|
|
3235
|
+
var googleBatchOutputSchema = z8.object({
|
|
3236
|
+
responsesFile: z8.string().nullish(),
|
|
3237
|
+
inlinedResponses: z8.object({
|
|
3238
|
+
inlinedResponses: z8.array(
|
|
3239
|
+
z8.object({
|
|
3240
|
+
metadata: z8.object({
|
|
3241
|
+
key: z8.string()
|
|
3091
3242
|
}),
|
|
3092
|
-
response:
|
|
3243
|
+
response: z8.unknown().nullish(),
|
|
3093
3244
|
error: googleRpcStatusSchema.nullish()
|
|
3094
3245
|
})
|
|
3095
3246
|
)
|
|
3096
3247
|
}).nullish()
|
|
3097
3248
|
});
|
|
3098
|
-
var googleBatchOperationZodSchema = () =>
|
|
3099
|
-
name:
|
|
3100
|
-
metadata:
|
|
3101
|
-
state:
|
|
3102
|
-
createTime:
|
|
3249
|
+
var googleBatchOperationZodSchema = () => z8.object({
|
|
3250
|
+
name: z8.string(),
|
|
3251
|
+
metadata: z8.object({
|
|
3252
|
+
state: z8.string().nullish(),
|
|
3253
|
+
createTime: z8.string().nullish(),
|
|
3103
3254
|
batchStats: googleBatchStatsSchema.nullish(),
|
|
3104
3255
|
output: googleBatchOutputSchema.nullish()
|
|
3105
3256
|
}).nullish(),
|
|
3106
|
-
done:
|
|
3257
|
+
done: z8.boolean().nullish(),
|
|
3107
3258
|
error: googleRpcStatusSchema.nullish(),
|
|
3108
3259
|
response: googleBatchOutputSchema.nullish()
|
|
3109
3260
|
});
|
|
3110
|
-
var googleBatchOperationSchema =
|
|
3111
|
-
() =>
|
|
3261
|
+
var googleBatchOperationSchema = lazySchema8(
|
|
3262
|
+
() => zodSchema8(googleBatchOperationZodSchema())
|
|
3112
3263
|
);
|
|
3113
|
-
var googleBatchListResponseSchema =
|
|
3114
|
-
() =>
|
|
3115
|
-
|
|
3116
|
-
operations:
|
|
3117
|
-
nextPageToken:
|
|
3264
|
+
var googleBatchListResponseSchema = lazySchema8(
|
|
3265
|
+
() => zodSchema8(
|
|
3266
|
+
z8.object({
|
|
3267
|
+
operations: z8.array(googleBatchOperationZodSchema()).nullish(),
|
|
3268
|
+
nextPageToken: z8.string().nullish()
|
|
3118
3269
|
})
|
|
3119
3270
|
)
|
|
3120
3271
|
);
|
|
3121
|
-
var googleBatchCancelResponseSchema =
|
|
3122
|
-
() =>
|
|
3272
|
+
var googleBatchCancelResponseSchema = lazySchema8(
|
|
3273
|
+
() => zodSchema8(z8.object({}))
|
|
3123
3274
|
);
|
|
3124
|
-
var googleFileUploadResponseSchema =
|
|
3125
|
-
() =>
|
|
3126
|
-
|
|
3127
|
-
file:
|
|
3128
|
-
name:
|
|
3129
|
-
expirationTime:
|
|
3275
|
+
var googleFileUploadResponseSchema = lazySchema8(
|
|
3276
|
+
() => zodSchema8(
|
|
3277
|
+
z8.object({
|
|
3278
|
+
file: z8.object({
|
|
3279
|
+
name: z8.string(),
|
|
3280
|
+
expirationTime: z8.string().nullish()
|
|
3130
3281
|
})
|
|
3131
3282
|
})
|
|
3132
3283
|
)
|
|
3133
3284
|
);
|
|
3134
|
-
var googleBatchResultLineSchema =
|
|
3135
|
-
() =>
|
|
3136
|
-
|
|
3137
|
-
key:
|
|
3138
|
-
response:
|
|
3285
|
+
var googleBatchResultLineSchema = lazySchema8(
|
|
3286
|
+
() => zodSchema8(
|
|
3287
|
+
z8.object({
|
|
3288
|
+
key: z8.string(),
|
|
3289
|
+
response: z8.unknown().nullish(),
|
|
3139
3290
|
error: googleRpcStatusSchema.nullish()
|
|
3140
3291
|
})
|
|
3141
3292
|
)
|
|
3142
3293
|
);
|
|
3143
|
-
var googleBatchResponsePreviewSchema =
|
|
3144
|
-
() =>
|
|
3145
|
-
|
|
3146
|
-
candidates:
|
|
3147
|
-
promptFeedback:
|
|
3148
|
-
blockReason:
|
|
3294
|
+
var googleBatchResponsePreviewSchema = lazySchema8(
|
|
3295
|
+
() => zodSchema8(
|
|
3296
|
+
z8.object({
|
|
3297
|
+
candidates: z8.array(z8.unknown()).nullish(),
|
|
3298
|
+
promptFeedback: z8.object({
|
|
3299
|
+
blockReason: z8.string().nullish()
|
|
3149
3300
|
}).nullish()
|
|
3150
3301
|
})
|
|
3151
3302
|
)
|
|
@@ -3160,6 +3311,7 @@ var GoogleBatch = class {
|
|
|
3160
3311
|
this.batchGenerateId = (_a = options.config.generateId) != null ? _a : generateId2;
|
|
3161
3312
|
}
|
|
3162
3313
|
async doStartBatch(options) {
|
|
3314
|
+
assertSupportedBatchRequests(options.requests);
|
|
3163
3315
|
const modelId = getGoogleBatchModelId(options.requests);
|
|
3164
3316
|
const warnings = [];
|
|
3165
3317
|
const displayName = `ai-sdk-batch-${this.batchGenerateId()}`;
|
|
@@ -3181,11 +3333,11 @@ var GoogleBatch = class {
|
|
|
3181
3333
|
).byteLength;
|
|
3182
3334
|
let fileParts;
|
|
3183
3335
|
for (const request of options.requests) {
|
|
3184
|
-
const preparedRequest = await GoogleLanguageModel.prepareRequest({
|
|
3336
|
+
const preparedRequest = request.type === "text" ? await GoogleLanguageModel.prepareRequest({
|
|
3185
3337
|
modelId: request.modelId,
|
|
3186
3338
|
config: this.batchConfig,
|
|
3187
3339
|
options: request.options
|
|
3188
|
-
});
|
|
3340
|
+
}) : await this.prepareImageRequest(request);
|
|
3189
3341
|
const inlinedRequest = {
|
|
3190
3342
|
request: preparedRequest.args,
|
|
3191
3343
|
metadata: { key: request.id }
|
|
@@ -3518,6 +3670,16 @@ var GoogleBatch = class {
|
|
|
3518
3670
|
warnings: [],
|
|
3519
3671
|
providerOptionsNames: ["google"]
|
|
3520
3672
|
});
|
|
3673
|
+
const imageResult = convertGoogleImageBatchResult(result);
|
|
3674
|
+
if (imageResult != null) {
|
|
3675
|
+
yield {
|
|
3676
|
+
type: "image",
|
|
3677
|
+
id: line.key,
|
|
3678
|
+
status: "succeeded",
|
|
3679
|
+
result: imageResult
|
|
3680
|
+
};
|
|
3681
|
+
continue;
|
|
3682
|
+
}
|
|
3521
3683
|
const unsupportedPart = result.content.find(
|
|
3522
3684
|
(part) => !supportedGoogleBatchContentTypes.has(part.type)
|
|
3523
3685
|
);
|
|
@@ -3536,6 +3698,91 @@ var GoogleBatch = class {
|
|
|
3536
3698
|
yield { type: "text", id: line.key, status: "succeeded", result };
|
|
3537
3699
|
}
|
|
3538
3700
|
}
|
|
3701
|
+
async prepareImageRequest(request) {
|
|
3702
|
+
var _a;
|
|
3703
|
+
const { prompt, n, size, aspectRatio, seed, files, mask, providerOptions } = request.options;
|
|
3704
|
+
const warnings = [];
|
|
3705
|
+
if (mask != null) {
|
|
3706
|
+
throw new UnsupportedFunctionalityError4({
|
|
3707
|
+
functionality: "mask-based image editing in Google batches"
|
|
3708
|
+
});
|
|
3709
|
+
}
|
|
3710
|
+
if (n > 1) {
|
|
3711
|
+
throw new UnsupportedFunctionalityError4({
|
|
3712
|
+
functionality: "multiple images per Google batch request"
|
|
3713
|
+
});
|
|
3714
|
+
}
|
|
3715
|
+
if (size != null) {
|
|
3716
|
+
warnings.push({
|
|
3717
|
+
type: "unsupported",
|
|
3718
|
+
feature: "size",
|
|
3719
|
+
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3722
|
+
const userContent = [];
|
|
3723
|
+
if (prompt != null) userContent.push({ type: "text", text: prompt });
|
|
3724
|
+
for (const file of files != null ? files : []) {
|
|
3725
|
+
userContent.push(
|
|
3726
|
+
file.type === "url" ? {
|
|
3727
|
+
type: "file",
|
|
3728
|
+
data: { type: "url", url: new URL(file.url) },
|
|
3729
|
+
mediaType: "image/*"
|
|
3730
|
+
} : {
|
|
3731
|
+
type: "file",
|
|
3732
|
+
data: { type: "data", data: file.data },
|
|
3733
|
+
mediaType: file.mediaType
|
|
3734
|
+
}
|
|
3735
|
+
);
|
|
3736
|
+
}
|
|
3737
|
+
const googleImageOptions = await parseProviderOptions3({
|
|
3738
|
+
provider: "google",
|
|
3739
|
+
providerOptions,
|
|
3740
|
+
schema: googleImageModelOptionsSchema
|
|
3741
|
+
});
|
|
3742
|
+
const {
|
|
3743
|
+
responseModalities: _responseModalities,
|
|
3744
|
+
imageConfig: userImageConfig,
|
|
3745
|
+
...passthroughGoogleOptions
|
|
3746
|
+
} = (_a = await parseProviderOptions3({
|
|
3747
|
+
provider: "google",
|
|
3748
|
+
providerOptions,
|
|
3749
|
+
schema: googleLanguageModelOptions
|
|
3750
|
+
})) != null ? _a : {};
|
|
3751
|
+
const preparedGoogleOptions = await parseProviderOptions3({
|
|
3752
|
+
provider: "google",
|
|
3753
|
+
providerOptions: {
|
|
3754
|
+
google: {
|
|
3755
|
+
...passthroughGoogleOptions,
|
|
3756
|
+
responseModalities: ["IMAGE"],
|
|
3757
|
+
imageConfig: aspectRatio != null || userImageConfig != null ? {
|
|
3758
|
+
...userImageConfig,
|
|
3759
|
+
...aspectRatio != null ? { aspectRatio } : {}
|
|
3760
|
+
} : void 0
|
|
3761
|
+
}
|
|
3762
|
+
},
|
|
3763
|
+
schema: googleLanguageModelOptions
|
|
3764
|
+
});
|
|
3765
|
+
const prepared = await GoogleLanguageModel.prepareRequest({
|
|
3766
|
+
modelId: request.modelId,
|
|
3767
|
+
config: this.batchConfig,
|
|
3768
|
+
options: {
|
|
3769
|
+
prompt: [{ role: "user", content: userContent }],
|
|
3770
|
+
seed,
|
|
3771
|
+
providerOptions: {
|
|
3772
|
+
google: preparedGoogleOptions != null ? preparedGoogleOptions : { responseModalities: ["IMAGE"] }
|
|
3773
|
+
},
|
|
3774
|
+
tools: (googleImageOptions == null ? void 0 : googleImageOptions.googleSearch) != null ? [
|
|
3775
|
+
{
|
|
3776
|
+
type: "provider",
|
|
3777
|
+
id: "google.google_search",
|
|
3778
|
+
name: "google_search",
|
|
3779
|
+
args: googleImageOptions.googleSearch
|
|
3780
|
+
}
|
|
3781
|
+
] : void 0
|
|
3782
|
+
}
|
|
3783
|
+
});
|
|
3784
|
+
return { ...prepared, warnings: [...warnings, ...prepared.warnings] };
|
|
3785
|
+
}
|
|
3539
3786
|
async getHeaders(headers) {
|
|
3540
3787
|
return combineHeaders3(
|
|
3541
3788
|
this.batchConfig.headers ? await resolve3(this.batchConfig.headers) : void 0,
|
|
@@ -3648,124 +3895,126 @@ function getGoogleBatchModelId(requests) {
|
|
|
3648
3895
|
}
|
|
3649
3896
|
return modelId;
|
|
3650
3897
|
}
|
|
3898
|
+
function convertGoogleImageBatchResult(result) {
|
|
3899
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3900
|
+
const images = result.content.flatMap(
|
|
3901
|
+
(part) => part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data" ? [convertToBase642(part.data.data)] : []
|
|
3902
|
+
);
|
|
3903
|
+
if (images.length === 0) return void 0;
|
|
3904
|
+
const googleMetadata = (_b = (_a = result.providerMetadata) == null ? void 0 : _a.google) != null ? _b : {};
|
|
3905
|
+
return {
|
|
3906
|
+
images,
|
|
3907
|
+
warnings: result.warnings,
|
|
3908
|
+
providerMetadata: {
|
|
3909
|
+
google: { ...googleMetadata, images: images.map(() => ({})) }
|
|
3910
|
+
},
|
|
3911
|
+
response: {
|
|
3912
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3913
|
+
modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : "",
|
|
3914
|
+
headers: (_e = result.response) == null ? void 0 : _e.headers
|
|
3915
|
+
},
|
|
3916
|
+
usage: {
|
|
3917
|
+
inputTokens: result.usage.inputTokens.total,
|
|
3918
|
+
outputTokens: result.usage.outputTokens.total,
|
|
3919
|
+
totalTokens: ((_f = result.usage.inputTokens.total) != null ? _f : 0) + ((_g = result.usage.outputTokens.total) != null ? _g : 0)
|
|
3920
|
+
}
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3651
3923
|
|
|
3652
3924
|
// src/tool/code-execution.ts
|
|
3653
|
-
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
3654
|
-
import { z as
|
|
3655
|
-
var codeExecution =
|
|
3925
|
+
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
3926
|
+
import { z as z9 } from "zod/v4";
|
|
3927
|
+
var codeExecution = createProviderExecutedToolFactory2({
|
|
3656
3928
|
id: "google.code_execution",
|
|
3657
|
-
inputSchema:
|
|
3658
|
-
language:
|
|
3659
|
-
code:
|
|
3929
|
+
inputSchema: z9.object({
|
|
3930
|
+
language: z9.string().describe("The programming language of the code."),
|
|
3931
|
+
code: z9.string().describe("The code to be executed.")
|
|
3660
3932
|
}),
|
|
3661
|
-
outputSchema:
|
|
3662
|
-
outcome:
|
|
3663
|
-
output:
|
|
3933
|
+
outputSchema: z9.object({
|
|
3934
|
+
outcome: z9.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
3935
|
+
output: z9.string().describe("The output from the code execution.")
|
|
3664
3936
|
})
|
|
3665
3937
|
});
|
|
3666
3938
|
|
|
3667
3939
|
// src/tool/enterprise-web-search.ts
|
|
3668
3940
|
import {
|
|
3669
|
-
createProviderExecutedToolFactory as
|
|
3670
|
-
lazySchema as
|
|
3671
|
-
zodSchema as
|
|
3941
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
3942
|
+
lazySchema as lazySchema9,
|
|
3943
|
+
zodSchema as zodSchema9
|
|
3672
3944
|
} from "@ai-sdk/provider-utils";
|
|
3673
|
-
import { z as
|
|
3674
|
-
var enterpriseWebSearch =
|
|
3945
|
+
import { z as z10 } from "zod/v4";
|
|
3946
|
+
var enterpriseWebSearch = createProviderExecutedToolFactory3({
|
|
3675
3947
|
id: "google.enterprise_web_search",
|
|
3676
|
-
inputSchema:
|
|
3677
|
-
outputSchema:
|
|
3948
|
+
inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
|
|
3949
|
+
outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
|
|
3678
3950
|
});
|
|
3679
3951
|
|
|
3680
3952
|
// src/tool/file-search.ts
|
|
3681
3953
|
import {
|
|
3682
|
-
createProviderExecutedToolFactory as
|
|
3683
|
-
lazySchema as
|
|
3684
|
-
zodSchema as
|
|
3954
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
3955
|
+
lazySchema as lazySchema10,
|
|
3956
|
+
zodSchema as zodSchema10
|
|
3685
3957
|
} from "@ai-sdk/provider-utils";
|
|
3686
|
-
import { z as
|
|
3687
|
-
var fileSearchArgsBaseSchema =
|
|
3958
|
+
import { z as z11 } from "zod/v4";
|
|
3959
|
+
var fileSearchArgsBaseSchema = z11.looseObject({
|
|
3688
3960
|
/** The names of the file_search_stores to retrieve from.
|
|
3689
3961
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
3690
3962
|
*/
|
|
3691
|
-
fileSearchStoreNames:
|
|
3963
|
+
fileSearchStoreNames: z11.array(z11.string()).describe(
|
|
3692
3964
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
3693
3965
|
),
|
|
3694
3966
|
/** The number of file search retrieval chunks to retrieve. */
|
|
3695
|
-
topK:
|
|
3967
|
+
topK: z11.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
3696
3968
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
3697
3969
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
3698
3970
|
*/
|
|
3699
|
-
metadataFilter:
|
|
3971
|
+
metadataFilter: z11.string().describe(
|
|
3700
3972
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
3701
3973
|
).optional()
|
|
3702
3974
|
});
|
|
3703
|
-
var fileSearch =
|
|
3975
|
+
var fileSearch = createProviderExecutedToolFactory4({
|
|
3704
3976
|
id: "google.file_search",
|
|
3705
|
-
inputSchema:
|
|
3706
|
-
outputSchema:
|
|
3977
|
+
inputSchema: lazySchema10(() => zodSchema10(z11.object({}))),
|
|
3978
|
+
outputSchema: lazySchema10(() => zodSchema10(z11.object({})))
|
|
3707
3979
|
});
|
|
3708
3980
|
|
|
3709
3981
|
// src/tool/google-maps.ts
|
|
3710
|
-
import {
|
|
3711
|
-
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
3712
|
-
lazySchema as lazySchema9,
|
|
3713
|
-
zodSchema as zodSchema9
|
|
3714
|
-
} from "@ai-sdk/provider-utils";
|
|
3715
|
-
import { z as z10 } from "zod/v4";
|
|
3716
|
-
var googleMaps = createProviderExecutedToolFactory4({
|
|
3717
|
-
id: "google.google_maps",
|
|
3718
|
-
inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
|
|
3719
|
-
outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
|
|
3720
|
-
});
|
|
3721
|
-
|
|
3722
|
-
// src/tool/google-search.ts
|
|
3723
3982
|
import {
|
|
3724
3983
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
3725
|
-
lazySchema as
|
|
3726
|
-
zodSchema as
|
|
3984
|
+
lazySchema as lazySchema11,
|
|
3985
|
+
zodSchema as zodSchema11
|
|
3727
3986
|
} from "@ai-sdk/provider-utils";
|
|
3728
|
-
import { z as
|
|
3729
|
-
var
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
}).optional(),
|
|
3734
|
-
timeRangeFilter: z11.object({
|
|
3735
|
-
startTime: z11.string(),
|
|
3736
|
-
endTime: z11.string()
|
|
3737
|
-
}).optional()
|
|
3738
|
-
});
|
|
3739
|
-
var googleSearch = createProviderExecutedToolFactory5({
|
|
3740
|
-
id: "google.google_search",
|
|
3741
|
-
inputSchema: lazySchema10(() => zodSchema10(z11.object({}))),
|
|
3742
|
-
outputSchema: lazySchema10(() => zodSchema10(z11.object({})))
|
|
3987
|
+
import { z as z12 } from "zod/v4";
|
|
3988
|
+
var googleMaps = createProviderExecutedToolFactory5({
|
|
3989
|
+
id: "google.google_maps",
|
|
3990
|
+
inputSchema: lazySchema11(() => zodSchema11(z12.object({}))),
|
|
3991
|
+
outputSchema: lazySchema11(() => zodSchema11(z12.object({})))
|
|
3743
3992
|
});
|
|
3744
3993
|
|
|
3745
3994
|
// src/tool/url-context.ts
|
|
3746
3995
|
import {
|
|
3747
3996
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
3748
|
-
lazySchema as
|
|
3749
|
-
zodSchema as
|
|
3997
|
+
lazySchema as lazySchema12,
|
|
3998
|
+
zodSchema as zodSchema12
|
|
3750
3999
|
} from "@ai-sdk/provider-utils";
|
|
3751
|
-
import { z as
|
|
4000
|
+
import { z as z13 } from "zod/v4";
|
|
3752
4001
|
var urlContext = createProviderExecutedToolFactory6({
|
|
3753
4002
|
id: "google.url_context",
|
|
3754
|
-
inputSchema:
|
|
3755
|
-
outputSchema:
|
|
4003
|
+
inputSchema: lazySchema12(() => zodSchema12(z13.object({}))),
|
|
4004
|
+
outputSchema: lazySchema12(() => zodSchema12(z13.object({})))
|
|
3756
4005
|
});
|
|
3757
4006
|
|
|
3758
4007
|
// src/tool/vertex-rag-store.ts
|
|
3759
4008
|
import {
|
|
3760
4009
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
3761
|
-
lazySchema as
|
|
3762
|
-
zodSchema as
|
|
4010
|
+
lazySchema as lazySchema13,
|
|
4011
|
+
zodSchema as zodSchema13
|
|
3763
4012
|
} from "@ai-sdk/provider-utils";
|
|
3764
|
-
import { z as
|
|
4013
|
+
import { z as z14 } from "zod/v4";
|
|
3765
4014
|
var vertexRagStore = createProviderExecutedToolFactory7({
|
|
3766
4015
|
id: "google.vertex_rag_store",
|
|
3767
|
-
inputSchema:
|
|
3768
|
-
outputSchema:
|
|
4016
|
+
inputSchema: lazySchema13(() => zodSchema13(z14.object({}))),
|
|
4017
|
+
outputSchema: lazySchema13(() => zodSchema13(z14.object({})))
|
|
3769
4018
|
});
|
|
3770
4019
|
|
|
3771
4020
|
// src/google-tools.ts
|
|
@@ -3830,35 +4079,13 @@ var googleTools = {
|
|
|
3830
4079
|
|
|
3831
4080
|
// src/google-image-model.ts
|
|
3832
4081
|
import {
|
|
3833
|
-
convertToBase64 as
|
|
4082
|
+
convertToBase64 as convertToBase643,
|
|
3834
4083
|
generateId as defaultGenerateId,
|
|
3835
|
-
parseProviderOptions as
|
|
4084
|
+
parseProviderOptions as parseProviderOptions4,
|
|
3836
4085
|
serializeModelOptions as serializeModelOptions3,
|
|
3837
4086
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
3838
4087
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
|
|
3839
4088
|
} from "@ai-sdk/provider-utils";
|
|
3840
|
-
|
|
3841
|
-
// src/google-image-model-options.ts
|
|
3842
|
-
import { lazySchema as lazySchema13, zodSchema as zodSchema13 } from "@ai-sdk/provider-utils";
|
|
3843
|
-
import { z as z14 } from "zod/v4";
|
|
3844
|
-
var googleImageModelOptionsSchema = lazySchema13(
|
|
3845
|
-
() => zodSchema13(
|
|
3846
|
-
z14.object({
|
|
3847
|
-
/**
|
|
3848
|
-
* Enable Google Search grounding for Gemini image models. The value is
|
|
3849
|
-
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
3850
|
-
* tool on the underlying language-model call. Pass `{}` for defaults.
|
|
3851
|
-
*
|
|
3852
|
-
* `generateImage` does not accept a `tools` parameter, so this is the
|
|
3853
|
-
* dedicated escape hatch for grounding image generation the same way
|
|
3854
|
-
* `generateText` does.
|
|
3855
|
-
*/
|
|
3856
|
-
googleSearch: googleSearchToolArgsBaseSchema.optional()
|
|
3857
|
-
})
|
|
3858
|
-
)
|
|
3859
|
-
);
|
|
3860
|
-
|
|
3861
|
-
// src/google-image-model.ts
|
|
3862
4089
|
var GoogleImageModel = class _GoogleImageModel {
|
|
3863
4090
|
constructor(modelId, settings, config) {
|
|
3864
4091
|
this.modelId = modelId;
|
|
@@ -3948,7 +4175,7 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
3948
4175
|
const languageModelPrompt = [
|
|
3949
4176
|
{ role: "user", content: userContent }
|
|
3950
4177
|
];
|
|
3951
|
-
const googleImageOptions = await
|
|
4178
|
+
const googleImageOptions = await parseProviderOptions4({
|
|
3952
4179
|
provider: "google",
|
|
3953
4180
|
providerOptions,
|
|
3954
4181
|
schema: googleImageModelOptionsSchema
|
|
@@ -3996,7 +4223,7 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
3996
4223
|
const images = [];
|
|
3997
4224
|
for (const part of result.content) {
|
|
3998
4225
|
if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
|
|
3999
|
-
images.push(
|
|
4226
|
+
images.push(convertToBase643(part.data.data));
|
|
4000
4227
|
}
|
|
4001
4228
|
}
|
|
4002
4229
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -4034,7 +4261,7 @@ import {
|
|
|
4034
4261
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
4035
4262
|
delay,
|
|
4036
4263
|
lazySchema as lazySchema14,
|
|
4037
|
-
parseProviderOptions as
|
|
4264
|
+
parseProviderOptions as parseProviderOptions5,
|
|
4038
4265
|
zodSchema as zodSchema14,
|
|
4039
4266
|
getFromApi as getFromApi2
|
|
4040
4267
|
} from "@ai-sdk/provider-utils";
|
|
@@ -4053,7 +4280,7 @@ var GoogleFiles = class {
|
|
|
4053
4280
|
}
|
|
4054
4281
|
async uploadFile(options) {
|
|
4055
4282
|
var _a, _b, _c, _d;
|
|
4056
|
-
const googleOptions = await
|
|
4283
|
+
const googleOptions = await parseProviderOptions5({
|
|
4057
4284
|
provider: "google",
|
|
4058
4285
|
providerOptions: options.providerOptions,
|
|
4059
4286
|
schema: googleFilesUploadOptionsSchema
|
|
@@ -4215,7 +4442,7 @@ import {
|
|
|
4215
4442
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
4216
4443
|
getFromApi as getFromApi3,
|
|
4217
4444
|
isSameOrigin,
|
|
4218
|
-
parseProviderOptions as
|
|
4445
|
+
parseProviderOptions as parseProviderOptions6,
|
|
4219
4446
|
postJsonToApi as postJsonToApi4,
|
|
4220
4447
|
resolve as resolve4
|
|
4221
4448
|
} from "@ai-sdk/provider-utils";
|
|
@@ -4320,7 +4547,7 @@ var GoogleVideoModel = class {
|
|
|
4320
4547
|
}
|
|
4321
4548
|
async buildRequest(options) {
|
|
4322
4549
|
const warnings = [];
|
|
4323
|
-
const googleOptions = await
|
|
4550
|
+
const googleOptions = await parseProviderOptions6({
|
|
4324
4551
|
provider: "google",
|
|
4325
4552
|
providerOptions: options.providerOptions,
|
|
4326
4553
|
schema: googleVideoModelOptionsSchema
|
|
@@ -4556,7 +4783,7 @@ import {
|
|
|
4556
4783
|
combineHeaders as combineHeaders6,
|
|
4557
4784
|
convertBase64ToUint8Array,
|
|
4558
4785
|
createJsonResponseHandler as createJsonResponseHandler6,
|
|
4559
|
-
parseProviderOptions as
|
|
4786
|
+
parseProviderOptions as parseProviderOptions7,
|
|
4560
4787
|
postJsonToApi as postJsonToApi5,
|
|
4561
4788
|
resolve as resolve5,
|
|
4562
4789
|
serializeModelOptions as serializeModelOptions4,
|
|
@@ -4656,7 +4883,7 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4656
4883
|
const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
|
|
4657
4884
|
let googleOptions;
|
|
4658
4885
|
for (const name of providerOptionsNames) {
|
|
4659
|
-
googleOptions = await
|
|
4886
|
+
googleOptions = await parseProviderOptions7({
|
|
4660
4887
|
provider: name,
|
|
4661
4888
|
providerOptions,
|
|
4662
4889
|
schema: googleSpeechProviderOptionsSchema
|
|
@@ -4666,7 +4893,7 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4666
4893
|
}
|
|
4667
4894
|
}
|
|
4668
4895
|
if (googleOptions == null && !providerOptionsNames.includes("google")) {
|
|
4669
|
-
googleOptions = await
|
|
4896
|
+
googleOptions = await parseProviderOptions7({
|
|
4670
4897
|
provider: "google",
|
|
4671
4898
|
providerOptions,
|
|
4672
4899
|
schema: googleSpeechProviderOptionsSchema
|
|
@@ -4830,7 +5057,7 @@ import {
|
|
|
4830
5057
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
4831
5058
|
createJsonResponseHandler as createJsonResponseHandler8,
|
|
4832
5059
|
generateId as defaultGenerateId2,
|
|
4833
|
-
parseProviderOptions as
|
|
5060
|
+
parseProviderOptions as parseProviderOptions8,
|
|
4834
5061
|
postJsonToApi as postJsonToApi6,
|
|
4835
5062
|
resolve as resolve6,
|
|
4836
5063
|
serializeModelOptions as serializeModelOptions5,
|
|
@@ -5621,9 +5848,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5621
5848
|
|
|
5622
5849
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
5623
5850
|
import {
|
|
5624
|
-
convertToBase64 as
|
|
5851
|
+
convertToBase64 as convertToBase644,
|
|
5625
5852
|
getTopLevelMediaType as getTopLevelMediaType2,
|
|
5626
|
-
isFullMediaType as
|
|
5853
|
+
isFullMediaType as isFullMediaType3,
|
|
5627
5854
|
resolveFullMediaType as resolveFullMediaType2,
|
|
5628
5855
|
resolveProviderReference as resolveProviderReference2,
|
|
5629
5856
|
secureJsonParse as secureJsonParse2
|
|
@@ -5822,7 +6049,7 @@ function convertFilePartToContent({
|
|
|
5822
6049
|
const mimeType = resolveFullMediaType2({ part });
|
|
5823
6050
|
return {
|
|
5824
6051
|
type: kind,
|
|
5825
|
-
data:
|
|
6052
|
+
data: convertToBase644(part.data.data),
|
|
5826
6053
|
mime_type: mimeType,
|
|
5827
6054
|
...resolutionField,
|
|
5828
6055
|
...processingField
|
|
@@ -5832,7 +6059,7 @@ function convertFilePartToContent({
|
|
|
5832
6059
|
return {
|
|
5833
6060
|
type: kind,
|
|
5834
6061
|
uri: part.data.url.toString(),
|
|
5835
|
-
...
|
|
6062
|
+
...isFullMediaType3(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
5836
6063
|
...resolutionField,
|
|
5837
6064
|
...processingField
|
|
5838
6065
|
};
|
|
@@ -5845,7 +6072,7 @@ function convertFilePartToContent({
|
|
|
5845
6072
|
return {
|
|
5846
6073
|
type: kind,
|
|
5847
6074
|
uri,
|
|
5848
|
-
...
|
|
6075
|
+
...isFullMediaType3(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
5849
6076
|
...resolutionField,
|
|
5850
6077
|
...processingField
|
|
5851
6078
|
};
|
|
@@ -6000,7 +6227,7 @@ function filePartToImageBlock({
|
|
|
6000
6227
|
}) {
|
|
6001
6228
|
switch (part.data.type) {
|
|
6002
6229
|
case "data": {
|
|
6003
|
-
const mimeType =
|
|
6230
|
+
const mimeType = isFullMediaType3(part.mediaType) ? part.mediaType : resolveFullMediaType2({
|
|
6004
6231
|
part: {
|
|
6005
6232
|
type: "file",
|
|
6006
6233
|
mediaType: part.mediaType,
|
|
@@ -6009,7 +6236,7 @@ function filePartToImageBlock({
|
|
|
6009
6236
|
});
|
|
6010
6237
|
return {
|
|
6011
6238
|
type: "image",
|
|
6012
|
-
data:
|
|
6239
|
+
data: convertToBase644(part.data.data),
|
|
6013
6240
|
mime_type: mimeType
|
|
6014
6241
|
};
|
|
6015
6242
|
}
|
|
@@ -6017,7 +6244,7 @@ function filePartToImageBlock({
|
|
|
6017
6244
|
return {
|
|
6018
6245
|
type: "image",
|
|
6019
6246
|
uri: part.data.url.toString(),
|
|
6020
|
-
...
|
|
6247
|
+
...isFullMediaType3(part.mediaType) ? { mime_type: part.mediaType } : {}
|
|
6021
6248
|
};
|
|
6022
6249
|
case "reference": {
|
|
6023
6250
|
const uri = resolveProviderReference2({
|
|
@@ -6027,7 +6254,7 @@ function filePartToImageBlock({
|
|
|
6027
6254
|
return {
|
|
6028
6255
|
type: "image",
|
|
6029
6256
|
uri,
|
|
6030
|
-
...
|
|
6257
|
+
...isFullMediaType3(part.mediaType) ? { mime_type: part.mediaType } : {}
|
|
6031
6258
|
};
|
|
6032
6259
|
}
|
|
6033
6260
|
case "text": {
|
|
@@ -7437,7 +7664,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7437
7664
|
async getArgs(options) {
|
|
7438
7665
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
7439
7666
|
const warnings = [];
|
|
7440
|
-
const googleOptions = await
|
|
7667
|
+
const googleOptions = await parseProviderOptions8({
|
|
7441
7668
|
provider: "google",
|
|
7442
7669
|
providerOptions: options.providerOptions,
|
|
7443
7670
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -8338,9 +8565,9 @@ import {
|
|
|
8338
8565
|
import {
|
|
8339
8566
|
combineHeaders as combineHeaders9,
|
|
8340
8567
|
connectToWebSocket,
|
|
8341
|
-
convertToBase64 as
|
|
8568
|
+
convertToBase64 as convertToBase645,
|
|
8342
8569
|
createJsonResponseHandler as createJsonResponseHandler9,
|
|
8343
|
-
parseProviderOptions as
|
|
8570
|
+
parseProviderOptions as parseProviderOptions9,
|
|
8344
8571
|
postJsonToApi as postJsonToApi7,
|
|
8345
8572
|
resolve as resolve7,
|
|
8346
8573
|
safeParseJSON as safeParseJSON2,
|
|
@@ -8414,7 +8641,7 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8414
8641
|
return this.config.provider;
|
|
8415
8642
|
}
|
|
8416
8643
|
async parseOptions(providerOptions) {
|
|
8417
|
-
return
|
|
8644
|
+
return parseProviderOptions9({
|
|
8418
8645
|
provider: "google",
|
|
8419
8646
|
providerOptions,
|
|
8420
8647
|
schema: googleTranscriptionModelOptions
|
|
@@ -8437,7 +8664,7 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8437
8664
|
input: [
|
|
8438
8665
|
{
|
|
8439
8666
|
type: "audio",
|
|
8440
|
-
data:
|
|
8667
|
+
data: convertToBase645(options.audio),
|
|
8441
8668
|
mime_type: options.mediaType
|
|
8442
8669
|
}
|
|
8443
8670
|
],
|
|
@@ -8657,7 +8884,7 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8657
8884
|
JSON.stringify({
|
|
8658
8885
|
realtimeInput: {
|
|
8659
8886
|
audio: {
|
|
8660
|
-
data:
|
|
8887
|
+
data: convertToBase645(value),
|
|
8661
8888
|
mimeType: `audio/pcm;rate=${inputAudioRate}`
|
|
8662
8889
|
}
|
|
8663
8890
|
}
|
|
@@ -8856,8 +9083,8 @@ import {
|
|
|
8856
9083
|
connectToWebSocket as connectToWebSocket2,
|
|
8857
9084
|
combineHeaders as combineHeaders10,
|
|
8858
9085
|
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
8859
|
-
convertToBase64 as
|
|
8860
|
-
parseProviderOptions as
|
|
9086
|
+
convertToBase64 as convertToBase646,
|
|
9087
|
+
parseProviderOptions as parseProviderOptions10,
|
|
8861
9088
|
safeParseJSON as safeParseJSON3,
|
|
8862
9089
|
serializeModelOptions as serializeModelOptions7,
|
|
8863
9090
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
|
|
@@ -8920,7 +9147,7 @@ var GoogleSpeechTranslationModel = class _GoogleSpeechTranslationModel {
|
|
|
8920
9147
|
});
|
|
8921
9148
|
}
|
|
8922
9149
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
8923
|
-
const googleOptions = await
|
|
9150
|
+
const googleOptions = await parseProviderOptions10({
|
|
8924
9151
|
provider: "google",
|
|
8925
9152
|
providerOptions: options.providerOptions,
|
|
8926
9153
|
schema: googleSpeechTranslationModelOptions
|
|
@@ -9100,7 +9327,7 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9100
9327
|
JSON.stringify({
|
|
9101
9328
|
realtimeInput: {
|
|
9102
9329
|
audio: {
|
|
9103
|
-
data:
|
|
9330
|
+
data: convertToBase646(value),
|
|
9104
9331
|
mimeType: `audio/pcm;rate=${inputAudioRate}`
|
|
9105
9332
|
}
|
|
9106
9333
|
}
|