@ai-sdk/google 2.0.0-beta.1 → 2.0.0-beta.3
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 +17 -0
- package/dist/index.d.mts +56 -289
- package/dist/index.d.ts +56 -289
- package/dist/index.js +101 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -6
- 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 -87
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +11 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
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) {
|
@@ -369,30 +369,30 @@ function getModelPath(modelId) {
|
|
369
369
|
}
|
370
370
|
|
371
371
|
// src/google-generative-ai-options.ts
|
372
|
-
var
|
373
|
-
var dynamicRetrievalConfig =
|
372
|
+
var import_v44 = require("zod/v4");
|
373
|
+
var dynamicRetrievalConfig = import_v44.z.object({
|
374
374
|
/**
|
375
375
|
* The mode of the predictor to be used in dynamic retrieval.
|
376
376
|
*/
|
377
|
-
mode:
|
377
|
+
mode: import_v44.z.enum(["MODE_UNSPECIFIED", "MODE_DYNAMIC"]).optional(),
|
378
378
|
/**
|
379
379
|
* The threshold to be used in dynamic retrieval. If not set, a system default
|
380
380
|
* value is used.
|
381
381
|
*/
|
382
|
-
dynamicThreshold:
|
382
|
+
dynamicThreshold: import_v44.z.number().optional()
|
383
383
|
});
|
384
|
-
var googleGenerativeAIProviderOptions =
|
385
|
-
responseModalities:
|
386
|
-
thinkingConfig:
|
387
|
-
thinkingBudget:
|
388
|
-
includeThoughts:
|
384
|
+
var googleGenerativeAIProviderOptions = import_v44.z.object({
|
385
|
+
responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
|
386
|
+
thinkingConfig: import_v44.z.object({
|
387
|
+
thinkingBudget: import_v44.z.number().optional(),
|
388
|
+
includeThoughts: import_v44.z.boolean().optional()
|
389
389
|
}).optional(),
|
390
390
|
/**
|
391
391
|
Optional.
|
392
392
|
The name of the cached content used as context to serve the prediction.
|
393
393
|
Format: cachedContents/{cachedContent}
|
394
394
|
*/
|
395
|
-
cachedContent:
|
395
|
+
cachedContent: import_v44.z.string().optional(),
|
396
396
|
/**
|
397
397
|
* Optional. Enable structured output. Default is true.
|
398
398
|
*
|
@@ -401,13 +401,13 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
401
401
|
* Google Generative AI uses. You can use this to disable
|
402
402
|
* structured outputs if you need to.
|
403
403
|
*/
|
404
|
-
structuredOutputs:
|
404
|
+
structuredOutputs: import_v44.z.boolean().optional(),
|
405
405
|
/**
|
406
406
|
Optional. A list of unique safety settings for blocking unsafe content.
|
407
407
|
*/
|
408
|
-
safetySettings:
|
409
|
-
|
410
|
-
category:
|
408
|
+
safetySettings: import_v44.z.array(
|
409
|
+
import_v44.z.object({
|
410
|
+
category: import_v44.z.enum([
|
411
411
|
"HARM_CATEGORY_UNSPECIFIED",
|
412
412
|
"HARM_CATEGORY_HATE_SPEECH",
|
413
413
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
@@ -415,7 +415,7 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
415
415
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
416
416
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
417
417
|
]),
|
418
|
-
threshold:
|
418
|
+
threshold: import_v44.z.enum([
|
419
419
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
420
420
|
"BLOCK_LOW_AND_ABOVE",
|
421
421
|
"BLOCK_MEDIUM_AND_ABOVE",
|
@@ -425,7 +425,7 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
425
425
|
])
|
426
426
|
})
|
427
427
|
).optional(),
|
428
|
-
threshold:
|
428
|
+
threshold: import_v44.z.enum([
|
429
429
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
430
430
|
"BLOCK_LOW_AND_ABOVE",
|
431
431
|
"BLOCK_MEDIUM_AND_ABOVE",
|
@@ -438,13 +438,13 @@ var googleGenerativeAIProviderOptions = import_zod4.z.object({
|
|
438
438
|
*
|
439
439
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
440
440
|
*/
|
441
|
-
audioTimestamp:
|
441
|
+
audioTimestamp: import_v44.z.boolean().optional(),
|
442
442
|
/**
|
443
443
|
Optional. When enabled, the model will use Google search to ground the response.
|
444
444
|
|
445
445
|
@see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
|
446
446
|
*/
|
447
|
-
useSearchGrounding:
|
447
|
+
useSearchGrounding: import_v44.z.boolean().optional(),
|
448
448
|
/**
|
449
449
|
Optional. Specifies the dynamic retrieval configuration.
|
450
450
|
|
@@ -610,6 +610,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
610
610
|
});
|
611
611
|
}
|
612
612
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(prompt);
|
613
|
+
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
614
|
+
if (isGemmaModel && systemInstruction && systemInstruction.parts.length > 0) {
|
615
|
+
warnings.push({
|
616
|
+
type: "other",
|
617
|
+
message: `GEMMA models do not support system instructions. System messages will be ignored. Consider including instructions in the first user message instead.`
|
618
|
+
});
|
619
|
+
}
|
613
620
|
const {
|
614
621
|
tools: googleTools,
|
615
622
|
toolConfig: googleToolConfig,
|
@@ -647,7 +654,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
647
654
|
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
|
648
655
|
},
|
649
656
|
contents,
|
650
|
-
systemInstruction,
|
657
|
+
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
651
658
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
652
659
|
tools: googleTools,
|
653
660
|
toolConfig: googleToolConfig,
|
@@ -967,91 +974,91 @@ function extractSources({
|
|
967
974
|
title: chunk.web.title
|
968
975
|
}));
|
969
976
|
}
|
970
|
-
var contentSchema =
|
971
|
-
parts:
|
972
|
-
|
977
|
+
var contentSchema = import_v45.z.object({
|
978
|
+
parts: import_v45.z.array(
|
979
|
+
import_v45.z.union([
|
973
980
|
// note: order matters since text can be fully empty
|
974
|
-
|
975
|
-
functionCall:
|
976
|
-
name:
|
977
|
-
args:
|
981
|
+
import_v45.z.object({
|
982
|
+
functionCall: import_v45.z.object({
|
983
|
+
name: import_v45.z.string(),
|
984
|
+
args: import_v45.z.unknown()
|
978
985
|
})
|
979
986
|
}),
|
980
|
-
|
981
|
-
inlineData:
|
982
|
-
mimeType:
|
983
|
-
data:
|
987
|
+
import_v45.z.object({
|
988
|
+
inlineData: import_v45.z.object({
|
989
|
+
mimeType: import_v45.z.string(),
|
990
|
+
data: import_v45.z.string()
|
984
991
|
})
|
985
992
|
}),
|
986
|
-
|
987
|
-
text:
|
988
|
-
thought:
|
993
|
+
import_v45.z.object({
|
994
|
+
text: import_v45.z.string().nullish(),
|
995
|
+
thought: import_v45.z.boolean().nullish()
|
989
996
|
})
|
990
997
|
])
|
991
998
|
).nullish()
|
992
999
|
});
|
993
|
-
var groundingChunkSchema =
|
994
|
-
web:
|
995
|
-
retrievedContext:
|
1000
|
+
var groundingChunkSchema = import_v45.z.object({
|
1001
|
+
web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
|
1002
|
+
retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
|
996
1003
|
});
|
997
|
-
var groundingMetadataSchema =
|
998
|
-
webSearchQueries:
|
999
|
-
retrievalQueries:
|
1000
|
-
searchEntryPoint:
|
1001
|
-
groundingChunks:
|
1002
|
-
groundingSupports:
|
1003
|
-
|
1004
|
-
segment:
|
1005
|
-
startIndex:
|
1006
|
-
endIndex:
|
1007
|
-
text:
|
1004
|
+
var groundingMetadataSchema = import_v45.z.object({
|
1005
|
+
webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
1006
|
+
retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
|
1007
|
+
searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
|
1008
|
+
groundingChunks: import_v45.z.array(groundingChunkSchema).nullish(),
|
1009
|
+
groundingSupports: import_v45.z.array(
|
1010
|
+
import_v45.z.object({
|
1011
|
+
segment: import_v45.z.object({
|
1012
|
+
startIndex: import_v45.z.number().nullish(),
|
1013
|
+
endIndex: import_v45.z.number().nullish(),
|
1014
|
+
text: import_v45.z.string().nullish()
|
1008
1015
|
}),
|
1009
|
-
segment_text:
|
1010
|
-
groundingChunkIndices:
|
1011
|
-
supportChunkIndices:
|
1012
|
-
confidenceScores:
|
1013
|
-
confidenceScore:
|
1016
|
+
segment_text: import_v45.z.string().nullish(),
|
1017
|
+
groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
|
1018
|
+
supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
|
1019
|
+
confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
|
1020
|
+
confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
|
1014
1021
|
})
|
1015
1022
|
).nullish(),
|
1016
|
-
retrievalMetadata:
|
1017
|
-
|
1018
|
-
webDynamicRetrievalScore:
|
1023
|
+
retrievalMetadata: import_v45.z.union([
|
1024
|
+
import_v45.z.object({
|
1025
|
+
webDynamicRetrievalScore: import_v45.z.number()
|
1019
1026
|
}),
|
1020
|
-
|
1027
|
+
import_v45.z.object({})
|
1021
1028
|
]).nullish()
|
1022
1029
|
});
|
1023
|
-
var safetyRatingSchema =
|
1024
|
-
category:
|
1025
|
-
probability:
|
1026
|
-
probabilityScore:
|
1027
|
-
severity:
|
1028
|
-
severityScore:
|
1029
|
-
blocked:
|
1030
|
+
var safetyRatingSchema = import_v45.z.object({
|
1031
|
+
category: import_v45.z.string().nullish(),
|
1032
|
+
probability: import_v45.z.string().nullish(),
|
1033
|
+
probabilityScore: import_v45.z.number().nullish(),
|
1034
|
+
severity: import_v45.z.string().nullish(),
|
1035
|
+
severityScore: import_v45.z.number().nullish(),
|
1036
|
+
blocked: import_v45.z.boolean().nullish()
|
1030
1037
|
});
|
1031
|
-
var usageSchema =
|
1032
|
-
cachedContentTokenCount:
|
1033
|
-
thoughtsTokenCount:
|
1034
|
-
promptTokenCount:
|
1035
|
-
candidatesTokenCount:
|
1036
|
-
totalTokenCount:
|
1038
|
+
var usageSchema = import_v45.z.object({
|
1039
|
+
cachedContentTokenCount: import_v45.z.number().nullish(),
|
1040
|
+
thoughtsTokenCount: import_v45.z.number().nullish(),
|
1041
|
+
promptTokenCount: import_v45.z.number().nullish(),
|
1042
|
+
candidatesTokenCount: import_v45.z.number().nullish(),
|
1043
|
+
totalTokenCount: import_v45.z.number().nullish()
|
1037
1044
|
});
|
1038
|
-
var responseSchema =
|
1039
|
-
candidates:
|
1040
|
-
|
1041
|
-
content: contentSchema.nullish().or(
|
1042
|
-
finishReason:
|
1043
|
-
safetyRatings:
|
1045
|
+
var responseSchema = import_v45.z.object({
|
1046
|
+
candidates: import_v45.z.array(
|
1047
|
+
import_v45.z.object({
|
1048
|
+
content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
|
1049
|
+
finishReason: import_v45.z.string().nullish(),
|
1050
|
+
safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
|
1044
1051
|
groundingMetadata: groundingMetadataSchema.nullish()
|
1045
1052
|
})
|
1046
1053
|
),
|
1047
1054
|
usageMetadata: usageSchema.nullish()
|
1048
1055
|
});
|
1049
|
-
var chunkSchema =
|
1050
|
-
candidates:
|
1051
|
-
|
1056
|
+
var chunkSchema = import_v45.z.object({
|
1057
|
+
candidates: import_v45.z.array(
|
1058
|
+
import_v45.z.object({
|
1052
1059
|
content: contentSchema.nullish(),
|
1053
|
-
finishReason:
|
1054
|
-
safetyRatings:
|
1060
|
+
finishReason: import_v45.z.string().nullish(),
|
1061
|
+
safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
|
1055
1062
|
groundingMetadata: groundingMetadataSchema.nullish()
|
1056
1063
|
})
|
1057
1064
|
).nullish(),
|