@ai-sdk/google 3.0.57 → 3.0.58
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 +6 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +8 -0
- package/dist/internal/index.d.ts +8 -0
- package/dist/internal/index.js +10 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +10 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/convert-google-generative-ai-usage.ts +7 -0
- package/src/google-generative-ai-language-model.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.58",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider": "
|
|
40
|
-
"@ai-sdk/provider
|
|
39
|
+
"@ai-sdk/provider-utils": "4.0.22",
|
|
40
|
+
"@ai-sdk/provider": "3.0.8"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { LanguageModelV3Usage } from '@ai-sdk/provider';
|
|
2
2
|
|
|
3
|
+
export type GoogleGenerativeAITokenDetail = {
|
|
4
|
+
modality: string;
|
|
5
|
+
tokenCount: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
3
8
|
export type GoogleGenerativeAIUsageMetadata = {
|
|
4
9
|
promptTokenCount?: number | null;
|
|
5
10
|
candidatesTokenCount?: number | null;
|
|
@@ -7,6 +12,8 @@ export type GoogleGenerativeAIUsageMetadata = {
|
|
|
7
12
|
cachedContentTokenCount?: number | null;
|
|
8
13
|
thoughtsTokenCount?: number | null;
|
|
9
14
|
trafficType?: string | null;
|
|
15
|
+
promptTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
|
|
16
|
+
candidatesTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
|
|
10
17
|
};
|
|
11
18
|
|
|
12
19
|
export function convertGoogleGenerativeAIUsage(
|
|
@@ -1110,6 +1110,15 @@ const getSafetyRatingSchema = () =>
|
|
|
1110
1110
|
blocked: z.boolean().nullish(),
|
|
1111
1111
|
});
|
|
1112
1112
|
|
|
1113
|
+
const tokenDetailsSchema = z
|
|
1114
|
+
.array(
|
|
1115
|
+
z.object({
|
|
1116
|
+
modality: z.string(),
|
|
1117
|
+
tokenCount: z.number(),
|
|
1118
|
+
}),
|
|
1119
|
+
)
|
|
1120
|
+
.nullish();
|
|
1121
|
+
|
|
1113
1122
|
const usageSchema = z.object({
|
|
1114
1123
|
cachedContentTokenCount: z.number().nullish(),
|
|
1115
1124
|
thoughtsTokenCount: z.number().nullish(),
|
|
@@ -1118,6 +1127,9 @@ const usageSchema = z.object({
|
|
|
1118
1127
|
totalTokenCount: z.number().nullish(),
|
|
1119
1128
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
1120
1129
|
trafficType: z.string().nullish(),
|
|
1130
|
+
// https://ai.google.dev/api/generate-content#Modality
|
|
1131
|
+
promptTokensDetails: tokenDetailsSchema,
|
|
1132
|
+
candidatesTokensDetails: tokenDetailsSchema,
|
|
1121
1133
|
});
|
|
1122
1134
|
|
|
1123
1135
|
// https://ai.google.dev/api/generate-content#UrlRetrievalMetadata
|