@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/CHANGELOG.md +8 -0
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +14 -0
- package/dist/internal/index.d.ts +14 -0
- package/dist/internal/index.js +6 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +6 -3
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/convert-google-generative-ai-usage.ts +3 -0
- package/src/google-generative-ai-language-model.ts +24 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
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.
|
|
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
|
|
1485
|
-
|
|
1486
|
-
|
|
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
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
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 = () =>
|