@ai-sdk/google 4.0.67 → 4.0.68
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 +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +305 -170
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/google-batch.ts +193 -12
- 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.68" : "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) {
|
|
@@ -3066,86 +3069,142 @@ var chunkSchema = lazySchema5(
|
|
|
3066
3069
|
)
|
|
3067
3070
|
);
|
|
3068
3071
|
|
|
3072
|
+
// src/google-image-model-options.ts
|
|
3073
|
+
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
3074
|
+
import { z as z7 } from "zod/v4";
|
|
3075
|
+
|
|
3076
|
+
// src/tool/google-search.ts
|
|
3077
|
+
import {
|
|
3078
|
+
createProviderExecutedToolFactory,
|
|
3079
|
+
lazySchema as lazySchema6,
|
|
3080
|
+
zodSchema as zodSchema6
|
|
3081
|
+
} from "@ai-sdk/provider-utils";
|
|
3082
|
+
import { z as z6 } from "zod/v4";
|
|
3083
|
+
var googleSearchToolArgsBaseSchema = z6.looseObject({
|
|
3084
|
+
searchTypes: z6.object({
|
|
3085
|
+
webSearch: z6.object({}).optional(),
|
|
3086
|
+
imageSearch: z6.object({}).optional()
|
|
3087
|
+
}).optional(),
|
|
3088
|
+
timeRangeFilter: z6.object({
|
|
3089
|
+
startTime: z6.string(),
|
|
3090
|
+
endTime: z6.string()
|
|
3091
|
+
}).optional()
|
|
3092
|
+
});
|
|
3093
|
+
var googleSearch = createProviderExecutedToolFactory({
|
|
3094
|
+
id: "google.google_search",
|
|
3095
|
+
inputSchema: lazySchema6(() => zodSchema6(z6.object({}))),
|
|
3096
|
+
outputSchema: lazySchema6(() => zodSchema6(z6.object({})))
|
|
3097
|
+
});
|
|
3098
|
+
|
|
3099
|
+
// src/google-image-model-options.ts
|
|
3100
|
+
var googleImageModelOptionsSchema = lazySchema7(
|
|
3101
|
+
() => zodSchema7(
|
|
3102
|
+
z7.object({
|
|
3103
|
+
/**
|
|
3104
|
+
* Enable Google Search grounding for Gemini image models. The value is
|
|
3105
|
+
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
3106
|
+
* tool on the underlying language-model call. Pass `{}` for defaults.
|
|
3107
|
+
*
|
|
3108
|
+
* `generateImage` does not accept a `tools` parameter, so this is the
|
|
3109
|
+
* dedicated escape hatch for grounding image generation the same way
|
|
3110
|
+
* `generateText` does.
|
|
3111
|
+
*/
|
|
3112
|
+
googleSearch: googleSearchToolArgsBaseSchema.optional()
|
|
3113
|
+
})
|
|
3114
|
+
)
|
|
3115
|
+
);
|
|
3116
|
+
|
|
3069
3117
|
// src/google-batch.ts
|
|
3070
3118
|
var googleBatchInputFileMaxBytes = 2 * 1024 * 1024 * 1024;
|
|
3071
3119
|
var googleBatchInlineCreationMaxBytes = 2e7;
|
|
3072
3120
|
var supportedGoogleBatchContentTypes = /* @__PURE__ */ new Set(["text", "reasoning", "source", "tool-call", "tool-result"]);
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3121
|
+
function assertSupportedBatchRequests(requests) {
|
|
3122
|
+
for (const request of requests) {
|
|
3123
|
+
const requestType = request.type;
|
|
3124
|
+
if (requestType !== "text" && requestType !== "image") {
|
|
3125
|
+
throw new UnsupportedFunctionalityError4({
|
|
3126
|
+
functionality: `batch request type: ${requestType}`,
|
|
3127
|
+
message: `The Google Batch API does not support batch requests with type "${requestType}".`
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
var googleRpcStatusSchema = z8.object({
|
|
3133
|
+
code: z8.union([z8.number(), z8.string()]).nullish(),
|
|
3134
|
+
message: z8.string().nullish(),
|
|
3135
|
+
status: z8.string().nullish()
|
|
3077
3136
|
});
|
|
3078
|
-
var googleBatchStatsSchema =
|
|
3079
|
-
requestCount:
|
|
3080
|
-
successfulRequestCount:
|
|
3081
|
-
failedRequestCount:
|
|
3082
|
-
pendingRequestCount:
|
|
3137
|
+
var googleBatchStatsSchema = z8.object({
|
|
3138
|
+
requestCount: z8.union([z8.string(), z8.number()]).nullish(),
|
|
3139
|
+
successfulRequestCount: z8.union([z8.string(), z8.number()]).nullish(),
|
|
3140
|
+
failedRequestCount: z8.union([z8.string(), z8.number()]).nullish(),
|
|
3141
|
+
pendingRequestCount: z8.union([z8.string(), z8.number()]).nullish()
|
|
3083
3142
|
});
|
|
3084
|
-
var googleBatchOutputSchema =
|
|
3085
|
-
responsesFile:
|
|
3086
|
-
inlinedResponses:
|
|
3087
|
-
inlinedResponses:
|
|
3088
|
-
|
|
3089
|
-
metadata:
|
|
3090
|
-
key:
|
|
3143
|
+
var googleBatchOutputSchema = z8.object({
|
|
3144
|
+
responsesFile: z8.string().nullish(),
|
|
3145
|
+
inlinedResponses: z8.object({
|
|
3146
|
+
inlinedResponses: z8.array(
|
|
3147
|
+
z8.object({
|
|
3148
|
+
metadata: z8.object({
|
|
3149
|
+
key: z8.string()
|
|
3091
3150
|
}),
|
|
3092
|
-
response:
|
|
3151
|
+
response: z8.unknown().nullish(),
|
|
3093
3152
|
error: googleRpcStatusSchema.nullish()
|
|
3094
3153
|
})
|
|
3095
3154
|
)
|
|
3096
3155
|
}).nullish()
|
|
3097
3156
|
});
|
|
3098
|
-
var googleBatchOperationZodSchema = () =>
|
|
3099
|
-
name:
|
|
3100
|
-
metadata:
|
|
3101
|
-
state:
|
|
3102
|
-
createTime:
|
|
3157
|
+
var googleBatchOperationZodSchema = () => z8.object({
|
|
3158
|
+
name: z8.string(),
|
|
3159
|
+
metadata: z8.object({
|
|
3160
|
+
state: z8.string().nullish(),
|
|
3161
|
+
createTime: z8.string().nullish(),
|
|
3103
3162
|
batchStats: googleBatchStatsSchema.nullish(),
|
|
3104
3163
|
output: googleBatchOutputSchema.nullish()
|
|
3105
3164
|
}).nullish(),
|
|
3106
|
-
done:
|
|
3165
|
+
done: z8.boolean().nullish(),
|
|
3107
3166
|
error: googleRpcStatusSchema.nullish(),
|
|
3108
3167
|
response: googleBatchOutputSchema.nullish()
|
|
3109
3168
|
});
|
|
3110
|
-
var googleBatchOperationSchema =
|
|
3111
|
-
() =>
|
|
3169
|
+
var googleBatchOperationSchema = lazySchema8(
|
|
3170
|
+
() => zodSchema8(googleBatchOperationZodSchema())
|
|
3112
3171
|
);
|
|
3113
|
-
var googleBatchListResponseSchema =
|
|
3114
|
-
() =>
|
|
3115
|
-
|
|
3116
|
-
operations:
|
|
3117
|
-
nextPageToken:
|
|
3172
|
+
var googleBatchListResponseSchema = lazySchema8(
|
|
3173
|
+
() => zodSchema8(
|
|
3174
|
+
z8.object({
|
|
3175
|
+
operations: z8.array(googleBatchOperationZodSchema()).nullish(),
|
|
3176
|
+
nextPageToken: z8.string().nullish()
|
|
3118
3177
|
})
|
|
3119
3178
|
)
|
|
3120
3179
|
);
|
|
3121
|
-
var googleBatchCancelResponseSchema =
|
|
3122
|
-
() =>
|
|
3180
|
+
var googleBatchCancelResponseSchema = lazySchema8(
|
|
3181
|
+
() => zodSchema8(z8.object({}))
|
|
3123
3182
|
);
|
|
3124
|
-
var googleFileUploadResponseSchema =
|
|
3125
|
-
() =>
|
|
3126
|
-
|
|
3127
|
-
file:
|
|
3128
|
-
name:
|
|
3129
|
-
expirationTime:
|
|
3183
|
+
var googleFileUploadResponseSchema = lazySchema8(
|
|
3184
|
+
() => zodSchema8(
|
|
3185
|
+
z8.object({
|
|
3186
|
+
file: z8.object({
|
|
3187
|
+
name: z8.string(),
|
|
3188
|
+
expirationTime: z8.string().nullish()
|
|
3130
3189
|
})
|
|
3131
3190
|
})
|
|
3132
3191
|
)
|
|
3133
3192
|
);
|
|
3134
|
-
var googleBatchResultLineSchema =
|
|
3135
|
-
() =>
|
|
3136
|
-
|
|
3137
|
-
key:
|
|
3138
|
-
response:
|
|
3193
|
+
var googleBatchResultLineSchema = lazySchema8(
|
|
3194
|
+
() => zodSchema8(
|
|
3195
|
+
z8.object({
|
|
3196
|
+
key: z8.string(),
|
|
3197
|
+
response: z8.unknown().nullish(),
|
|
3139
3198
|
error: googleRpcStatusSchema.nullish()
|
|
3140
3199
|
})
|
|
3141
3200
|
)
|
|
3142
3201
|
);
|
|
3143
|
-
var googleBatchResponsePreviewSchema =
|
|
3144
|
-
() =>
|
|
3145
|
-
|
|
3146
|
-
candidates:
|
|
3147
|
-
promptFeedback:
|
|
3148
|
-
blockReason:
|
|
3202
|
+
var googleBatchResponsePreviewSchema = lazySchema8(
|
|
3203
|
+
() => zodSchema8(
|
|
3204
|
+
z8.object({
|
|
3205
|
+
candidates: z8.array(z8.unknown()).nullish(),
|
|
3206
|
+
promptFeedback: z8.object({
|
|
3207
|
+
blockReason: z8.string().nullish()
|
|
3149
3208
|
}).nullish()
|
|
3150
3209
|
})
|
|
3151
3210
|
)
|
|
@@ -3160,6 +3219,7 @@ var GoogleBatch = class {
|
|
|
3160
3219
|
this.batchGenerateId = (_a = options.config.generateId) != null ? _a : generateId2;
|
|
3161
3220
|
}
|
|
3162
3221
|
async doStartBatch(options) {
|
|
3222
|
+
assertSupportedBatchRequests(options.requests);
|
|
3163
3223
|
const modelId = getGoogleBatchModelId(options.requests);
|
|
3164
3224
|
const warnings = [];
|
|
3165
3225
|
const displayName = `ai-sdk-batch-${this.batchGenerateId()}`;
|
|
@@ -3181,11 +3241,11 @@ var GoogleBatch = class {
|
|
|
3181
3241
|
).byteLength;
|
|
3182
3242
|
let fileParts;
|
|
3183
3243
|
for (const request of options.requests) {
|
|
3184
|
-
const preparedRequest = await GoogleLanguageModel.prepareRequest({
|
|
3244
|
+
const preparedRequest = request.type === "text" ? await GoogleLanguageModel.prepareRequest({
|
|
3185
3245
|
modelId: request.modelId,
|
|
3186
3246
|
config: this.batchConfig,
|
|
3187
3247
|
options: request.options
|
|
3188
|
-
});
|
|
3248
|
+
}) : await this.prepareImageRequest(request);
|
|
3189
3249
|
const inlinedRequest = {
|
|
3190
3250
|
request: preparedRequest.args,
|
|
3191
3251
|
metadata: { key: request.id }
|
|
@@ -3518,6 +3578,16 @@ var GoogleBatch = class {
|
|
|
3518
3578
|
warnings: [],
|
|
3519
3579
|
providerOptionsNames: ["google"]
|
|
3520
3580
|
});
|
|
3581
|
+
const imageResult = convertGoogleImageBatchResult(result);
|
|
3582
|
+
if (imageResult != null) {
|
|
3583
|
+
yield {
|
|
3584
|
+
type: "image",
|
|
3585
|
+
id: line.key,
|
|
3586
|
+
status: "succeeded",
|
|
3587
|
+
result: imageResult
|
|
3588
|
+
};
|
|
3589
|
+
continue;
|
|
3590
|
+
}
|
|
3521
3591
|
const unsupportedPart = result.content.find(
|
|
3522
3592
|
(part) => !supportedGoogleBatchContentTypes.has(part.type)
|
|
3523
3593
|
);
|
|
@@ -3536,6 +3606,91 @@ var GoogleBatch = class {
|
|
|
3536
3606
|
yield { type: "text", id: line.key, status: "succeeded", result };
|
|
3537
3607
|
}
|
|
3538
3608
|
}
|
|
3609
|
+
async prepareImageRequest(request) {
|
|
3610
|
+
var _a;
|
|
3611
|
+
const { prompt, n, size, aspectRatio, seed, files, mask, providerOptions } = request.options;
|
|
3612
|
+
const warnings = [];
|
|
3613
|
+
if (mask != null) {
|
|
3614
|
+
throw new UnsupportedFunctionalityError4({
|
|
3615
|
+
functionality: "mask-based image editing in Google batches"
|
|
3616
|
+
});
|
|
3617
|
+
}
|
|
3618
|
+
if (n > 1) {
|
|
3619
|
+
throw new UnsupportedFunctionalityError4({
|
|
3620
|
+
functionality: "multiple images per Google batch request"
|
|
3621
|
+
});
|
|
3622
|
+
}
|
|
3623
|
+
if (size != null) {
|
|
3624
|
+
warnings.push({
|
|
3625
|
+
type: "unsupported",
|
|
3626
|
+
feature: "size",
|
|
3627
|
+
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
3628
|
+
});
|
|
3629
|
+
}
|
|
3630
|
+
const userContent = [];
|
|
3631
|
+
if (prompt != null) userContent.push({ type: "text", text: prompt });
|
|
3632
|
+
for (const file of files != null ? files : []) {
|
|
3633
|
+
userContent.push(
|
|
3634
|
+
file.type === "url" ? {
|
|
3635
|
+
type: "file",
|
|
3636
|
+
data: { type: "url", url: new URL(file.url) },
|
|
3637
|
+
mediaType: "image/*"
|
|
3638
|
+
} : {
|
|
3639
|
+
type: "file",
|
|
3640
|
+
data: { type: "data", data: file.data },
|
|
3641
|
+
mediaType: file.mediaType
|
|
3642
|
+
}
|
|
3643
|
+
);
|
|
3644
|
+
}
|
|
3645
|
+
const googleImageOptions = await parseProviderOptions3({
|
|
3646
|
+
provider: "google",
|
|
3647
|
+
providerOptions,
|
|
3648
|
+
schema: googleImageModelOptionsSchema
|
|
3649
|
+
});
|
|
3650
|
+
const {
|
|
3651
|
+
responseModalities: _responseModalities,
|
|
3652
|
+
imageConfig: userImageConfig,
|
|
3653
|
+
...passthroughGoogleOptions
|
|
3654
|
+
} = (_a = await parseProviderOptions3({
|
|
3655
|
+
provider: "google",
|
|
3656
|
+
providerOptions,
|
|
3657
|
+
schema: googleLanguageModelOptions
|
|
3658
|
+
})) != null ? _a : {};
|
|
3659
|
+
const preparedGoogleOptions = await parseProviderOptions3({
|
|
3660
|
+
provider: "google",
|
|
3661
|
+
providerOptions: {
|
|
3662
|
+
google: {
|
|
3663
|
+
...passthroughGoogleOptions,
|
|
3664
|
+
responseModalities: ["IMAGE"],
|
|
3665
|
+
imageConfig: aspectRatio != null || userImageConfig != null ? {
|
|
3666
|
+
...userImageConfig,
|
|
3667
|
+
...aspectRatio != null ? { aspectRatio } : {}
|
|
3668
|
+
} : void 0
|
|
3669
|
+
}
|
|
3670
|
+
},
|
|
3671
|
+
schema: googleLanguageModelOptions
|
|
3672
|
+
});
|
|
3673
|
+
const prepared = await GoogleLanguageModel.prepareRequest({
|
|
3674
|
+
modelId: request.modelId,
|
|
3675
|
+
config: this.batchConfig,
|
|
3676
|
+
options: {
|
|
3677
|
+
prompt: [{ role: "user", content: userContent }],
|
|
3678
|
+
seed,
|
|
3679
|
+
providerOptions: {
|
|
3680
|
+
google: preparedGoogleOptions != null ? preparedGoogleOptions : { responseModalities: ["IMAGE"] }
|
|
3681
|
+
},
|
|
3682
|
+
tools: (googleImageOptions == null ? void 0 : googleImageOptions.googleSearch) != null ? [
|
|
3683
|
+
{
|
|
3684
|
+
type: "provider",
|
|
3685
|
+
id: "google.google_search",
|
|
3686
|
+
name: "google_search",
|
|
3687
|
+
args: googleImageOptions.googleSearch
|
|
3688
|
+
}
|
|
3689
|
+
] : void 0
|
|
3690
|
+
}
|
|
3691
|
+
});
|
|
3692
|
+
return { ...prepared, warnings: [...warnings, ...prepared.warnings] };
|
|
3693
|
+
}
|
|
3539
3694
|
async getHeaders(headers) {
|
|
3540
3695
|
return combineHeaders3(
|
|
3541
3696
|
this.batchConfig.headers ? await resolve3(this.batchConfig.headers) : void 0,
|
|
@@ -3648,124 +3803,126 @@ function getGoogleBatchModelId(requests) {
|
|
|
3648
3803
|
}
|
|
3649
3804
|
return modelId;
|
|
3650
3805
|
}
|
|
3806
|
+
function convertGoogleImageBatchResult(result) {
|
|
3807
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3808
|
+
const images = result.content.flatMap(
|
|
3809
|
+
(part) => part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data" ? [convertToBase642(part.data.data)] : []
|
|
3810
|
+
);
|
|
3811
|
+
if (images.length === 0) return void 0;
|
|
3812
|
+
const googleMetadata = (_b = (_a = result.providerMetadata) == null ? void 0 : _a.google) != null ? _b : {};
|
|
3813
|
+
return {
|
|
3814
|
+
images,
|
|
3815
|
+
warnings: result.warnings,
|
|
3816
|
+
providerMetadata: {
|
|
3817
|
+
google: { ...googleMetadata, images: images.map(() => ({})) }
|
|
3818
|
+
},
|
|
3819
|
+
response: {
|
|
3820
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3821
|
+
modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : "",
|
|
3822
|
+
headers: (_e = result.response) == null ? void 0 : _e.headers
|
|
3823
|
+
},
|
|
3824
|
+
usage: {
|
|
3825
|
+
inputTokens: result.usage.inputTokens.total,
|
|
3826
|
+
outputTokens: result.usage.outputTokens.total,
|
|
3827
|
+
totalTokens: ((_f = result.usage.inputTokens.total) != null ? _f : 0) + ((_g = result.usage.outputTokens.total) != null ? _g : 0)
|
|
3828
|
+
}
|
|
3829
|
+
};
|
|
3830
|
+
}
|
|
3651
3831
|
|
|
3652
3832
|
// src/tool/code-execution.ts
|
|
3653
|
-
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
3654
|
-
import { z as
|
|
3655
|
-
var codeExecution =
|
|
3833
|
+
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
3834
|
+
import { z as z9 } from "zod/v4";
|
|
3835
|
+
var codeExecution = createProviderExecutedToolFactory2({
|
|
3656
3836
|
id: "google.code_execution",
|
|
3657
|
-
inputSchema:
|
|
3658
|
-
language:
|
|
3659
|
-
code:
|
|
3837
|
+
inputSchema: z9.object({
|
|
3838
|
+
language: z9.string().describe("The programming language of the code."),
|
|
3839
|
+
code: z9.string().describe("The code to be executed.")
|
|
3660
3840
|
}),
|
|
3661
|
-
outputSchema:
|
|
3662
|
-
outcome:
|
|
3663
|
-
output:
|
|
3841
|
+
outputSchema: z9.object({
|
|
3842
|
+
outcome: z9.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
3843
|
+
output: z9.string().describe("The output from the code execution.")
|
|
3664
3844
|
})
|
|
3665
3845
|
});
|
|
3666
3846
|
|
|
3667
3847
|
// src/tool/enterprise-web-search.ts
|
|
3668
3848
|
import {
|
|
3669
|
-
createProviderExecutedToolFactory as
|
|
3670
|
-
lazySchema as
|
|
3671
|
-
zodSchema as
|
|
3849
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
3850
|
+
lazySchema as lazySchema9,
|
|
3851
|
+
zodSchema as zodSchema9
|
|
3672
3852
|
} from "@ai-sdk/provider-utils";
|
|
3673
|
-
import { z as
|
|
3674
|
-
var enterpriseWebSearch =
|
|
3853
|
+
import { z as z10 } from "zod/v4";
|
|
3854
|
+
var enterpriseWebSearch = createProviderExecutedToolFactory3({
|
|
3675
3855
|
id: "google.enterprise_web_search",
|
|
3676
|
-
inputSchema:
|
|
3677
|
-
outputSchema:
|
|
3856
|
+
inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
|
|
3857
|
+
outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
|
|
3678
3858
|
});
|
|
3679
3859
|
|
|
3680
3860
|
// src/tool/file-search.ts
|
|
3681
3861
|
import {
|
|
3682
|
-
createProviderExecutedToolFactory as
|
|
3683
|
-
lazySchema as
|
|
3684
|
-
zodSchema as
|
|
3862
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
3863
|
+
lazySchema as lazySchema10,
|
|
3864
|
+
zodSchema as zodSchema10
|
|
3685
3865
|
} from "@ai-sdk/provider-utils";
|
|
3686
|
-
import { z as
|
|
3687
|
-
var fileSearchArgsBaseSchema =
|
|
3866
|
+
import { z as z11 } from "zod/v4";
|
|
3867
|
+
var fileSearchArgsBaseSchema = z11.looseObject({
|
|
3688
3868
|
/** The names of the file_search_stores to retrieve from.
|
|
3689
3869
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
3690
3870
|
*/
|
|
3691
|
-
fileSearchStoreNames:
|
|
3871
|
+
fileSearchStoreNames: z11.array(z11.string()).describe(
|
|
3692
3872
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
3693
3873
|
),
|
|
3694
3874
|
/** The number of file search retrieval chunks to retrieve. */
|
|
3695
|
-
topK:
|
|
3875
|
+
topK: z11.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
3696
3876
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
3697
3877
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
3698
3878
|
*/
|
|
3699
|
-
metadataFilter:
|
|
3879
|
+
metadataFilter: z11.string().describe(
|
|
3700
3880
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
3701
3881
|
).optional()
|
|
3702
3882
|
});
|
|
3703
|
-
var fileSearch =
|
|
3883
|
+
var fileSearch = createProviderExecutedToolFactory4({
|
|
3704
3884
|
id: "google.file_search",
|
|
3705
|
-
inputSchema:
|
|
3706
|
-
outputSchema:
|
|
3885
|
+
inputSchema: lazySchema10(() => zodSchema10(z11.object({}))),
|
|
3886
|
+
outputSchema: lazySchema10(() => zodSchema10(z11.object({})))
|
|
3707
3887
|
});
|
|
3708
3888
|
|
|
3709
3889
|
// 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
3890
|
import {
|
|
3724
3891
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
3725
|
-
lazySchema as
|
|
3726
|
-
zodSchema as
|
|
3892
|
+
lazySchema as lazySchema11,
|
|
3893
|
+
zodSchema as zodSchema11
|
|
3727
3894
|
} 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({})))
|
|
3895
|
+
import { z as z12 } from "zod/v4";
|
|
3896
|
+
var googleMaps = createProviderExecutedToolFactory5({
|
|
3897
|
+
id: "google.google_maps",
|
|
3898
|
+
inputSchema: lazySchema11(() => zodSchema11(z12.object({}))),
|
|
3899
|
+
outputSchema: lazySchema11(() => zodSchema11(z12.object({})))
|
|
3743
3900
|
});
|
|
3744
3901
|
|
|
3745
3902
|
// src/tool/url-context.ts
|
|
3746
3903
|
import {
|
|
3747
3904
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
3748
|
-
lazySchema as
|
|
3749
|
-
zodSchema as
|
|
3905
|
+
lazySchema as lazySchema12,
|
|
3906
|
+
zodSchema as zodSchema12
|
|
3750
3907
|
} from "@ai-sdk/provider-utils";
|
|
3751
|
-
import { z as
|
|
3908
|
+
import { z as z13 } from "zod/v4";
|
|
3752
3909
|
var urlContext = createProviderExecutedToolFactory6({
|
|
3753
3910
|
id: "google.url_context",
|
|
3754
|
-
inputSchema:
|
|
3755
|
-
outputSchema:
|
|
3911
|
+
inputSchema: lazySchema12(() => zodSchema12(z13.object({}))),
|
|
3912
|
+
outputSchema: lazySchema12(() => zodSchema12(z13.object({})))
|
|
3756
3913
|
});
|
|
3757
3914
|
|
|
3758
3915
|
// src/tool/vertex-rag-store.ts
|
|
3759
3916
|
import {
|
|
3760
3917
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
3761
|
-
lazySchema as
|
|
3762
|
-
zodSchema as
|
|
3918
|
+
lazySchema as lazySchema13,
|
|
3919
|
+
zodSchema as zodSchema13
|
|
3763
3920
|
} from "@ai-sdk/provider-utils";
|
|
3764
|
-
import { z as
|
|
3921
|
+
import { z as z14 } from "zod/v4";
|
|
3765
3922
|
var vertexRagStore = createProviderExecutedToolFactory7({
|
|
3766
3923
|
id: "google.vertex_rag_store",
|
|
3767
|
-
inputSchema:
|
|
3768
|
-
outputSchema:
|
|
3924
|
+
inputSchema: lazySchema13(() => zodSchema13(z14.object({}))),
|
|
3925
|
+
outputSchema: lazySchema13(() => zodSchema13(z14.object({})))
|
|
3769
3926
|
});
|
|
3770
3927
|
|
|
3771
3928
|
// src/google-tools.ts
|
|
@@ -3830,35 +3987,13 @@ var googleTools = {
|
|
|
3830
3987
|
|
|
3831
3988
|
// src/google-image-model.ts
|
|
3832
3989
|
import {
|
|
3833
|
-
convertToBase64 as
|
|
3990
|
+
convertToBase64 as convertToBase643,
|
|
3834
3991
|
generateId as defaultGenerateId,
|
|
3835
|
-
parseProviderOptions as
|
|
3992
|
+
parseProviderOptions as parseProviderOptions4,
|
|
3836
3993
|
serializeModelOptions as serializeModelOptions3,
|
|
3837
3994
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
3838
3995
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
|
|
3839
3996
|
} 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
3997
|
var GoogleImageModel = class _GoogleImageModel {
|
|
3863
3998
|
constructor(modelId, settings, config) {
|
|
3864
3999
|
this.modelId = modelId;
|
|
@@ -3948,7 +4083,7 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
3948
4083
|
const languageModelPrompt = [
|
|
3949
4084
|
{ role: "user", content: userContent }
|
|
3950
4085
|
];
|
|
3951
|
-
const googleImageOptions = await
|
|
4086
|
+
const googleImageOptions = await parseProviderOptions4({
|
|
3952
4087
|
provider: "google",
|
|
3953
4088
|
providerOptions,
|
|
3954
4089
|
schema: googleImageModelOptionsSchema
|
|
@@ -3996,7 +4131,7 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
3996
4131
|
const images = [];
|
|
3997
4132
|
for (const part of result.content) {
|
|
3998
4133
|
if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
|
|
3999
|
-
images.push(
|
|
4134
|
+
images.push(convertToBase643(part.data.data));
|
|
4000
4135
|
}
|
|
4001
4136
|
}
|
|
4002
4137
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -4034,7 +4169,7 @@ import {
|
|
|
4034
4169
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
4035
4170
|
delay,
|
|
4036
4171
|
lazySchema as lazySchema14,
|
|
4037
|
-
parseProviderOptions as
|
|
4172
|
+
parseProviderOptions as parseProviderOptions5,
|
|
4038
4173
|
zodSchema as zodSchema14,
|
|
4039
4174
|
getFromApi as getFromApi2
|
|
4040
4175
|
} from "@ai-sdk/provider-utils";
|
|
@@ -4053,7 +4188,7 @@ var GoogleFiles = class {
|
|
|
4053
4188
|
}
|
|
4054
4189
|
async uploadFile(options) {
|
|
4055
4190
|
var _a, _b, _c, _d;
|
|
4056
|
-
const googleOptions = await
|
|
4191
|
+
const googleOptions = await parseProviderOptions5({
|
|
4057
4192
|
provider: "google",
|
|
4058
4193
|
providerOptions: options.providerOptions,
|
|
4059
4194
|
schema: googleFilesUploadOptionsSchema
|
|
@@ -4215,7 +4350,7 @@ import {
|
|
|
4215
4350
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
4216
4351
|
getFromApi as getFromApi3,
|
|
4217
4352
|
isSameOrigin,
|
|
4218
|
-
parseProviderOptions as
|
|
4353
|
+
parseProviderOptions as parseProviderOptions6,
|
|
4219
4354
|
postJsonToApi as postJsonToApi4,
|
|
4220
4355
|
resolve as resolve4
|
|
4221
4356
|
} from "@ai-sdk/provider-utils";
|
|
@@ -4320,7 +4455,7 @@ var GoogleVideoModel = class {
|
|
|
4320
4455
|
}
|
|
4321
4456
|
async buildRequest(options) {
|
|
4322
4457
|
const warnings = [];
|
|
4323
|
-
const googleOptions = await
|
|
4458
|
+
const googleOptions = await parseProviderOptions6({
|
|
4324
4459
|
provider: "google",
|
|
4325
4460
|
providerOptions: options.providerOptions,
|
|
4326
4461
|
schema: googleVideoModelOptionsSchema
|
|
@@ -4556,7 +4691,7 @@ import {
|
|
|
4556
4691
|
combineHeaders as combineHeaders6,
|
|
4557
4692
|
convertBase64ToUint8Array,
|
|
4558
4693
|
createJsonResponseHandler as createJsonResponseHandler6,
|
|
4559
|
-
parseProviderOptions as
|
|
4694
|
+
parseProviderOptions as parseProviderOptions7,
|
|
4560
4695
|
postJsonToApi as postJsonToApi5,
|
|
4561
4696
|
resolve as resolve5,
|
|
4562
4697
|
serializeModelOptions as serializeModelOptions4,
|
|
@@ -4656,7 +4791,7 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4656
4791
|
const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
|
|
4657
4792
|
let googleOptions;
|
|
4658
4793
|
for (const name of providerOptionsNames) {
|
|
4659
|
-
googleOptions = await
|
|
4794
|
+
googleOptions = await parseProviderOptions7({
|
|
4660
4795
|
provider: name,
|
|
4661
4796
|
providerOptions,
|
|
4662
4797
|
schema: googleSpeechProviderOptionsSchema
|
|
@@ -4666,7 +4801,7 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4666
4801
|
}
|
|
4667
4802
|
}
|
|
4668
4803
|
if (googleOptions == null && !providerOptionsNames.includes("google")) {
|
|
4669
|
-
googleOptions = await
|
|
4804
|
+
googleOptions = await parseProviderOptions7({
|
|
4670
4805
|
provider: "google",
|
|
4671
4806
|
providerOptions,
|
|
4672
4807
|
schema: googleSpeechProviderOptionsSchema
|
|
@@ -4830,7 +4965,7 @@ import {
|
|
|
4830
4965
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
4831
4966
|
createJsonResponseHandler as createJsonResponseHandler8,
|
|
4832
4967
|
generateId as defaultGenerateId2,
|
|
4833
|
-
parseProviderOptions as
|
|
4968
|
+
parseProviderOptions as parseProviderOptions8,
|
|
4834
4969
|
postJsonToApi as postJsonToApi6,
|
|
4835
4970
|
resolve as resolve6,
|
|
4836
4971
|
serializeModelOptions as serializeModelOptions5,
|
|
@@ -5621,7 +5756,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5621
5756
|
|
|
5622
5757
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
5623
5758
|
import {
|
|
5624
|
-
convertToBase64 as
|
|
5759
|
+
convertToBase64 as convertToBase644,
|
|
5625
5760
|
getTopLevelMediaType as getTopLevelMediaType2,
|
|
5626
5761
|
isFullMediaType as isFullMediaType2,
|
|
5627
5762
|
resolveFullMediaType as resolveFullMediaType2,
|
|
@@ -5822,7 +5957,7 @@ function convertFilePartToContent({
|
|
|
5822
5957
|
const mimeType = resolveFullMediaType2({ part });
|
|
5823
5958
|
return {
|
|
5824
5959
|
type: kind,
|
|
5825
|
-
data:
|
|
5960
|
+
data: convertToBase644(part.data.data),
|
|
5826
5961
|
mime_type: mimeType,
|
|
5827
5962
|
...resolutionField,
|
|
5828
5963
|
...processingField
|
|
@@ -6009,7 +6144,7 @@ function filePartToImageBlock({
|
|
|
6009
6144
|
});
|
|
6010
6145
|
return {
|
|
6011
6146
|
type: "image",
|
|
6012
|
-
data:
|
|
6147
|
+
data: convertToBase644(part.data.data),
|
|
6013
6148
|
mime_type: mimeType
|
|
6014
6149
|
};
|
|
6015
6150
|
}
|
|
@@ -7437,7 +7572,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7437
7572
|
async getArgs(options) {
|
|
7438
7573
|
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
7574
|
const warnings = [];
|
|
7440
|
-
const googleOptions = await
|
|
7575
|
+
const googleOptions = await parseProviderOptions8({
|
|
7441
7576
|
provider: "google",
|
|
7442
7577
|
providerOptions: options.providerOptions,
|
|
7443
7578
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -8338,9 +8473,9 @@ import {
|
|
|
8338
8473
|
import {
|
|
8339
8474
|
combineHeaders as combineHeaders9,
|
|
8340
8475
|
connectToWebSocket,
|
|
8341
|
-
convertToBase64 as
|
|
8476
|
+
convertToBase64 as convertToBase645,
|
|
8342
8477
|
createJsonResponseHandler as createJsonResponseHandler9,
|
|
8343
|
-
parseProviderOptions as
|
|
8478
|
+
parseProviderOptions as parseProviderOptions9,
|
|
8344
8479
|
postJsonToApi as postJsonToApi7,
|
|
8345
8480
|
resolve as resolve7,
|
|
8346
8481
|
safeParseJSON as safeParseJSON2,
|
|
@@ -8414,7 +8549,7 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8414
8549
|
return this.config.provider;
|
|
8415
8550
|
}
|
|
8416
8551
|
async parseOptions(providerOptions) {
|
|
8417
|
-
return
|
|
8552
|
+
return parseProviderOptions9({
|
|
8418
8553
|
provider: "google",
|
|
8419
8554
|
providerOptions,
|
|
8420
8555
|
schema: googleTranscriptionModelOptions
|
|
@@ -8437,7 +8572,7 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8437
8572
|
input: [
|
|
8438
8573
|
{
|
|
8439
8574
|
type: "audio",
|
|
8440
|
-
data:
|
|
8575
|
+
data: convertToBase645(options.audio),
|
|
8441
8576
|
mime_type: options.mediaType
|
|
8442
8577
|
}
|
|
8443
8578
|
],
|
|
@@ -8657,7 +8792,7 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8657
8792
|
JSON.stringify({
|
|
8658
8793
|
realtimeInput: {
|
|
8659
8794
|
audio: {
|
|
8660
|
-
data:
|
|
8795
|
+
data: convertToBase645(value),
|
|
8661
8796
|
mimeType: `audio/pcm;rate=${inputAudioRate}`
|
|
8662
8797
|
}
|
|
8663
8798
|
}
|
|
@@ -8856,8 +8991,8 @@ import {
|
|
|
8856
8991
|
connectToWebSocket as connectToWebSocket2,
|
|
8857
8992
|
combineHeaders as combineHeaders10,
|
|
8858
8993
|
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
8859
|
-
convertToBase64 as
|
|
8860
|
-
parseProviderOptions as
|
|
8994
|
+
convertToBase64 as convertToBase646,
|
|
8995
|
+
parseProviderOptions as parseProviderOptions10,
|
|
8861
8996
|
safeParseJSON as safeParseJSON3,
|
|
8862
8997
|
serializeModelOptions as serializeModelOptions7,
|
|
8863
8998
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
|
|
@@ -8920,7 +9055,7 @@ var GoogleSpeechTranslationModel = class _GoogleSpeechTranslationModel {
|
|
|
8920
9055
|
});
|
|
8921
9056
|
}
|
|
8922
9057
|
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
|
|
9058
|
+
const googleOptions = await parseProviderOptions10({
|
|
8924
9059
|
provider: "google",
|
|
8925
9060
|
providerOptions: options.providerOptions,
|
|
8926
9061
|
schema: googleSpeechTranslationModelOptions
|
|
@@ -9100,7 +9235,7 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9100
9235
|
JSON.stringify({
|
|
9101
9236
|
realtimeInput: {
|
|
9102
9237
|
audio: {
|
|
9103
|
-
data:
|
|
9238
|
+
data: convertToBase646(value),
|
|
9104
9239
|
mimeType: `audio/pcm;rate=${inputAudioRate}`
|
|
9105
9240
|
}
|
|
9106
9241
|
}
|