@ai-sdk/google 2.0.0-beta.2 → 2.0.0-beta.4
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 +18 -0
- package/dist/index.d.mts +56 -289
- package/dist/index.d.ts +56 -289
- package/dist/index.js +101 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +18 -162
- package/dist/internal/index.d.ts +18 -162
- package/dist/internal/index.js +94 -88
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +11 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -32,16 +32,16 @@ var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
32
32
|
// src/google-generative-ai-embedding-model.ts
|
33
33
|
var import_provider = require("@ai-sdk/provider");
|
34
34
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
35
|
-
var
|
35
|
+
var import_v43 = require("zod/v4");
|
36
36
|
|
37
37
|
// src/google-error.ts
|
38
38
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
39
|
-
var
|
40
|
-
var googleErrorDataSchema =
|
41
|
-
error:
|
42
|
-
code:
|
43
|
-
message:
|
44
|
-
status:
|
39
|
+
var import_v4 = require("zod/v4");
|
40
|
+
var googleErrorDataSchema = import_v4.z.object({
|
41
|
+
error: import_v4.z.object({
|
42
|
+
code: import_v4.z.number().nullable(),
|
43
|
+
message: import_v4.z.string(),
|
44
|
+
status: import_v4.z.string()
|
45
45
|
})
|
46
46
|
});
|
47
47
|
var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
@@ -50,13 +50,13 @@ var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
50
50
|
});
|
51
51
|
|
52
52
|
// src/google-generative-ai-embedding-options.ts
|
53
|
-
var
|
54
|
-
var googleGenerativeAIEmbeddingProviderOptions =
|
53
|
+
var import_v42 = require("zod/v4");
|
54
|
+
var googleGenerativeAIEmbeddingProviderOptions = import_v42.z.object({
|
55
55
|
/**
|
56
56
|
* Optional. Optional reduced dimension for the output embedding.
|
57
57
|
* If set, excessive values in the output embedding are truncated from the end.
|
58
58
|
*/
|
59
|
-
outputDimensionality:
|
59
|
+
outputDimensionality: import_v42.z.number().optional(),
|
60
60
|
/**
|
61
61
|
* Optional. Specifies the task type for generating embeddings.
|
62
62
|
* Supported task types:
|
@@ -69,7 +69,7 @@ var googleGenerativeAIEmbeddingProviderOptions = import_zod2.z.object({
|
|
69
69
|
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
70
70
|
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
71
71
|
*/
|
72
|
-
taskType:
|
72
|
+
taskType: import_v42.z.enum([
|
73
73
|
"SEMANTIC_SIMILARITY",
|
74
74
|
"CLASSIFICATION",
|
75
75
|
"CLUSTERING",
|
@@ -145,13 +145,13 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
145
145
|
};
|
146
146
|
}
|
147
147
|
};
|
148
|
-
var googleGenerativeAITextEmbeddingResponseSchema =
|
149
|
-
embeddings:
|
148
|
+
var googleGenerativeAITextEmbeddingResponseSchema = import_v43.z.object({
|
149
|
+
embeddings: import_v43.z.array(import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) }))
|
150
150
|
});
|
151
151
|
|
152
152
|
// src/google-generative-ai-language-model.ts
|
153
153
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
154
|
-
var
|
154
|
+
var import_v45 = require("zod/v4");
|
155
155
|
|
156
156
|
// src/convert-json-schema-to-openapi-schema.ts
|
157
157
|
function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
@@ -173,7 +173,8 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
173
173
|
format,
|
174
174
|
const: constValue,
|
175
175
|
minLength,
|
176
|
-
enum: enumValues
|
176
|
+
enum: enumValues,
|
177
|
+
additionalProperties
|
177
178
|
} = jsonSchema;
|
178
179
|
const result = {};
|
179
180
|
if (description)
|
@@ -244,10 +245,15 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
244
245
|
if (minLength !== void 0) {
|
245
246
|
result.minLength = minLength;
|
246
247
|
}
|
248
|
+
if (additionalProperties === true) {
|
249
|
+
result.additionalProperties = true;
|
250
|
+
} else if (additionalProperties) {
|
251
|
+
result.additionalProperties = convertJSONSchemaToOpenAPISchema(additionalProperties);
|
252
|
+
}
|
247
253
|
return result;
|
248
254
|
}
|
249
255
|
function isEmptyObjectSchema(jsonSchema) {
|
250
|
-
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0);
|
256
|
+
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
251
257
|
}
|
252
258
|
|
253
259
|
// src/convert-to-google-generative-ai-messages.ts
|
@@ -369,30 +375,30 @@ function getModelPath(modelId) {
|
|
369
375
|
}
|
370
376
|
|
371
377
|
// src/google-generative-ai-options.ts
|
372
|
-
var
|
373
|
-
var dynamicRetrievalConfig =
|
378
|
+
var import_v44 = require("zod/v4");
|
379
|
+
var dynamicRetrievalConfig = import_v44.z.object({
|
374
380
|
/**
|
375
381
|
* The mode of the predictor to be used in dynamic retrieval.
|
376
382
|
*/
|
377
|
-
mode:
|
383
|
+
mode: import_v44.z.enum(["MODE_UNSPECIFIED", "MODE_DYNAMIC"]).optional(),
|
378
384
|
/**
|
379
385
|
* The threshold to be used in dynamic retrieval. If not set, a system default
|
380
386
|
* value is used.
|
381
387
|
*/
|
382
|
-
dynamicThreshold:
|
388
|
+
dynamicThreshold: import_v44.z.number().optional()
|
383
389
|
});
|
384
|
-
var googleGenerativeAIProviderOptions =
|
385
|
-
responseModalities:
|
386
|
-
thinkingConfig:
|
387
|
-
thinkingBudget:
|
388
|
-
includeThoughts:
|
390
|
+
var googleGenerativeAIProviderOptions = import_v44.z.object({
|
391
|
+
responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
|
392
|
+
thinkingConfig: import_v44.z.object({
|
393
|
+
thinkingBudget: import_v44.z.number().optional(),
|
394
|
+
includeThoughts: import_v44.z.boolean().optional()
|
389
395
|
}).optional(),
|
390
396
|
/**
|
391
397
|
Optional.
|
392
398
|
The name of the cached content used as context to serve the prediction.
|
393
399
|
Format: cachedContents/{cachedContent}
|
394
400
|
*/
|
395
|
-
cachedContent:
|
401
|
+
cachedContent: import_v44.z.string().optional(),
|
396
402
|
/**
|
397
403
|
* Optional. Enable structured output. Default is true.
|
398
404
|
*
|
@@ -401,13 +407,13 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
401
407
|
* Google Generative AI uses. You can use this to disable
|
402
408
|
* structured outputs if you need to.
|
403
409
|
*/
|
404
|
-
structuredOutputs:
|
410
|
+
structuredOutputs: import_v44.z.boolean().optional(),
|
405
411
|
/**
|
406
412
|
Optional. A list of unique safety settings for blocking unsafe content.
|
407
413
|
*/
|
408
|
-
safetySettings:
|
409
|
-
|
410
|
-
category:
|
414
|
+
safetySettings: import_v44.z.array(
|
415
|
+
import_v44.z.object({
|
416
|
+
category: import_v44.z.enum([
|
411
417
|
"HARM_CATEGORY_UNSPECIFIED",
|
412
418
|
"HARM_CATEGORY_HATE_SPEECH",
|
413
419
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
@@ -415,7 +421,7 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
415
421
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
416
422
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
417
423
|
]),
|
418
|
-
threshold:
|
424
|
+
threshold: import_v44.z.enum([
|
419
425
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
420
426
|
"BLOCK_LOW_AND_ABOVE",
|
421
427
|
"BLOCK_MEDIUM_AND_ABOVE",
|
@@ -425,7 +431,7 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
425
431
|
])
|
426
432
|
})
|
427
433
|
).optional(),
|
428
|
-
threshold:
|
434
|
+
threshold: import_v44.z.enum([
|
429
435
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
430
436
|
"BLOCK_LOW_AND_ABOVE",
|
431
437
|
"BLOCK_MEDIUM_AND_ABOVE",
|
@@ -438,13 +444,13 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
438
444
|
*
|
439
445
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
440
446
|
*/
|
441
|
-
audioTimestamp:
|
447
|
+
audioTimestamp: import_v44.z.boolean().optional(),
|
442
448
|
/**
|
443
449
|
Optional. When enabled, the model will use Google search to ground the response.
|
444
450
|
|
445
451
|
@see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
|
446
452
|
*/
|
447
|
-
useSearchGrounding:
|
453
|
+
useSearchGrounding: import_v44.z.boolean().optional(),
|
448
454
|
/**
|
449
455
|
Optional. Specifies the dynamic retrieval configuration.
|
450
456
|
|
@@ -974,91 +980,91 @@ function extractSources({
|
|
974
980
|
title: chunk.web.title
|
975
981
|
}));
|
976
982
|
}
|
977
|
-
var contentSchema =
|
978
|
-
parts:
|
979
|
-
|
983
|
+
var contentSchema = import_v45.z.object({
|
984
|
+
parts: import_v45.z.array(
|
985
|
+
import_v45.z.union([
|
980
986
|
// note: order matters since text can be fully empty
|
981
|
-
|
982
|
-
functionCall:
|
983
|
-
name:
|
984
|
-
args:
|
987
|
+
import_v45.z.object({
|
988
|
+
functionCall: import_v45.z.object({
|
989
|
+
name: import_v45.z.string(),
|
990
|
+
args: import_v45.z.unknown()
|
985
991
|
})
|
986
992
|
}),
|
987
|
-
|
988
|
-
inlineData:
|
989
|
-
mimeType:
|
990
|
-
data:
|
993
|
+
import_v45.z.object({
|
994
|
+
inlineData: import_v45.z.object({
|
995
|
+
mimeType: import_v45.z.string(),
|
996
|
+
data: import_v45.z.string()
|
991
997
|
})
|
992
998
|
}),
|
993
|
-
|
994
|
-
text:
|
995
|
-
thought:
|
999
|
+
import_v45.z.object({
|
1000
|
+
text: import_v45.z.string().nullish(),
|
1001
|
+
thought: import_v45.z.boolean().nullish()
|
996
1002
|
})
|
997
1003
|
])
|
998
1004
|
).nullish()
|
999
1005
|
});
|
1000
|
-
var groundingChunkSchema =
|
1001
|
-
web:
|
1002
|
-
retrievedContext:
|
1006
|
+
var groundingChunkSchema = import_v45.z.object({
|
1007
|
+
web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
|
1008
|
+
retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
|
1003
1009
|
});
|
1004
|
-
var groundingMetadataSchema =
|
1005
|
-
webSearchQueries:
|
1006
|
-
retrievalQueries:
|
1007
|
-
searchEntryPoint:
|
1008
|
-
groundingChunks:
|
1009
|
-
groundingSupports:
|
1010
|
-
|
1011
|
-
segment:
|
1012
|
-
startIndex:
|
1013
|
-
endIndex:
|
1014
|
-
text:
|
1010
|
+
var groundingMetadataSchema = import_v45.z.object({
|
1011
|
+
webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
1012
|
+
retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
1013
|
+
searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
|
1014
|
+
groundingChunks: import_v45.z.array(groundingChunkSchema).nullish(),
|
1015
|
+
groundingSupports: import_v45.z.array(
|
1016
|
+
import_v45.z.object({
|
1017
|
+
segment: import_v45.z.object({
|
1018
|
+
startIndex: import_v45.z.number().nullish(),
|
1019
|
+
endIndex: import_v45.z.number().nullish(),
|
1020
|
+
text: import_v45.z.string().nullish()
|
1015
1021
|
}),
|
1016
|
-
segment_text:
|
1017
|
-
groundingChunkIndices:
|
1018
|
-
supportChunkIndices:
|
1019
|
-
confidenceScores:
|
1020
|
-
confidenceScore:
|
1022
|
+
segment_text: import_v45.z.string().nullish(),
|
1023
|
+
groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
|
1024
|
+
supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
|
1025
|
+
confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
|
1026
|
+
confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
|
1021
1027
|
})
|
1022
1028
|
).nullish(),
|
1023
|
-
retrievalMetadata:
|
1024
|
-
|
1025
|
-
webDynamicRetrievalScore:
|
1029
|
+
retrievalMetadata: import_v45.z.union([
|
1030
|
+
import_v45.z.object({
|
1031
|
+
webDynamicRetrievalScore: import_v45.z.number()
|
1026
1032
|
}),
|
1027
|
-
|
1033
|
+
import_v45.z.object({})
|
1028
1034
|
]).nullish()
|
1029
1035
|
});
|
1030
|
-
var safetyRatingSchema =
|
1031
|
-
category:
|
1032
|
-
probability:
|
1033
|
-
probabilityScore:
|
1034
|
-
severity:
|
1035
|
-
severityScore:
|
1036
|
-
blocked:
|
1036
|
+
var safetyRatingSchema = import_v45.z.object({
|
1037
|
+
category: import_v45.z.string().nullish(),
|
1038
|
+
probability: import_v45.z.string().nullish(),
|
1039
|
+
probabilityScore: import_v45.z.number().nullish(),
|
1040
|
+
severity: import_v45.z.string().nullish(),
|
1041
|
+
severityScore: import_v45.z.number().nullish(),
|
1042
|
+
blocked: import_v45.z.boolean().nullish()
|
1037
1043
|
});
|
1038
|
-
var usageSchema =
|
1039
|
-
cachedContentTokenCount:
|
1040
|
-
thoughtsTokenCount:
|
1041
|
-
promptTokenCount:
|
1042
|
-
candidatesTokenCount:
|
1043
|
-
totalTokenCount:
|
1044
|
+
var usageSchema = import_v45.z.object({
|
1045
|
+
cachedContentTokenCount: import_v45.z.number().nullish(),
|
1046
|
+
thoughtsTokenCount: import_v45.z.number().nullish(),
|
1047
|
+
promptTokenCount: import_v45.z.number().nullish(),
|
1048
|
+
candidatesTokenCount: import_v45.z.number().nullish(),
|
1049
|
+
totalTokenCount: import_v45.z.number().nullish()
|
1044
1050
|
});
|
1045
|
-
var responseSchema =
|
1046
|
-
candidates:
|
1047
|
-
|
1048
|
-
content: contentSchema.nullish().or(
|
1049
|
-
finishReason:
|
1050
|
-
safetyRatings:
|
1051
|
+
var responseSchema = import_v45.z.object({
|
1052
|
+
candidates: import_v45.z.array(
|
1053
|
+
import_v45.z.object({
|
1054
|
+
content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
|
1055
|
+
finishReason: import_v45.z.string().nullish(),
|
1056
|
+
safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
|
1051
1057
|
groundingMetadata: groundingMetadataSchema.nullish()
|
1052
1058
|
})
|
1053
1059
|
),
|
1054
1060
|
usageMetadata: usageSchema.nullish()
|
1055
1061
|
});
|
1056
|
-
var chunkSchema =
|
1057
|
-
candidates:
|
1058
|
-
|
1062
|
+
var chunkSchema = import_v45.z.object({
|
1063
|
+
candidates: import_v45.z.array(
|
1064
|
+
import_v45.z.object({
|
1059
1065
|
content: contentSchema.nullish(),
|
1060
|
-
finishReason:
|
1061
|
-
safetyRatings:
|
1066
|
+
finishReason: import_v45.z.string().nullish(),
|
1067
|
+
safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
|
1062
1068
|
groundingMetadata: groundingMetadataSchema.nullish()
|
1063
1069
|
})
|
1064
1070
|
).nullish(),
|