@ai-sdk/google 4.0.54 → 4.0.56
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 +13 -0
- package/dist/index.d.ts +21 -6
- package/dist/index.js +82 -43
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +21 -6
- package/dist/internal/index.js +81 -42
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/convert-google-usage.ts +3 -0
- package/src/google-language-model.ts +119 -53
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.56
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3ad9da9: Preserve complete Google Generative Language usage metadata in raw usage results.
|
|
8
|
+
- e9bc618: Omit unsupported frequency and presence penalties from Gemini 2.5 requests and return warnings instead.
|
|
9
|
+
|
|
10
|
+
## 4.0.55
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 56d492f: Surface prompt-level Google safety blocks without candidates as content-filter results with prompt feedback metadata.
|
|
15
|
+
|
|
3
16
|
## 4.0.54
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,8 @@ declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
56
56
|
type GoogleLanguageModelOptions = InferSchema<typeof googleLanguageModelOptions>;
|
|
57
57
|
|
|
58
58
|
declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
59
|
-
|
|
59
|
+
responseId?: string | null | undefined;
|
|
60
|
+
candidates?: {
|
|
60
61
|
content?: Record<string, never> | {
|
|
61
62
|
parts?: ({
|
|
62
63
|
functionCall: {
|
|
@@ -172,21 +173,34 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
172
173
|
urlRetrievalStatus: string;
|
|
173
174
|
}[] | null | undefined;
|
|
174
175
|
} | null | undefined;
|
|
175
|
-
}[];
|
|
176
|
-
responseId?: string | null | undefined;
|
|
176
|
+
}[] | null | undefined;
|
|
177
177
|
usageMetadata?: {
|
|
178
|
+
[x: string]: unknown;
|
|
178
179
|
cachedContentTokenCount?: number | null | undefined;
|
|
179
180
|
thoughtsTokenCount?: number | null | undefined;
|
|
180
181
|
promptTokenCount?: number | null | undefined;
|
|
181
182
|
candidatesTokenCount?: number | null | undefined;
|
|
183
|
+
toolUsePromptTokenCount?: number | null | undefined;
|
|
182
184
|
totalTokenCount?: number | null | undefined;
|
|
183
185
|
trafficType?: string | null | undefined;
|
|
184
186
|
serviceTier?: string | null | undefined;
|
|
185
187
|
promptTokensDetails?: {
|
|
188
|
+
[x: string]: unknown;
|
|
189
|
+
modality: string;
|
|
190
|
+
tokenCount: number;
|
|
191
|
+
}[] | null | undefined;
|
|
192
|
+
cacheTokensDetails?: {
|
|
193
|
+
[x: string]: unknown;
|
|
186
194
|
modality: string;
|
|
187
195
|
tokenCount: number;
|
|
188
196
|
}[] | null | undefined;
|
|
189
197
|
candidatesTokensDetails?: {
|
|
198
|
+
[x: string]: unknown;
|
|
199
|
+
modality: string;
|
|
200
|
+
tokenCount: number;
|
|
201
|
+
}[] | null | undefined;
|
|
202
|
+
toolUsePromptTokensDetails?: {
|
|
203
|
+
[x: string]: unknown;
|
|
190
204
|
modality: string;
|
|
191
205
|
tokenCount: number;
|
|
192
206
|
}[] | null | undefined;
|
|
@@ -203,9 +217,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
203
217
|
}[] | null | undefined;
|
|
204
218
|
} | null | undefined;
|
|
205
219
|
}>;
|
|
206
|
-
type
|
|
207
|
-
type
|
|
208
|
-
type
|
|
220
|
+
type CandidateSchema = NonNullable<InferSchema<typeof responseSchema>['candidates']>[number];
|
|
221
|
+
type GroundingMetadataSchema = NonNullable<CandidateSchema['groundingMetadata']>;
|
|
222
|
+
type UrlContextMetadataSchema = NonNullable<CandidateSchema['urlContextMetadata']>;
|
|
223
|
+
type SafetyRatingSchema = NonNullable<CandidateSchema['safetyRatings']>[number];
|
|
209
224
|
type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
|
|
210
225
|
type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
|
|
211
226
|
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.56" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -1806,6 +1806,7 @@ var configurableSafetySettingCategories = [
|
|
|
1806
1806
|
"HARM_CATEGORY_HARASSMENT",
|
|
1807
1807
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1808
1808
|
];
|
|
1809
|
+
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1809
1810
|
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1810
1811
|
constructor(modelId, config) {
|
|
1811
1812
|
this.specificationVersion = "v4";
|
|
@@ -1923,6 +1924,19 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1923
1924
|
}
|
|
1924
1925
|
}
|
|
1925
1926
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1927
|
+
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
|
|
1928
|
+
if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
|
|
1929
|
+
warnings.push({
|
|
1930
|
+
type: "unsupported",
|
|
1931
|
+
feature: "frequencyPenalty"
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
if (isGemini25DeveloperApiModel && presencePenalty != null) {
|
|
1935
|
+
warnings.push({
|
|
1936
|
+
type: "unsupported",
|
|
1937
|
+
feature: "presencePenalty"
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1926
1940
|
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1927
1941
|
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1928
1942
|
isGemmaModel,
|
|
@@ -1974,8 +1988,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1974
1988
|
temperature,
|
|
1975
1989
|
topK,
|
|
1976
1990
|
topP,
|
|
1977
|
-
frequencyPenalty,
|
|
1978
|
-
presencePenalty,
|
|
1991
|
+
frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
|
|
1992
|
+
presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
|
|
1979
1993
|
stopSequences,
|
|
1980
1994
|
seed,
|
|
1981
1995
|
// response format:
|
|
@@ -2014,18 +2028,21 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2014
2028
|
warnings,
|
|
2015
2029
|
providerOptionsNames
|
|
2016
2030
|
}) {
|
|
2017
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2031
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2018
2032
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
2019
2033
|
providerOptionsNames.map((name) => [name, payload])
|
|
2020
2034
|
);
|
|
2021
|
-
const candidate = response.candidates[0];
|
|
2035
|
+
const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
|
|
2036
|
+
const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2037
|
+
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
|
|
2038
|
+
const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
|
|
2022
2039
|
const content = [];
|
|
2023
|
-
const parts = (
|
|
2040
|
+
const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
|
|
2024
2041
|
const usageMetadata = response.usageMetadata;
|
|
2025
2042
|
let lastCodeExecutionToolCallId;
|
|
2026
2043
|
let lastServerToolCallId;
|
|
2027
2044
|
for (const part of parts) {
|
|
2028
|
-
if ("executableCode" in part && ((
|
|
2045
|
+
if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
|
|
2029
2046
|
const toolCallId = this.config.generateId();
|
|
2030
2047
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2031
2048
|
content.push({
|
|
@@ -2043,7 +2060,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2043
2060
|
toolName: "code_execution",
|
|
2044
2061
|
result: {
|
|
2045
2062
|
outcome: part.codeExecutionResult.outcome,
|
|
2046
|
-
output: (
|
|
2063
|
+
output: (_h = part.codeExecutionResult.output) != null ? _h : ""
|
|
2047
2064
|
}
|
|
2048
2065
|
});
|
|
2049
2066
|
} else if ("text" in part && part.text != null) {
|
|
@@ -2067,7 +2084,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2067
2084
|
type: "tool-call",
|
|
2068
2085
|
toolCallId: part.functionCall.id || this.config.generateId(),
|
|
2069
2086
|
toolName: part.functionCall.name,
|
|
2070
|
-
input: JSON.stringify((
|
|
2087
|
+
input: JSON.stringify((_i = part.functionCall.args) != null ? _i : {}),
|
|
2071
2088
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
2072
2089
|
thoughtSignature: part.thoughtSignature
|
|
2073
2090
|
}) : void 0
|
|
@@ -2090,7 +2107,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2090
2107
|
type: "tool-call",
|
|
2091
2108
|
toolCallId,
|
|
2092
2109
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2093
|
-
input: JSON.stringify((
|
|
2110
|
+
input: JSON.stringify((_j = part.toolCall.args) != null ? _j : {}),
|
|
2094
2111
|
providerExecuted: true,
|
|
2095
2112
|
dynamic: true,
|
|
2096
2113
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -2108,7 +2125,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2108
2125
|
type: "tool-result",
|
|
2109
2126
|
toolCallId: responseToolCallId,
|
|
2110
2127
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2111
|
-
result: (
|
|
2128
|
+
result: (_k = part.toolResponse.response) != null ? _k : {},
|
|
2112
2129
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
2113
2130
|
thoughtSignature: part.thoughtSignature,
|
|
2114
2131
|
serverToolCallId: responseToolCallId,
|
|
@@ -2121,39 +2138,39 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2121
2138
|
lastServerToolCallId = void 0;
|
|
2122
2139
|
}
|
|
2123
2140
|
}
|
|
2124
|
-
const sources = (
|
|
2125
|
-
groundingMetadata: candidate.groundingMetadata,
|
|
2141
|
+
const sources = (_l = extractSources({
|
|
2142
|
+
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
2126
2143
|
generateId: this.config.generateId
|
|
2127
|
-
})) != null ?
|
|
2144
|
+
})) != null ? _l : [];
|
|
2128
2145
|
for (const source of sources) {
|
|
2129
2146
|
content.push(source);
|
|
2130
2147
|
}
|
|
2131
2148
|
return {
|
|
2132
2149
|
content,
|
|
2133
2150
|
finishReason: {
|
|
2134
|
-
unified: mapGoogleFinishReason({
|
|
2135
|
-
finishReason:
|
|
2151
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleFinishReason({
|
|
2152
|
+
finishReason: rawFinishReason,
|
|
2136
2153
|
// Only count client-executed tool calls for finish reason determination.
|
|
2137
2154
|
hasToolCalls: content.some(
|
|
2138
2155
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
2139
2156
|
)
|
|
2140
2157
|
}),
|
|
2141
|
-
raw:
|
|
2158
|
+
raw: rawFinishReason
|
|
2142
2159
|
},
|
|
2143
2160
|
usage: convertGoogleUsage(usageMetadata),
|
|
2144
2161
|
warnings,
|
|
2145
2162
|
providerMetadata: wrapProviderMetadata({
|
|
2146
|
-
promptFeedback: (
|
|
2147
|
-
groundingMetadata: (
|
|
2148
|
-
urlContextMetadata: (
|
|
2149
|
-
safetyRatings: (
|
|
2163
|
+
promptFeedback: (_m = response.promptFeedback) != null ? _m : null,
|
|
2164
|
+
groundingMetadata: (_n = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _n : null,
|
|
2165
|
+
urlContextMetadata: (_o = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _o : null,
|
|
2166
|
+
safetyRatings: (_p = candidate == null ? void 0 : candidate.safetyRatings) != null ? _p : null,
|
|
2150
2167
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2151
|
-
finishMessage: (
|
|
2152
|
-
serviceTier: (
|
|
2168
|
+
finishMessage: (_q = candidate == null ? void 0 : candidate.finishMessage) != null ? _q : null,
|
|
2169
|
+
serviceTier: (_r = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _r : null
|
|
2153
2170
|
}),
|
|
2154
2171
|
response: {
|
|
2155
2172
|
// TODO timestamp, model id
|
|
2156
|
-
id: (
|
|
2173
|
+
id: (_s = response.responseId) != null ? _s : void 0
|
|
2157
2174
|
}
|
|
2158
2175
|
};
|
|
2159
2176
|
}
|
|
@@ -2268,7 +2285,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2268
2285
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2269
2286
|
},
|
|
2270
2287
|
transform(chunk, controller) {
|
|
2271
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2288
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2272
2289
|
if (options.includeRawChunks) {
|
|
2273
2290
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2274
2291
|
}
|
|
@@ -2290,6 +2307,22 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2290
2307
|
}
|
|
2291
2308
|
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
2292
2309
|
if (candidate == null) {
|
|
2310
|
+
const promptBlockReason2 = (_b = value.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2311
|
+
if (promptBlockReason2 != null) {
|
|
2312
|
+
finishReason = {
|
|
2313
|
+
unified: "content-filter",
|
|
2314
|
+
raw: promptBlockReason2
|
|
2315
|
+
};
|
|
2316
|
+
providerMetadata = wrapProviderMetadata({
|
|
2317
|
+
promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
|
|
2318
|
+
groundingMetadata: lastGroundingMetadata,
|
|
2319
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
2320
|
+
safetyRatings: null,
|
|
2321
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2322
|
+
finishMessage: null,
|
|
2323
|
+
serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2293
2326
|
return;
|
|
2294
2327
|
}
|
|
2295
2328
|
const content = candidate.content;
|
|
@@ -2312,9 +2345,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2312
2345
|
}
|
|
2313
2346
|
}
|
|
2314
2347
|
if (content != null) {
|
|
2315
|
-
const parts = (
|
|
2348
|
+
const parts = (_e = content.parts) != null ? _e : [];
|
|
2316
2349
|
for (const part of parts) {
|
|
2317
|
-
if ("executableCode" in part && ((
|
|
2350
|
+
if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
|
|
2318
2351
|
const toolCallId = generateId4();
|
|
2319
2352
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2320
2353
|
controller.enqueue({
|
|
@@ -2333,7 +2366,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2333
2366
|
toolName: "code_execution",
|
|
2334
2367
|
result: {
|
|
2335
2368
|
outcome: part.codeExecutionResult.outcome,
|
|
2336
|
-
output: (
|
|
2369
|
+
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|
|
2337
2370
|
}
|
|
2338
2371
|
});
|
|
2339
2372
|
}
|
|
@@ -2433,7 +2466,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2433
2466
|
type: "tool-call",
|
|
2434
2467
|
toolCallId,
|
|
2435
2468
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2436
|
-
input: JSON.stringify((
|
|
2469
|
+
input: JSON.stringify((_h = part.toolCall.args) != null ? _h : {}),
|
|
2437
2470
|
providerExecuted: true,
|
|
2438
2471
|
dynamic: true,
|
|
2439
2472
|
providerMetadata: serverMeta
|
|
@@ -2449,7 +2482,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2449
2482
|
type: "tool-result",
|
|
2450
2483
|
toolCallId: responseToolCallId,
|
|
2451
2484
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2452
|
-
result: (
|
|
2485
|
+
result: (_i = part.toolResponse.response) != null ? _i : {},
|
|
2453
2486
|
providerMetadata: serverMeta
|
|
2454
2487
|
});
|
|
2455
2488
|
lastServerToolCallId = void 0;
|
|
@@ -2516,7 +2549,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2516
2549
|
} else if (isCompleteCall) {
|
|
2517
2550
|
const toolCallId = part.functionCall.id || generateId4();
|
|
2518
2551
|
const toolName = part.functionCall.name;
|
|
2519
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((
|
|
2552
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_j = part.functionCall.args) != null ? _j : {});
|
|
2520
2553
|
controller.enqueue({
|
|
2521
2554
|
type: "tool-input-start",
|
|
2522
2555
|
id: toolCallId,
|
|
@@ -2567,22 +2600,25 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2567
2600
|
}
|
|
2568
2601
|
}
|
|
2569
2602
|
}
|
|
2570
|
-
|
|
2603
|
+
const promptBlockReason = (_k = value.promptFeedback) == null ? void 0 : _k.blockReason;
|
|
2604
|
+
const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
|
|
2605
|
+
const rawFinishReason = (_m = (_l = candidate.finishReason) != null ? _l : promptBlockReason) != null ? _m : void 0;
|
|
2606
|
+
if (rawFinishReason != null) {
|
|
2571
2607
|
finishReason = {
|
|
2572
|
-
unified: mapGoogleFinishReason({
|
|
2573
|
-
finishReason:
|
|
2608
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleFinishReason({
|
|
2609
|
+
finishReason: rawFinishReason,
|
|
2574
2610
|
hasToolCalls
|
|
2575
2611
|
}),
|
|
2576
|
-
raw:
|
|
2612
|
+
raw: rawFinishReason
|
|
2577
2613
|
};
|
|
2578
2614
|
providerMetadata = wrapProviderMetadata({
|
|
2579
|
-
promptFeedback: (
|
|
2615
|
+
promptFeedback: (_n = value.promptFeedback) != null ? _n : null,
|
|
2580
2616
|
groundingMetadata: lastGroundingMetadata,
|
|
2581
2617
|
urlContextMetadata: lastUrlContextMetadata,
|
|
2582
|
-
safetyRatings: (
|
|
2618
|
+
safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
|
|
2583
2619
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2584
|
-
finishMessage: (
|
|
2585
|
-
serviceTier: (
|
|
2620
|
+
finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
|
|
2621
|
+
serviceTier: (_q = usage == null ? void 0 : usage.serviceTier) != null ? _q : null
|
|
2586
2622
|
});
|
|
2587
2623
|
}
|
|
2588
2624
|
},
|
|
@@ -2914,21 +2950,24 @@ var tokenDetailsSchema = z5.array(
|
|
|
2914
2950
|
z5.object({
|
|
2915
2951
|
modality: z5.string(),
|
|
2916
2952
|
tokenCount: z5.number()
|
|
2917
|
-
})
|
|
2953
|
+
}).loose()
|
|
2918
2954
|
).nullish();
|
|
2919
2955
|
var usageSchema = z5.object({
|
|
2920
2956
|
cachedContentTokenCount: z5.number().nullish(),
|
|
2921
2957
|
thoughtsTokenCount: z5.number().nullish(),
|
|
2922
2958
|
promptTokenCount: z5.number().nullish(),
|
|
2923
2959
|
candidatesTokenCount: z5.number().nullish(),
|
|
2960
|
+
toolUsePromptTokenCount: z5.number().nullish(),
|
|
2924
2961
|
totalTokenCount: z5.number().nullish(),
|
|
2925
2962
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2926
2963
|
trafficType: z5.string().nullish(),
|
|
2927
2964
|
serviceTier: z5.string().nullish(),
|
|
2928
2965
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2929
2966
|
promptTokensDetails: tokenDetailsSchema,
|
|
2930
|
-
|
|
2931
|
-
|
|
2967
|
+
cacheTokensDetails: tokenDetailsSchema,
|
|
2968
|
+
candidatesTokensDetails: tokenDetailsSchema,
|
|
2969
|
+
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
2970
|
+
}).loose();
|
|
2932
2971
|
var getUrlContextMetadataSchema = () => z5.object({
|
|
2933
2972
|
urlMetadata: z5.array(
|
|
2934
2973
|
z5.object({
|
|
@@ -2950,7 +2989,7 @@ var responseSchema = lazySchema5(
|
|
|
2950
2989
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2951
2990
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2952
2991
|
})
|
|
2953
|
-
),
|
|
2992
|
+
).nullish(),
|
|
2954
2993
|
usageMetadata: usageSchema.nullish(),
|
|
2955
2994
|
promptFeedback: z5.object({
|
|
2956
2995
|
blockReason: z5.string().nullish(),
|