@ai-sdk/google 3.0.118 → 3.0.119

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "3.0.118",
3
+ "version": "3.0.119",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "3.0.15",
40
- "@ai-sdk/provider-utils": "4.0.49"
40
+ "@ai-sdk/provider-utils": "4.0.50"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -8,13 +8,16 @@ export type GoogleGenerativeAITokenDetail = {
8
8
  export type GoogleGenerativeAIUsageMetadata = {
9
9
  promptTokenCount?: number | null;
10
10
  candidatesTokenCount?: number | null;
11
+ toolUsePromptTokenCount?: number | null;
11
12
  totalTokenCount?: number | null;
12
13
  cachedContentTokenCount?: number | null;
13
14
  thoughtsTokenCount?: number | null;
14
15
  trafficType?: string | null;
15
16
  serviceTier?: string | null;
16
17
  promptTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
18
+ cacheTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
17
19
  candidatesTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
20
+ toolUsePromptTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
18
21
  };
19
22
 
20
23
  export function convertGoogleGenerativeAIUsage(
@@ -1481,26 +1481,33 @@ const getSafetyRatingSchema = () =>
1481
1481
 
1482
1482
  const tokenDetailsSchema = z
1483
1483
  .array(
1484
- z.object({
1485
- modality: z.string(),
1486
- tokenCount: z.number(),
1487
- }),
1484
+ z
1485
+ .object({
1486
+ modality: z.string(),
1487
+ tokenCount: z.number(),
1488
+ })
1489
+ .catchall(z.json()),
1488
1490
  )
1489
1491
  .nullish();
1490
1492
 
1491
- const usageSchema = z.object({
1492
- cachedContentTokenCount: z.number().nullish(),
1493
- thoughtsTokenCount: z.number().nullish(),
1494
- promptTokenCount: z.number().nullish(),
1495
- candidatesTokenCount: z.number().nullish(),
1496
- totalTokenCount: z.number().nullish(),
1497
- // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1498
- trafficType: z.string().nullish(),
1499
- serviceTier: z.string().nullish(),
1500
- // https://ai.google.dev/api/generate-content#Modality
1501
- promptTokensDetails: tokenDetailsSchema,
1502
- candidatesTokensDetails: tokenDetailsSchema,
1503
- });
1493
+ const usageSchema = z
1494
+ .object({
1495
+ cachedContentTokenCount: z.number().nullish(),
1496
+ thoughtsTokenCount: z.number().nullish(),
1497
+ promptTokenCount: z.number().nullish(),
1498
+ candidatesTokenCount: z.number().nullish(),
1499
+ toolUsePromptTokenCount: z.number().nullish(),
1500
+ totalTokenCount: z.number().nullish(),
1501
+ // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1502
+ trafficType: z.string().nullish(),
1503
+ serviceTier: z.string().nullish(),
1504
+ // https://ai.google.dev/api/generate-content#Modality
1505
+ promptTokensDetails: tokenDetailsSchema,
1506
+ cacheTokensDetails: tokenDetailsSchema,
1507
+ candidatesTokensDetails: tokenDetailsSchema,
1508
+ toolUsePromptTokensDetails: tokenDetailsSchema,
1509
+ })
1510
+ .catchall(z.json());
1504
1511
 
1505
1512
  // https://ai.google.dev/api/generate-content#UrlRetrievalMetadata
1506
1513
  export const getUrlContextMetadataSchema = () =>