@ai-sdk/google 2.0.17 → 2.0.18
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 +9 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +144 -137
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +128 -121
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +9 -12
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __create = Object.create;
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
8
|
var __export = (target, all) => {
|
7
9
|
for (var name in all)
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
17
|
}
|
16
18
|
return to;
|
17
19
|
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
29
|
|
20
30
|
// src/internal/index.ts
|
@@ -28,7 +38,7 @@ module.exports = __toCommonJS(internal_exports);
|
|
28
38
|
|
29
39
|
// src/google-generative-ai-language-model.ts
|
30
40
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
31
|
-
var
|
41
|
+
var z5 = __toESM(require("zod/v4"));
|
32
42
|
|
33
43
|
// src/convert-json-schema-to-openapi-schema.ts
|
34
44
|
function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
@@ -53,12 +63,9 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
53
63
|
enum: enumValues
|
54
64
|
} = jsonSchema;
|
55
65
|
const result = {};
|
56
|
-
if (description)
|
57
|
-
|
58
|
-
if (
|
59
|
-
result.required = required;
|
60
|
-
if (format)
|
61
|
-
result.format = format;
|
66
|
+
if (description) result.description = description;
|
67
|
+
if (required) result.required = required;
|
68
|
+
if (format) result.format = format;
|
62
69
|
if (constValue !== void 0) {
|
63
70
|
result.enum = [constValue];
|
64
71
|
}
|
@@ -304,12 +311,12 @@ function getModelPath(modelId) {
|
|
304
311
|
|
305
312
|
// src/google-error.ts
|
306
313
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
307
|
-
var
|
308
|
-
var googleErrorDataSchema =
|
309
|
-
error:
|
310
|
-
code:
|
311
|
-
message:
|
312
|
-
status:
|
314
|
+
var z = __toESM(require("zod/v4"));
|
315
|
+
var googleErrorDataSchema = z.object({
|
316
|
+
error: z.object({
|
317
|
+
code: z.number().nullable(),
|
318
|
+
message: z.string(),
|
319
|
+
status: z.string()
|
313
320
|
})
|
314
321
|
});
|
315
322
|
var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
|
@@ -318,19 +325,19 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
|
|
318
325
|
});
|
319
326
|
|
320
327
|
// src/google-generative-ai-options.ts
|
321
|
-
var
|
322
|
-
var googleGenerativeAIProviderOptions =
|
323
|
-
responseModalities:
|
324
|
-
thinkingConfig:
|
325
|
-
thinkingBudget:
|
326
|
-
includeThoughts:
|
328
|
+
var z2 = __toESM(require("zod/v4"));
|
329
|
+
var googleGenerativeAIProviderOptions = z2.object({
|
330
|
+
responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
|
331
|
+
thinkingConfig: z2.object({
|
332
|
+
thinkingBudget: z2.number().optional(),
|
333
|
+
includeThoughts: z2.boolean().optional()
|
327
334
|
}).optional(),
|
328
335
|
/**
|
329
336
|
Optional.
|
330
337
|
The name of the cached content used as context to serve the prediction.
|
331
338
|
Format: cachedContents/{cachedContent}
|
332
339
|
*/
|
333
|
-
cachedContent:
|
340
|
+
cachedContent: z2.string().optional(),
|
334
341
|
/**
|
335
342
|
* Optional. Enable structured output. Default is true.
|
336
343
|
*
|
@@ -339,13 +346,13 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
|
|
339
346
|
* Google Generative AI uses. You can use this to disable
|
340
347
|
* structured outputs if you need to.
|
341
348
|
*/
|
342
|
-
structuredOutputs:
|
349
|
+
structuredOutputs: z2.boolean().optional(),
|
343
350
|
/**
|
344
351
|
Optional. A list of unique safety settings for blocking unsafe content.
|
345
352
|
*/
|
346
|
-
safetySettings:
|
347
|
-
|
348
|
-
category:
|
353
|
+
safetySettings: z2.array(
|
354
|
+
z2.object({
|
355
|
+
category: z2.enum([
|
349
356
|
"HARM_CATEGORY_UNSPECIFIED",
|
350
357
|
"HARM_CATEGORY_HATE_SPEECH",
|
351
358
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
@@ -353,7 +360,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
|
|
353
360
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
354
361
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
355
362
|
]),
|
356
|
-
threshold:
|
363
|
+
threshold: z2.enum([
|
357
364
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
358
365
|
"BLOCK_LOW_AND_ABOVE",
|
359
366
|
"BLOCK_MEDIUM_AND_ABOVE",
|
@@ -363,7 +370,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
|
|
363
370
|
])
|
364
371
|
})
|
365
372
|
).optional(),
|
366
|
-
threshold:
|
373
|
+
threshold: z2.enum([
|
367
374
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
368
375
|
"BLOCK_LOW_AND_ABOVE",
|
369
376
|
"BLOCK_MEDIUM_AND_ABOVE",
|
@@ -376,13 +383,13 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
|
|
376
383
|
*
|
377
384
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
378
385
|
*/
|
379
|
-
audioTimestamp:
|
386
|
+
audioTimestamp: z2.boolean().optional(),
|
380
387
|
/**
|
381
388
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
382
389
|
*
|
383
390
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
384
391
|
*/
|
385
|
-
labels:
|
392
|
+
labels: z2.record(z2.string(), z2.string()).optional()
|
386
393
|
});
|
387
394
|
|
388
395
|
// src/google-prepare-tools.ts
|
@@ -556,60 +563,60 @@ function mapGoogleGenerativeAIFinishReason({
|
|
556
563
|
|
557
564
|
// src/tool/google-search.ts
|
558
565
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
559
|
-
var
|
560
|
-
var groundingChunkSchema =
|
561
|
-
web:
|
562
|
-
retrievedContext:
|
566
|
+
var z3 = __toESM(require("zod/v4"));
|
567
|
+
var groundingChunkSchema = z3.object({
|
568
|
+
web: z3.object({ uri: z3.string(), title: z3.string() }).nullish(),
|
569
|
+
retrievedContext: z3.object({ uri: z3.string(), title: z3.string() }).nullish()
|
563
570
|
});
|
564
|
-
var groundingMetadataSchema =
|
565
|
-
webSearchQueries:
|
566
|
-
retrievalQueries:
|
567
|
-
searchEntryPoint:
|
568
|
-
groundingChunks:
|
569
|
-
groundingSupports:
|
570
|
-
|
571
|
-
segment:
|
572
|
-
startIndex:
|
573
|
-
endIndex:
|
574
|
-
text:
|
571
|
+
var groundingMetadataSchema = z3.object({
|
572
|
+
webSearchQueries: z3.array(z3.string()).nullish(),
|
573
|
+
retrievalQueries: z3.array(z3.string()).nullish(),
|
574
|
+
searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
|
575
|
+
groundingChunks: z3.array(groundingChunkSchema).nullish(),
|
576
|
+
groundingSupports: z3.array(
|
577
|
+
z3.object({
|
578
|
+
segment: z3.object({
|
579
|
+
startIndex: z3.number().nullish(),
|
580
|
+
endIndex: z3.number().nullish(),
|
581
|
+
text: z3.string().nullish()
|
575
582
|
}),
|
576
|
-
segment_text:
|
577
|
-
groundingChunkIndices:
|
578
|
-
supportChunkIndices:
|
579
|
-
confidenceScores:
|
580
|
-
confidenceScore:
|
583
|
+
segment_text: z3.string().nullish(),
|
584
|
+
groundingChunkIndices: z3.array(z3.number()).nullish(),
|
585
|
+
supportChunkIndices: z3.array(z3.number()).nullish(),
|
586
|
+
confidenceScores: z3.array(z3.number()).nullish(),
|
587
|
+
confidenceScore: z3.array(z3.number()).nullish()
|
581
588
|
})
|
582
589
|
).nullish(),
|
583
|
-
retrievalMetadata:
|
584
|
-
|
585
|
-
webDynamicRetrievalScore:
|
590
|
+
retrievalMetadata: z3.union([
|
591
|
+
z3.object({
|
592
|
+
webDynamicRetrievalScore: z3.number()
|
586
593
|
}),
|
587
|
-
|
594
|
+
z3.object({})
|
588
595
|
]).nullish()
|
589
596
|
});
|
590
597
|
var googleSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
|
591
598
|
id: "google.google_search",
|
592
599
|
name: "google_search",
|
593
|
-
inputSchema:
|
594
|
-
mode:
|
595
|
-
dynamicThreshold:
|
600
|
+
inputSchema: z3.object({
|
601
|
+
mode: z3.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
602
|
+
dynamicThreshold: z3.number().default(1)
|
596
603
|
})
|
597
604
|
});
|
598
605
|
|
599
606
|
// src/tool/url-context.ts
|
600
607
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
601
|
-
var
|
602
|
-
var urlMetadataSchema =
|
603
|
-
retrievedUrl:
|
604
|
-
urlRetrievalStatus:
|
608
|
+
var z4 = __toESM(require("zod/v4"));
|
609
|
+
var urlMetadataSchema = z4.object({
|
610
|
+
retrievedUrl: z4.string(),
|
611
|
+
urlRetrievalStatus: z4.string()
|
605
612
|
});
|
606
|
-
var urlContextMetadataSchema =
|
607
|
-
urlMetadata:
|
613
|
+
var urlContextMetadataSchema = z4.object({
|
614
|
+
urlMetadata: z4.array(urlMetadataSchema)
|
608
615
|
});
|
609
616
|
var urlContext = (0, import_provider_utils4.createProviderDefinedToolFactory)({
|
610
617
|
id: "google.url_context",
|
611
618
|
name: "url_context",
|
612
|
-
inputSchema:
|
619
|
+
inputSchema: z4.object({})
|
613
620
|
});
|
614
621
|
|
615
622
|
// src/google-generative-ai-language-model.ts
|
@@ -1104,100 +1111,100 @@ function extractSources({
|
|
1104
1111
|
title: chunk.web.title
|
1105
1112
|
}));
|
1106
1113
|
}
|
1107
|
-
var contentSchema =
|
1108
|
-
parts:
|
1109
|
-
|
1114
|
+
var contentSchema = z5.object({
|
1115
|
+
parts: z5.array(
|
1116
|
+
z5.union([
|
1110
1117
|
// note: order matters since text can be fully empty
|
1111
|
-
|
1112
|
-
functionCall:
|
1113
|
-
name:
|
1114
|
-
args:
|
1118
|
+
z5.object({
|
1119
|
+
functionCall: z5.object({
|
1120
|
+
name: z5.string(),
|
1121
|
+
args: z5.unknown()
|
1115
1122
|
}),
|
1116
|
-
thoughtSignature:
|
1123
|
+
thoughtSignature: z5.string().nullish()
|
1117
1124
|
}),
|
1118
|
-
|
1119
|
-
inlineData:
|
1120
|
-
mimeType:
|
1121
|
-
data:
|
1125
|
+
z5.object({
|
1126
|
+
inlineData: z5.object({
|
1127
|
+
mimeType: z5.string(),
|
1128
|
+
data: z5.string()
|
1122
1129
|
})
|
1123
1130
|
}),
|
1124
|
-
|
1125
|
-
executableCode:
|
1126
|
-
language:
|
1127
|
-
code:
|
1131
|
+
z5.object({
|
1132
|
+
executableCode: z5.object({
|
1133
|
+
language: z5.string(),
|
1134
|
+
code: z5.string()
|
1128
1135
|
}).nullish(),
|
1129
|
-
codeExecutionResult:
|
1130
|
-
outcome:
|
1131
|
-
output:
|
1136
|
+
codeExecutionResult: z5.object({
|
1137
|
+
outcome: z5.string(),
|
1138
|
+
output: z5.string()
|
1132
1139
|
}).nullish(),
|
1133
|
-
text:
|
1134
|
-
thought:
|
1135
|
-
thoughtSignature:
|
1140
|
+
text: z5.string().nullish(),
|
1141
|
+
thought: z5.boolean().nullish(),
|
1142
|
+
thoughtSignature: z5.string().nullish()
|
1136
1143
|
})
|
1137
1144
|
])
|
1138
1145
|
).nullish()
|
1139
1146
|
});
|
1140
|
-
var safetyRatingSchema =
|
1141
|
-
category:
|
1142
|
-
probability:
|
1143
|
-
probabilityScore:
|
1144
|
-
severity:
|
1145
|
-
severityScore:
|
1146
|
-
blocked:
|
1147
|
+
var safetyRatingSchema = z5.object({
|
1148
|
+
category: z5.string().nullish(),
|
1149
|
+
probability: z5.string().nullish(),
|
1150
|
+
probabilityScore: z5.number().nullish(),
|
1151
|
+
severity: z5.string().nullish(),
|
1152
|
+
severityScore: z5.number().nullish(),
|
1153
|
+
blocked: z5.boolean().nullish()
|
1147
1154
|
});
|
1148
|
-
var usageSchema =
|
1149
|
-
cachedContentTokenCount:
|
1150
|
-
thoughtsTokenCount:
|
1151
|
-
promptTokenCount:
|
1152
|
-
candidatesTokenCount:
|
1153
|
-
totalTokenCount:
|
1155
|
+
var usageSchema = z5.object({
|
1156
|
+
cachedContentTokenCount: z5.number().nullish(),
|
1157
|
+
thoughtsTokenCount: z5.number().nullish(),
|
1158
|
+
promptTokenCount: z5.number().nullish(),
|
1159
|
+
candidatesTokenCount: z5.number().nullish(),
|
1160
|
+
totalTokenCount: z5.number().nullish()
|
1154
1161
|
});
|
1155
|
-
var responseSchema =
|
1156
|
-
candidates:
|
1157
|
-
|
1158
|
-
content: contentSchema.nullish().or(
|
1159
|
-
finishReason:
|
1160
|
-
safetyRatings:
|
1162
|
+
var responseSchema = z5.object({
|
1163
|
+
candidates: z5.array(
|
1164
|
+
z5.object({
|
1165
|
+
content: contentSchema.nullish().or(z5.object({}).strict()),
|
1166
|
+
finishReason: z5.string().nullish(),
|
1167
|
+
safetyRatings: z5.array(safetyRatingSchema).nullish(),
|
1161
1168
|
groundingMetadata: groundingMetadataSchema.nullish(),
|
1162
1169
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1163
1170
|
})
|
1164
1171
|
),
|
1165
1172
|
usageMetadata: usageSchema.nullish(),
|
1166
|
-
promptFeedback:
|
1167
|
-
blockReason:
|
1168
|
-
safetyRatings:
|
1173
|
+
promptFeedback: z5.object({
|
1174
|
+
blockReason: z5.string().nullish(),
|
1175
|
+
safetyRatings: z5.array(safetyRatingSchema).nullish()
|
1169
1176
|
}).nullish()
|
1170
1177
|
});
|
1171
|
-
var chunkSchema =
|
1172
|
-
candidates:
|
1173
|
-
|
1178
|
+
var chunkSchema = z5.object({
|
1179
|
+
candidates: z5.array(
|
1180
|
+
z5.object({
|
1174
1181
|
content: contentSchema.nullish(),
|
1175
|
-
finishReason:
|
1176
|
-
safetyRatings:
|
1182
|
+
finishReason: z5.string().nullish(),
|
1183
|
+
safetyRatings: z5.array(safetyRatingSchema).nullish(),
|
1177
1184
|
groundingMetadata: groundingMetadataSchema.nullish(),
|
1178
1185
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1179
1186
|
})
|
1180
1187
|
).nullish(),
|
1181
1188
|
usageMetadata: usageSchema.nullish(),
|
1182
|
-
promptFeedback:
|
1183
|
-
blockReason:
|
1184
|
-
safetyRatings:
|
1189
|
+
promptFeedback: z5.object({
|
1190
|
+
blockReason: z5.string().nullish(),
|
1191
|
+
safetyRatings: z5.array(safetyRatingSchema).nullish()
|
1185
1192
|
}).nullish()
|
1186
1193
|
});
|
1187
1194
|
|
1188
1195
|
// src/tool/code-execution.ts
|
1189
1196
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
1190
|
-
var
|
1197
|
+
var z6 = __toESM(require("zod/v4"));
|
1191
1198
|
var codeExecution = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
|
1192
1199
|
id: "google.code_execution",
|
1193
1200
|
name: "code_execution",
|
1194
|
-
inputSchema:
|
1195
|
-
language:
|
1196
|
-
code:
|
1201
|
+
inputSchema: z6.object({
|
1202
|
+
language: z6.string().describe("The programming language of the code."),
|
1203
|
+
code: z6.string().describe("The code to be executed.")
|
1197
1204
|
}),
|
1198
|
-
outputSchema:
|
1199
|
-
outcome:
|
1200
|
-
output:
|
1205
|
+
outputSchema: z6.object({
|
1206
|
+
outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
1207
|
+
output: z6.string().describe("The output from the code execution.")
|
1201
1208
|
})
|
1202
1209
|
});
|
1203
1210
|
|