@ai-sdk/google 4.0.114 → 4.0.117
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 +25 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -3
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +20 -9
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +1 -0
- package/package.json +3 -3
- package/src/google-json-accumulator.ts +21 -6
- package/src/google-language-model-options.ts +1 -0
- package/src/google-language-model.ts +11 -2
- package/src/google-model-catalog.ts +1 -0
- package/src/interactions/google-interactions-language-model-options.ts +1 -0
package/docs/15-google.mdx
CHANGED
|
@@ -1279,6 +1279,7 @@ will still validate the response against the schema in `Output.object`.
|
|
|
1279
1279
|
| ------------------------------------- | ----------- | ----------------- | ---------- | -------------- | ------------- | ----------- |
|
|
1280
1280
|
| `gemini-nano-banana-2.1` | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Check /> | <Cross /> |
|
|
1281
1281
|
| `gemini-4-argon` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
1282
|
+
| `gemini-4-carbon` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
1282
1283
|
| `gemini-3.8-flash` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
1283
1284
|
| `gemini-3.7-flash` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
1284
1285
|
| `gemini-3.6-flash` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.117",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ai-sdk/provider": "4.0.37",
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.79"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.4",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@vercel/ai-tsdown-config": "0.0.0",
|
|
46
46
|
"tsdown": "^0.23.0",
|
|
47
47
|
"typescript": "6.0.3",
|
|
48
|
-
"zod": "
|
|
48
|
+
"zod": "4.6.7"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -61,7 +61,7 @@ export class GoogleJSONAccumulator {
|
|
|
61
61
|
if (!rawPath || rawPath === '$') continue;
|
|
62
62
|
|
|
63
63
|
const segments = parsePath(rawPath);
|
|
64
|
-
if (!
|
|
64
|
+
if (!normalizeAndCheckIndexes(this.accumulatedArgs, segments)) continue;
|
|
65
65
|
|
|
66
66
|
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
67
67
|
const isStringContinuation =
|
|
@@ -388,20 +388,35 @@ function getNestedValue(
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
/**
|
|
391
|
-
*
|
|
392
|
-
* one. Arrays are streamed in order, and a
|
|
393
|
-
* serialize one `null` per hole, so a tiny
|
|
391
|
+
* Normalizes dotted array indexes in place and checks that every array index
|
|
392
|
+
* is an existing element or the next one. Arrays are streamed in order, and a
|
|
393
|
+
* sparse index would make `finalize()` serialize one `null` per hole, so a tiny
|
|
394
|
+
* response could allocate without bound.
|
|
394
395
|
* A missing or `null` parent is replaced with a new array, so it starts at 0.
|
|
395
396
|
*
|
|
396
397
|
* Input: ({items:["a"]}, ["items",1]) or ({items:["a"]}, ["items",5])
|
|
397
398
|
* Output: true or false
|
|
398
399
|
*/
|
|
399
|
-
function
|
|
400
|
+
function normalizeAndCheckIndexes(
|
|
400
401
|
obj: Record<string, unknown>,
|
|
401
402
|
segments: Array<string | number>,
|
|
402
403
|
): boolean {
|
|
403
404
|
let current: unknown = obj;
|
|
404
|
-
for (
|
|
405
|
+
for (let i = 0; i < segments.length; i++) {
|
|
406
|
+
let pathSegment = segments[i];
|
|
407
|
+
if (Array.isArray(current) && typeof pathSegment === 'string') {
|
|
408
|
+
const index = Number(pathSegment);
|
|
409
|
+
// Only canonical array-index keys affect length. Keep object keys as strings.
|
|
410
|
+
if (
|
|
411
|
+
Number.isInteger(index) &&
|
|
412
|
+
index >= 0 &&
|
|
413
|
+
index < 2 ** 32 - 1 &&
|
|
414
|
+
String(index) === pathSegment
|
|
415
|
+
) {
|
|
416
|
+
pathSegment = index;
|
|
417
|
+
segments[i] = index;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
405
420
|
if (typeof pathSegment === 'number') {
|
|
406
421
|
const length = Array.isArray(current)
|
|
407
422
|
? current.length
|
|
@@ -518,6 +518,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
518
518
|
static convertGenerateContentResponse({
|
|
519
519
|
config,
|
|
520
520
|
response,
|
|
521
|
+
responseHeaders,
|
|
521
522
|
warnings,
|
|
522
523
|
providerOptionsNames,
|
|
523
524
|
toolNameMapping,
|
|
@@ -527,6 +528,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
527
528
|
}: {
|
|
528
529
|
config: GoogleLanguageModelConfig;
|
|
529
530
|
response: InferSchema<typeof responseSchema>;
|
|
531
|
+
responseHeaders?: Record<string, string>;
|
|
530
532
|
warnings: SharedV4Warning[];
|
|
531
533
|
providerOptionsNames: readonly string[];
|
|
532
534
|
toolNameMapping?: ReturnType<typeof createToolNameMapping>;
|
|
@@ -730,7 +732,10 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
730
732
|
safetyRatings: candidate?.safetyRatings ?? null,
|
|
731
733
|
usageMetadata: usageMetadata ?? null,
|
|
732
734
|
finishMessage: candidate?.finishMessage ?? null,
|
|
733
|
-
serviceTier:
|
|
735
|
+
serviceTier:
|
|
736
|
+
usageMetadata?.serviceTier ??
|
|
737
|
+
responseHeaders?.['x-gemini-service-tier'] ??
|
|
738
|
+
null,
|
|
734
739
|
...(candidate?.continuationToken != null
|
|
735
740
|
? { continuationToken: candidate.continuationToken }
|
|
736
741
|
: {}),
|
|
@@ -832,6 +837,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
832
837
|
const lastResult = GoogleLanguageModel.convertGenerateContentResponse({
|
|
833
838
|
config: this.config,
|
|
834
839
|
response: { ...response, usageMetadata },
|
|
840
|
+
responseHeaders,
|
|
835
841
|
warnings,
|
|
836
842
|
providerOptionsNames,
|
|
837
843
|
toolNameMapping,
|
|
@@ -1591,7 +1597,10 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
1591
1597
|
safetyRatings: lastSafetyRatings,
|
|
1592
1598
|
usageMetadata: usage ?? null,
|
|
1593
1599
|
finishMessage: lastFinishMessage,
|
|
1594
|
-
serviceTier:
|
|
1600
|
+
serviceTier:
|
|
1601
|
+
usage?.serviceTier ??
|
|
1602
|
+
responseHeaders?.['x-gemini-service-tier'] ??
|
|
1603
|
+
null,
|
|
1595
1604
|
// Only surface the token when the response stopped early
|
|
1596
1605
|
// (budget used up, or continuing failed), not for the
|
|
1597
1606
|
// checkpoint tokens of a stream that finished normally.
|
|
@@ -119,6 +119,7 @@ const documentedModels: Record<string, DocumentedCapabilities> = {
|
|
|
119
119
|
urlContext: false,
|
|
120
120
|
},
|
|
121
121
|
'gemini-4-argon': standard,
|
|
122
|
+
'gemini-4-carbon': standard,
|
|
122
123
|
'gemini-3.8-flash': standard,
|
|
123
124
|
'gemini-3.7-flash': standard,
|
|
124
125
|
'gemini-3.6-flash': standard,
|