@ai-sdk/google 3.0.116 → 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 +20 -0
- package/dist/index.d.mts +22 -7
- package/dist/index.d.ts +22 -7
- package/dist/index.js +92 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -51
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +21 -6
- package/dist/internal/index.d.ts +21 -6
- package/dist/internal/index.js +91 -50
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +91 -50
- 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 +123 -56
package/dist/index.mjs
CHANGED
|
@@ -224,7 +224,7 @@ import {
|
|
|
224
224
|
} from "@ai-sdk/provider-utils";
|
|
225
225
|
|
|
226
226
|
// src/version.ts
|
|
227
|
-
var VERSION = true ? "3.0.
|
|
227
|
+
var VERSION = true ? "3.0.119" : "0.0.0-test";
|
|
228
228
|
|
|
229
229
|
// src/google-generative-ai-embedding-model.ts
|
|
230
230
|
import {
|
|
@@ -1876,6 +1876,7 @@ var configurableSafetySettingCategories = [
|
|
|
1876
1876
|
"HARM_CATEGORY_HARASSMENT",
|
|
1877
1877
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1878
1878
|
];
|
|
1879
|
+
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1879
1880
|
var GoogleGenerativeAILanguageModel = class {
|
|
1880
1881
|
constructor(modelId, config) {
|
|
1881
1882
|
this.specificationVersion = "v3";
|
|
@@ -1979,6 +1980,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1979
1980
|
}
|
|
1980
1981
|
}
|
|
1981
1982
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1983
|
+
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
|
|
1984
|
+
if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
|
|
1985
|
+
warnings.push({
|
|
1986
|
+
type: "unsupported",
|
|
1987
|
+
feature: "frequencyPenalty"
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
if (isGemini25DeveloperApiModel && presencePenalty != null) {
|
|
1991
|
+
warnings.push({
|
|
1992
|
+
type: "unsupported",
|
|
1993
|
+
feature: "presencePenalty"
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1982
1996
|
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1983
1997
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
1984
1998
|
prompt,
|
|
@@ -2027,8 +2041,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2027
2041
|
temperature,
|
|
2028
2042
|
topK,
|
|
2029
2043
|
topP,
|
|
2030
|
-
frequencyPenalty,
|
|
2031
|
-
presencePenalty,
|
|
2044
|
+
frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
|
|
2045
|
+
presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
|
|
2032
2046
|
stopSequences,
|
|
2033
2047
|
seed,
|
|
2034
2048
|
// response format:
|
|
@@ -2063,7 +2077,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2063
2077
|
};
|
|
2064
2078
|
}
|
|
2065
2079
|
async doGenerate(options) {
|
|
2066
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2080
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2067
2081
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
2068
2082
|
const mergedHeaders = combineHeaders3(
|
|
2069
2083
|
await resolve3(this.config.headers),
|
|
@@ -2085,14 +2099,17 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2085
2099
|
abortSignal: options.abortSignal,
|
|
2086
2100
|
fetch: this.config.fetch
|
|
2087
2101
|
});
|
|
2088
|
-
const candidate = response.candidates[0];
|
|
2102
|
+
const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
|
|
2103
|
+
const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2104
|
+
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
|
|
2105
|
+
const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
|
|
2089
2106
|
const content = [];
|
|
2090
|
-
const parts = (
|
|
2107
|
+
const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
|
|
2091
2108
|
const usageMetadata = response.usageMetadata;
|
|
2092
2109
|
let lastCodeExecutionToolCallId;
|
|
2093
2110
|
let lastServerToolCallId;
|
|
2094
2111
|
for (const part of parts) {
|
|
2095
|
-
if ("executableCode" in part && ((
|
|
2112
|
+
if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
|
|
2096
2113
|
const toolCallId = this.config.generateId();
|
|
2097
2114
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2098
2115
|
content.push({
|
|
@@ -2110,7 +2127,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2110
2127
|
toolName: "code_execution",
|
|
2111
2128
|
result: {
|
|
2112
2129
|
outcome: part.codeExecutionResult.outcome,
|
|
2113
|
-
output: (
|
|
2130
|
+
output: (_h = part.codeExecutionResult.output) != null ? _h : ""
|
|
2114
2131
|
}
|
|
2115
2132
|
});
|
|
2116
2133
|
} else if ("text" in part && part.text != null) {
|
|
@@ -2134,9 +2151,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2134
2151
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
2135
2152
|
content.push({
|
|
2136
2153
|
type: "tool-call",
|
|
2137
|
-
toolCallId: (
|
|
2154
|
+
toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
|
|
2138
2155
|
toolName: part.functionCall.name,
|
|
2139
|
-
input: JSON.stringify((
|
|
2156
|
+
input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
|
|
2140
2157
|
providerMetadata: part.thoughtSignature ? {
|
|
2141
2158
|
[providerOptionsName]: {
|
|
2142
2159
|
thoughtSignature: part.thoughtSignature
|
|
@@ -2158,13 +2175,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2158
2175
|
} : void 0
|
|
2159
2176
|
});
|
|
2160
2177
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2161
|
-
const toolCallId = (
|
|
2178
|
+
const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
|
|
2162
2179
|
lastServerToolCallId = toolCallId;
|
|
2163
2180
|
content.push({
|
|
2164
2181
|
type: "tool-call",
|
|
2165
2182
|
toolCallId,
|
|
2166
2183
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2167
|
-
input: JSON.stringify((
|
|
2184
|
+
input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
|
|
2168
2185
|
providerExecuted: true,
|
|
2169
2186
|
dynamic: true,
|
|
2170
2187
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -2181,12 +2198,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2181
2198
|
}
|
|
2182
2199
|
});
|
|
2183
2200
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2184
|
-
const responseToolCallId = (
|
|
2201
|
+
const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
|
|
2185
2202
|
content.push({
|
|
2186
2203
|
type: "tool-result",
|
|
2187
2204
|
toolCallId: responseToolCallId,
|
|
2188
2205
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2189
|
-
result: (
|
|
2206
|
+
result: (_n = part.toolResponse.response) != null ? _n : {},
|
|
2190
2207
|
providerMetadata: part.thoughtSignature ? {
|
|
2191
2208
|
[providerOptionsName]: {
|
|
2192
2209
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -2203,42 +2220,42 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2203
2220
|
lastServerToolCallId = void 0;
|
|
2204
2221
|
}
|
|
2205
2222
|
}
|
|
2206
|
-
const sources = (
|
|
2207
|
-
groundingMetadata: candidate.groundingMetadata,
|
|
2223
|
+
const sources = (_o = extractSources({
|
|
2224
|
+
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
2208
2225
|
generateId: this.config.generateId
|
|
2209
|
-
})) != null ?
|
|
2226
|
+
})) != null ? _o : [];
|
|
2210
2227
|
for (const source of sources) {
|
|
2211
2228
|
content.push(source);
|
|
2212
2229
|
}
|
|
2213
2230
|
return {
|
|
2214
2231
|
content,
|
|
2215
2232
|
finishReason: {
|
|
2216
|
-
unified: mapGoogleGenerativeAIFinishReason({
|
|
2217
|
-
finishReason:
|
|
2233
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
|
|
2234
|
+
finishReason: rawFinishReason,
|
|
2218
2235
|
// Only count client-executed tool calls for finish reason determination.
|
|
2219
2236
|
hasToolCalls: content.some(
|
|
2220
2237
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
2221
2238
|
)
|
|
2222
2239
|
}),
|
|
2223
|
-
raw:
|
|
2240
|
+
raw: rawFinishReason
|
|
2224
2241
|
},
|
|
2225
2242
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
2226
2243
|
warnings,
|
|
2227
2244
|
providerMetadata: {
|
|
2228
2245
|
[providerOptionsName]: {
|
|
2229
|
-
promptFeedback: (
|
|
2230
|
-
groundingMetadata: (
|
|
2231
|
-
urlContextMetadata: (
|
|
2232
|
-
safetyRatings: (
|
|
2246
|
+
promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
|
|
2247
|
+
groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
|
|
2248
|
+
urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
|
|
2249
|
+
safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
|
|
2233
2250
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2234
|
-
finishMessage: (
|
|
2235
|
-
serviceTier: (
|
|
2251
|
+
finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
|
|
2252
|
+
serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
|
|
2236
2253
|
}
|
|
2237
2254
|
},
|
|
2238
2255
|
request: { body: args },
|
|
2239
2256
|
response: {
|
|
2240
2257
|
// TODO timestamp, model id
|
|
2241
|
-
id: (
|
|
2258
|
+
id: (_v = response.responseId) != null ? _v : void 0,
|
|
2242
2259
|
headers: responseHeaders,
|
|
2243
2260
|
body: rawResponse
|
|
2244
2261
|
}
|
|
@@ -2315,7 +2332,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2315
2332
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2316
2333
|
},
|
|
2317
2334
|
transform(chunk, controller) {
|
|
2318
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2335
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2319
2336
|
if (options.includeRawChunks) {
|
|
2320
2337
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2321
2338
|
}
|
|
@@ -2337,6 +2354,24 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2337
2354
|
}
|
|
2338
2355
|
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
2339
2356
|
if (candidate == null) {
|
|
2357
|
+
const promptBlockReason2 = (_b = value.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2358
|
+
if (promptBlockReason2 != null) {
|
|
2359
|
+
finishReason = {
|
|
2360
|
+
unified: "content-filter",
|
|
2361
|
+
raw: promptBlockReason2
|
|
2362
|
+
};
|
|
2363
|
+
providerMetadata = {
|
|
2364
|
+
[providerOptionsName]: {
|
|
2365
|
+
promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
|
|
2366
|
+
groundingMetadata: lastGroundingMetadata,
|
|
2367
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
2368
|
+
safetyRatings: null,
|
|
2369
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2370
|
+
finishMessage: null,
|
|
2371
|
+
serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2340
2375
|
return;
|
|
2341
2376
|
}
|
|
2342
2377
|
const content = candidate.content;
|
|
@@ -2359,9 +2394,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2359
2394
|
}
|
|
2360
2395
|
}
|
|
2361
2396
|
if (content != null) {
|
|
2362
|
-
const parts = (
|
|
2397
|
+
const parts = (_e = content.parts) != null ? _e : [];
|
|
2363
2398
|
for (const part of parts) {
|
|
2364
|
-
if ("executableCode" in part && ((
|
|
2399
|
+
if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
|
|
2365
2400
|
const toolCallId = generateId3();
|
|
2366
2401
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2367
2402
|
controller.enqueue({
|
|
@@ -2380,7 +2415,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2380
2415
|
toolName: "code_execution",
|
|
2381
2416
|
result: {
|
|
2382
2417
|
outcome: part.codeExecutionResult.outcome,
|
|
2383
|
-
output: (
|
|
2418
|
+
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|
|
2384
2419
|
}
|
|
2385
2420
|
});
|
|
2386
2421
|
}
|
|
@@ -2474,7 +2509,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2474
2509
|
providerMetadata: fileMeta
|
|
2475
2510
|
});
|
|
2476
2511
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2477
|
-
const toolCallId = (
|
|
2512
|
+
const toolCallId = (_h = part.toolCall.id) != null ? _h : generateId3();
|
|
2478
2513
|
lastServerToolCallId = toolCallId;
|
|
2479
2514
|
const serverMeta = {
|
|
2480
2515
|
[providerOptionsName]: {
|
|
@@ -2487,13 +2522,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2487
2522
|
type: "tool-call",
|
|
2488
2523
|
toolCallId,
|
|
2489
2524
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2490
|
-
input: JSON.stringify((
|
|
2525
|
+
input: JSON.stringify((_i = part.toolCall.args) != null ? _i : {}),
|
|
2491
2526
|
providerExecuted: true,
|
|
2492
2527
|
dynamic: true,
|
|
2493
2528
|
providerMetadata: serverMeta
|
|
2494
2529
|
});
|
|
2495
2530
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2496
|
-
const responseToolCallId = (
|
|
2531
|
+
const responseToolCallId = (_j = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _j : generateId3();
|
|
2497
2532
|
const serverMeta = {
|
|
2498
2533
|
[providerOptionsName]: {
|
|
2499
2534
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
@@ -2505,7 +2540,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2505
2540
|
type: "tool-result",
|
|
2506
2541
|
toolCallId: responseToolCallId,
|
|
2507
2542
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2508
|
-
result: (
|
|
2543
|
+
result: (_k = part.toolResponse.response) != null ? _k : {},
|
|
2509
2544
|
providerMetadata: serverMeta
|
|
2510
2545
|
});
|
|
2511
2546
|
lastServerToolCallId = void 0;
|
|
@@ -2524,7 +2559,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2524
2559
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
2525
2560
|
if (isStreamingChunk) {
|
|
2526
2561
|
if (part.functionCall.name != null) {
|
|
2527
|
-
const toolCallId = (
|
|
2562
|
+
const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId3();
|
|
2528
2563
|
const accumulator = new GoogleJSONAccumulator();
|
|
2529
2564
|
activeStreamingToolCalls.push({
|
|
2530
2565
|
toolCallId,
|
|
@@ -2572,9 +2607,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2572
2607
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
2573
2608
|
finishActiveStreamingToolCall(controller);
|
|
2574
2609
|
} else if (isCompleteCall) {
|
|
2575
|
-
const toolCallId = (
|
|
2610
|
+
const toolCallId = (_m = part.functionCall.id) != null ? _m : generateId3();
|
|
2576
2611
|
const toolName = part.functionCall.name;
|
|
2577
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((
|
|
2612
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_n = part.functionCall.args) != null ? _n : {});
|
|
2578
2613
|
controller.enqueue({
|
|
2579
2614
|
type: "tool-input-start",
|
|
2580
2615
|
id: toolCallId,
|
|
@@ -2601,7 +2636,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2601
2636
|
});
|
|
2602
2637
|
hasToolCalls = true;
|
|
2603
2638
|
} else if (isNoArgsCompleteCall) {
|
|
2604
|
-
const toolCallId = (
|
|
2639
|
+
const toolCallId = (_o = part.functionCall.id) != null ? _o : generateId3();
|
|
2605
2640
|
const toolName = part.functionCall.name;
|
|
2606
2641
|
controller.enqueue({
|
|
2607
2642
|
type: "tool-input-start",
|
|
@@ -2625,23 +2660,26 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2625
2660
|
}
|
|
2626
2661
|
}
|
|
2627
2662
|
}
|
|
2628
|
-
|
|
2663
|
+
const promptBlockReason = (_p = value.promptFeedback) == null ? void 0 : _p.blockReason;
|
|
2664
|
+
const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
|
|
2665
|
+
const rawFinishReason = (_r = (_q = candidate.finishReason) != null ? _q : promptBlockReason) != null ? _r : void 0;
|
|
2666
|
+
if (rawFinishReason != null) {
|
|
2629
2667
|
finishReason = {
|
|
2630
|
-
unified: mapGoogleGenerativeAIFinishReason({
|
|
2631
|
-
finishReason:
|
|
2668
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
|
|
2669
|
+
finishReason: rawFinishReason,
|
|
2632
2670
|
hasToolCalls
|
|
2633
2671
|
}),
|
|
2634
|
-
raw:
|
|
2672
|
+
raw: rawFinishReason
|
|
2635
2673
|
};
|
|
2636
2674
|
providerMetadata = {
|
|
2637
2675
|
[providerOptionsName]: {
|
|
2638
|
-
promptFeedback: (
|
|
2676
|
+
promptFeedback: (_s = value.promptFeedback) != null ? _s : null,
|
|
2639
2677
|
groundingMetadata: lastGroundingMetadata,
|
|
2640
2678
|
urlContextMetadata: lastUrlContextMetadata,
|
|
2641
|
-
safetyRatings: (
|
|
2679
|
+
safetyRatings: (_t = candidate.safetyRatings) != null ? _t : null,
|
|
2642
2680
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2643
|
-
finishMessage: (
|
|
2644
|
-
serviceTier: (
|
|
2681
|
+
finishMessage: (_u = candidate.finishMessage) != null ? _u : null,
|
|
2682
|
+
serviceTier: (_v = usage == null ? void 0 : usage.serviceTier) != null ? _v : null
|
|
2645
2683
|
}
|
|
2646
2684
|
};
|
|
2647
2685
|
}
|
|
@@ -2890,21 +2928,24 @@ var tokenDetailsSchema = z7.array(
|
|
|
2890
2928
|
z7.object({
|
|
2891
2929
|
modality: z7.string(),
|
|
2892
2930
|
tokenCount: z7.number()
|
|
2893
|
-
})
|
|
2931
|
+
}).catchall(z7.json())
|
|
2894
2932
|
).nullish();
|
|
2895
2933
|
var usageSchema = z7.object({
|
|
2896
2934
|
cachedContentTokenCount: z7.number().nullish(),
|
|
2897
2935
|
thoughtsTokenCount: z7.number().nullish(),
|
|
2898
2936
|
promptTokenCount: z7.number().nullish(),
|
|
2899
2937
|
candidatesTokenCount: z7.number().nullish(),
|
|
2938
|
+
toolUsePromptTokenCount: z7.number().nullish(),
|
|
2900
2939
|
totalTokenCount: z7.number().nullish(),
|
|
2901
2940
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2902
2941
|
trafficType: z7.string().nullish(),
|
|
2903
2942
|
serviceTier: z7.string().nullish(),
|
|
2904
2943
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2905
2944
|
promptTokensDetails: tokenDetailsSchema,
|
|
2906
|
-
|
|
2907
|
-
|
|
2945
|
+
cacheTokensDetails: tokenDetailsSchema,
|
|
2946
|
+
candidatesTokensDetails: tokenDetailsSchema,
|
|
2947
|
+
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
2948
|
+
}).catchall(z7.json());
|
|
2908
2949
|
var getUrlContextMetadataSchema = () => z7.object({
|
|
2909
2950
|
urlMetadata: z7.array(
|
|
2910
2951
|
z7.object({
|
|
@@ -2926,7 +2967,7 @@ var responseSchema = lazySchema5(
|
|
|
2926
2967
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2927
2968
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2928
2969
|
})
|
|
2929
|
-
),
|
|
2970
|
+
).nullish(),
|
|
2930
2971
|
usageMetadata: usageSchema.nullish(),
|
|
2931
2972
|
promptFeedback: z7.object({
|
|
2932
2973
|
blockReason: z7.string().nullish(),
|