@ai-sdk/google 2.0.66 → 2.0.68
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 +12 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -4
- 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 +22 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -3
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 2.0.68
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4c10694: fix(google): fix `serviceTier` to be correctly formatted for Vertex API
|
|
8
|
+
|
|
9
|
+
## 2.0.67
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 84bbfee: feat(provider/google): preserve per-modality token details in usage data
|
|
14
|
+
|
|
3
15
|
## 2.0.66
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -141,6 +141,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
141
141
|
candidatesTokenCount?: number | null | undefined;
|
|
142
142
|
totalTokenCount?: number | null | undefined;
|
|
143
143
|
trafficType?: string | null | undefined;
|
|
144
|
+
promptTokensDetails?: {
|
|
145
|
+
modality: string;
|
|
146
|
+
tokenCount: number;
|
|
147
|
+
}[] | null | undefined;
|
|
148
|
+
candidatesTokensDetails?: {
|
|
149
|
+
modality: string;
|
|
150
|
+
tokenCount: number;
|
|
151
|
+
}[] | null | undefined;
|
|
144
152
|
} | null | undefined;
|
|
145
153
|
promptFeedback?: {
|
|
146
154
|
blockReason?: string | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -141,6 +141,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
141
141
|
candidatesTokenCount?: number | null | undefined;
|
|
142
142
|
totalTokenCount?: number | null | undefined;
|
|
143
143
|
trafficType?: string | null | undefined;
|
|
144
|
+
promptTokensDetails?: {
|
|
145
|
+
modality: string;
|
|
146
|
+
tokenCount: number;
|
|
147
|
+
}[] | null | undefined;
|
|
148
|
+
candidatesTokensDetails?: {
|
|
149
|
+
modality: string;
|
|
150
|
+
tokenCount: number;
|
|
151
|
+
}[] | null | undefined;
|
|
144
152
|
} | null | undefined;
|
|
145
153
|
promptFeedback?: {
|
|
146
154
|
blockReason?: string | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.68" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -703,6 +703,11 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
703
703
|
})
|
|
704
704
|
)
|
|
705
705
|
);
|
|
706
|
+
var VertexServiceTierMap = {
|
|
707
|
+
standard: "SERVICE_TIER_STANDARD",
|
|
708
|
+
flex: "SERVICE_TIER_FLEX",
|
|
709
|
+
priority: "SERVICE_TIER_PRIORITY"
|
|
710
|
+
};
|
|
706
711
|
|
|
707
712
|
// src/google-prepare-tools.ts
|
|
708
713
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -967,14 +972,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
967
972
|
providerOptions,
|
|
968
973
|
schema: googleGenerativeAIProviderOptions
|
|
969
974
|
});
|
|
975
|
+
const isVertexProvider = this.config.provider.startsWith("google.vertex.");
|
|
970
976
|
if ((tools == null ? void 0 : tools.some(
|
|
971
977
|
(tool) => tool.type === "provider-defined" && tool.id === "google.vertex_rag_store"
|
|
972
|
-
)) && !
|
|
978
|
+
)) && !isVertexProvider) {
|
|
973
979
|
warnings.push({
|
|
974
980
|
type: "other",
|
|
975
981
|
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
|
|
976
982
|
});
|
|
977
983
|
}
|
|
984
|
+
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
985
|
+
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
986
|
+
sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
|
|
987
|
+
}
|
|
978
988
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
979
989
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
980
990
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
@@ -1031,7 +1041,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1031
1041
|
} : googleToolConfig,
|
|
1032
1042
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1033
1043
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1034
|
-
serviceTier:
|
|
1044
|
+
serviceTier: sanitizedServiceTier
|
|
1035
1045
|
},
|
|
1036
1046
|
warnings: [...warnings, ...toolWarnings]
|
|
1037
1047
|
};
|
|
@@ -1619,6 +1629,12 @@ var getSafetyRatingSchema = () => import_v45.z.object({
|
|
|
1619
1629
|
severityScore: import_v45.z.number().nullish(),
|
|
1620
1630
|
blocked: import_v45.z.boolean().nullish()
|
|
1621
1631
|
});
|
|
1632
|
+
var tokenDetailsSchema = import_v45.z.array(
|
|
1633
|
+
import_v45.z.object({
|
|
1634
|
+
modality: import_v45.z.string(),
|
|
1635
|
+
tokenCount: import_v45.z.number()
|
|
1636
|
+
})
|
|
1637
|
+
).nullish();
|
|
1622
1638
|
var usageSchema = import_v45.z.object({
|
|
1623
1639
|
cachedContentTokenCount: import_v45.z.number().nullish(),
|
|
1624
1640
|
thoughtsTokenCount: import_v45.z.number().nullish(),
|
|
@@ -1626,7 +1642,10 @@ var usageSchema = import_v45.z.object({
|
|
|
1626
1642
|
candidatesTokenCount: import_v45.z.number().nullish(),
|
|
1627
1643
|
totalTokenCount: import_v45.z.number().nullish(),
|
|
1628
1644
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
1629
|
-
trafficType: import_v45.z.string().nullish()
|
|
1645
|
+
trafficType: import_v45.z.string().nullish(),
|
|
1646
|
+
// https://ai.google.dev/api/generate-content#Modality
|
|
1647
|
+
promptTokensDetails: tokenDetailsSchema,
|
|
1648
|
+
candidatesTokensDetails: tokenDetailsSchema
|
|
1630
1649
|
});
|
|
1631
1650
|
var getUrlContextMetadataSchema = () => import_v45.z.object({
|
|
1632
1651
|
urlMetadata: import_v45.z.array(
|