@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/internal/index.mjs
CHANGED
|
@@ -1466,6 +1466,7 @@ var configurableSafetySettingCategories = [
|
|
|
1466
1466
|
"HARM_CATEGORY_HARASSMENT",
|
|
1467
1467
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1468
1468
|
];
|
|
1469
|
+
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1469
1470
|
var GoogleGenerativeAILanguageModel = class {
|
|
1470
1471
|
constructor(modelId, config) {
|
|
1471
1472
|
this.specificationVersion = "v3";
|
|
@@ -1569,6 +1570,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1569
1570
|
}
|
|
1570
1571
|
}
|
|
1571
1572
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1573
|
+
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
|
|
1574
|
+
if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
|
|
1575
|
+
warnings.push({
|
|
1576
|
+
type: "unsupported",
|
|
1577
|
+
feature: "frequencyPenalty"
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
if (isGemini25DeveloperApiModel && presencePenalty != null) {
|
|
1581
|
+
warnings.push({
|
|
1582
|
+
type: "unsupported",
|
|
1583
|
+
feature: "presencePenalty"
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1572
1586
|
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1573
1587
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
1574
1588
|
prompt,
|
|
@@ -1617,8 +1631,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1617
1631
|
temperature,
|
|
1618
1632
|
topK,
|
|
1619
1633
|
topP,
|
|
1620
|
-
frequencyPenalty,
|
|
1621
|
-
presencePenalty,
|
|
1634
|
+
frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
|
|
1635
|
+
presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
|
|
1622
1636
|
stopSequences,
|
|
1623
1637
|
seed,
|
|
1624
1638
|
// response format:
|
|
@@ -1653,7 +1667,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1653
1667
|
};
|
|
1654
1668
|
}
|
|
1655
1669
|
async doGenerate(options) {
|
|
1656
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1670
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1657
1671
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1658
1672
|
const mergedHeaders = combineHeaders(
|
|
1659
1673
|
await resolve(this.config.headers),
|
|
@@ -1675,14 +1689,17 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1675
1689
|
abortSignal: options.abortSignal,
|
|
1676
1690
|
fetch: this.config.fetch
|
|
1677
1691
|
});
|
|
1678
|
-
const candidate = response.candidates[0];
|
|
1692
|
+
const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
|
|
1693
|
+
const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
1694
|
+
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
|
|
1695
|
+
const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
|
|
1679
1696
|
const content = [];
|
|
1680
|
-
const parts = (
|
|
1697
|
+
const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
|
|
1681
1698
|
const usageMetadata = response.usageMetadata;
|
|
1682
1699
|
let lastCodeExecutionToolCallId;
|
|
1683
1700
|
let lastServerToolCallId;
|
|
1684
1701
|
for (const part of parts) {
|
|
1685
|
-
if ("executableCode" in part && ((
|
|
1702
|
+
if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
|
|
1686
1703
|
const toolCallId = this.config.generateId();
|
|
1687
1704
|
lastCodeExecutionToolCallId = toolCallId;
|
|
1688
1705
|
content.push({
|
|
@@ -1700,7 +1717,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1700
1717
|
toolName: "code_execution",
|
|
1701
1718
|
result: {
|
|
1702
1719
|
outcome: part.codeExecutionResult.outcome,
|
|
1703
|
-
output: (
|
|
1720
|
+
output: (_h = part.codeExecutionResult.output) != null ? _h : ""
|
|
1704
1721
|
}
|
|
1705
1722
|
});
|
|
1706
1723
|
} else if ("text" in part && part.text != null) {
|
|
@@ -1724,9 +1741,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1724
1741
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1725
1742
|
content.push({
|
|
1726
1743
|
type: "tool-call",
|
|
1727
|
-
toolCallId: (
|
|
1744
|
+
toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
|
|
1728
1745
|
toolName: part.functionCall.name,
|
|
1729
|
-
input: JSON.stringify((
|
|
1746
|
+
input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
|
|
1730
1747
|
providerMetadata: part.thoughtSignature ? {
|
|
1731
1748
|
[providerOptionsName]: {
|
|
1732
1749
|
thoughtSignature: part.thoughtSignature
|
|
@@ -1748,13 +1765,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1748
1765
|
} : void 0
|
|
1749
1766
|
});
|
|
1750
1767
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1751
|
-
const toolCallId = (
|
|
1768
|
+
const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
|
|
1752
1769
|
lastServerToolCallId = toolCallId;
|
|
1753
1770
|
content.push({
|
|
1754
1771
|
type: "tool-call",
|
|
1755
1772
|
toolCallId,
|
|
1756
1773
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1757
|
-
input: JSON.stringify((
|
|
1774
|
+
input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
|
|
1758
1775
|
providerExecuted: true,
|
|
1759
1776
|
dynamic: true,
|
|
1760
1777
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -1771,12 +1788,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1771
1788
|
}
|
|
1772
1789
|
});
|
|
1773
1790
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1774
|
-
const responseToolCallId = (
|
|
1791
|
+
const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
|
|
1775
1792
|
content.push({
|
|
1776
1793
|
type: "tool-result",
|
|
1777
1794
|
toolCallId: responseToolCallId,
|
|
1778
1795
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1779
|
-
result: (
|
|
1796
|
+
result: (_n = part.toolResponse.response) != null ? _n : {},
|
|
1780
1797
|
providerMetadata: part.thoughtSignature ? {
|
|
1781
1798
|
[providerOptionsName]: {
|
|
1782
1799
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -1793,42 +1810,42 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1793
1810
|
lastServerToolCallId = void 0;
|
|
1794
1811
|
}
|
|
1795
1812
|
}
|
|
1796
|
-
const sources = (
|
|
1797
|
-
groundingMetadata: candidate.groundingMetadata,
|
|
1813
|
+
const sources = (_o = extractSources({
|
|
1814
|
+
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
1798
1815
|
generateId: this.config.generateId
|
|
1799
|
-
})) != null ?
|
|
1816
|
+
})) != null ? _o : [];
|
|
1800
1817
|
for (const source of sources) {
|
|
1801
1818
|
content.push(source);
|
|
1802
1819
|
}
|
|
1803
1820
|
return {
|
|
1804
1821
|
content,
|
|
1805
1822
|
finishReason: {
|
|
1806
|
-
unified: mapGoogleGenerativeAIFinishReason({
|
|
1807
|
-
finishReason:
|
|
1823
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
|
|
1824
|
+
finishReason: rawFinishReason,
|
|
1808
1825
|
// Only count client-executed tool calls for finish reason determination.
|
|
1809
1826
|
hasToolCalls: content.some(
|
|
1810
1827
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1811
1828
|
)
|
|
1812
1829
|
}),
|
|
1813
|
-
raw:
|
|
1830
|
+
raw: rawFinishReason
|
|
1814
1831
|
},
|
|
1815
1832
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
1816
1833
|
warnings,
|
|
1817
1834
|
providerMetadata: {
|
|
1818
1835
|
[providerOptionsName]: {
|
|
1819
|
-
promptFeedback: (
|
|
1820
|
-
groundingMetadata: (
|
|
1821
|
-
urlContextMetadata: (
|
|
1822
|
-
safetyRatings: (
|
|
1836
|
+
promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
|
|
1837
|
+
groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
|
|
1838
|
+
urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
|
|
1839
|
+
safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
|
|
1823
1840
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1824
|
-
finishMessage: (
|
|
1825
|
-
serviceTier: (
|
|
1841
|
+
finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
|
|
1842
|
+
serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
|
|
1826
1843
|
}
|
|
1827
1844
|
},
|
|
1828
1845
|
request: { body: args },
|
|
1829
1846
|
response: {
|
|
1830
1847
|
// TODO timestamp, model id
|
|
1831
|
-
id: (
|
|
1848
|
+
id: (_v = response.responseId) != null ? _v : void 0,
|
|
1832
1849
|
headers: responseHeaders,
|
|
1833
1850
|
body: rawResponse
|
|
1834
1851
|
}
|
|
@@ -1905,7 +1922,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1905
1922
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1906
1923
|
},
|
|
1907
1924
|
transform(chunk, controller) {
|
|
1908
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1925
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1909
1926
|
if (options.includeRawChunks) {
|
|
1910
1927
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1911
1928
|
}
|
|
@@ -1927,6 +1944,24 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1927
1944
|
}
|
|
1928
1945
|
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1929
1946
|
if (candidate == null) {
|
|
1947
|
+
const promptBlockReason2 = (_b = value.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
1948
|
+
if (promptBlockReason2 != null) {
|
|
1949
|
+
finishReason = {
|
|
1950
|
+
unified: "content-filter",
|
|
1951
|
+
raw: promptBlockReason2
|
|
1952
|
+
};
|
|
1953
|
+
providerMetadata = {
|
|
1954
|
+
[providerOptionsName]: {
|
|
1955
|
+
promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
|
|
1956
|
+
groundingMetadata: lastGroundingMetadata,
|
|
1957
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
1958
|
+
safetyRatings: null,
|
|
1959
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1960
|
+
finishMessage: null,
|
|
1961
|
+
serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1930
1965
|
return;
|
|
1931
1966
|
}
|
|
1932
1967
|
const content = candidate.content;
|
|
@@ -1949,9 +1984,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1949
1984
|
}
|
|
1950
1985
|
}
|
|
1951
1986
|
if (content != null) {
|
|
1952
|
-
const parts = (
|
|
1987
|
+
const parts = (_e = content.parts) != null ? _e : [];
|
|
1953
1988
|
for (const part of parts) {
|
|
1954
|
-
if ("executableCode" in part && ((
|
|
1989
|
+
if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
|
|
1955
1990
|
const toolCallId = generateId2();
|
|
1956
1991
|
lastCodeExecutionToolCallId = toolCallId;
|
|
1957
1992
|
controller.enqueue({
|
|
@@ -1970,7 +2005,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1970
2005
|
toolName: "code_execution",
|
|
1971
2006
|
result: {
|
|
1972
2007
|
outcome: part.codeExecutionResult.outcome,
|
|
1973
|
-
output: (
|
|
2008
|
+
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|
|
1974
2009
|
}
|
|
1975
2010
|
});
|
|
1976
2011
|
}
|
|
@@ -2064,7 +2099,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2064
2099
|
providerMetadata: fileMeta
|
|
2065
2100
|
});
|
|
2066
2101
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2067
|
-
const toolCallId = (
|
|
2102
|
+
const toolCallId = (_h = part.toolCall.id) != null ? _h : generateId2();
|
|
2068
2103
|
lastServerToolCallId = toolCallId;
|
|
2069
2104
|
const serverMeta = {
|
|
2070
2105
|
[providerOptionsName]: {
|
|
@@ -2077,13 +2112,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2077
2112
|
type: "tool-call",
|
|
2078
2113
|
toolCallId,
|
|
2079
2114
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2080
|
-
input: JSON.stringify((
|
|
2115
|
+
input: JSON.stringify((_i = part.toolCall.args) != null ? _i : {}),
|
|
2081
2116
|
providerExecuted: true,
|
|
2082
2117
|
dynamic: true,
|
|
2083
2118
|
providerMetadata: serverMeta
|
|
2084
2119
|
});
|
|
2085
2120
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2086
|
-
const responseToolCallId = (
|
|
2121
|
+
const responseToolCallId = (_j = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _j : generateId2();
|
|
2087
2122
|
const serverMeta = {
|
|
2088
2123
|
[providerOptionsName]: {
|
|
2089
2124
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
@@ -2095,7 +2130,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2095
2130
|
type: "tool-result",
|
|
2096
2131
|
toolCallId: responseToolCallId,
|
|
2097
2132
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2098
|
-
result: (
|
|
2133
|
+
result: (_k = part.toolResponse.response) != null ? _k : {},
|
|
2099
2134
|
providerMetadata: serverMeta
|
|
2100
2135
|
});
|
|
2101
2136
|
lastServerToolCallId = void 0;
|
|
@@ -2114,7 +2149,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2114
2149
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
2115
2150
|
if (isStreamingChunk) {
|
|
2116
2151
|
if (part.functionCall.name != null) {
|
|
2117
|
-
const toolCallId = (
|
|
2152
|
+
const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId2();
|
|
2118
2153
|
const accumulator = new GoogleJSONAccumulator();
|
|
2119
2154
|
activeStreamingToolCalls.push({
|
|
2120
2155
|
toolCallId,
|
|
@@ -2162,9 +2197,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2162
2197
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
2163
2198
|
finishActiveStreamingToolCall(controller);
|
|
2164
2199
|
} else if (isCompleteCall) {
|
|
2165
|
-
const toolCallId = (
|
|
2200
|
+
const toolCallId = (_m = part.functionCall.id) != null ? _m : generateId2();
|
|
2166
2201
|
const toolName = part.functionCall.name;
|
|
2167
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((
|
|
2202
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_n = part.functionCall.args) != null ? _n : {});
|
|
2168
2203
|
controller.enqueue({
|
|
2169
2204
|
type: "tool-input-start",
|
|
2170
2205
|
id: toolCallId,
|
|
@@ -2191,7 +2226,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2191
2226
|
});
|
|
2192
2227
|
hasToolCalls = true;
|
|
2193
2228
|
} else if (isNoArgsCompleteCall) {
|
|
2194
|
-
const toolCallId = (
|
|
2229
|
+
const toolCallId = (_o = part.functionCall.id) != null ? _o : generateId2();
|
|
2195
2230
|
const toolName = part.functionCall.name;
|
|
2196
2231
|
controller.enqueue({
|
|
2197
2232
|
type: "tool-input-start",
|
|
@@ -2215,23 +2250,26 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2215
2250
|
}
|
|
2216
2251
|
}
|
|
2217
2252
|
}
|
|
2218
|
-
|
|
2253
|
+
const promptBlockReason = (_p = value.promptFeedback) == null ? void 0 : _p.blockReason;
|
|
2254
|
+
const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
|
|
2255
|
+
const rawFinishReason = (_r = (_q = candidate.finishReason) != null ? _q : promptBlockReason) != null ? _r : void 0;
|
|
2256
|
+
if (rawFinishReason != null) {
|
|
2219
2257
|
finishReason = {
|
|
2220
|
-
unified: mapGoogleGenerativeAIFinishReason({
|
|
2221
|
-
finishReason:
|
|
2258
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
|
|
2259
|
+
finishReason: rawFinishReason,
|
|
2222
2260
|
hasToolCalls
|
|
2223
2261
|
}),
|
|
2224
|
-
raw:
|
|
2262
|
+
raw: rawFinishReason
|
|
2225
2263
|
};
|
|
2226
2264
|
providerMetadata = {
|
|
2227
2265
|
[providerOptionsName]: {
|
|
2228
|
-
promptFeedback: (
|
|
2266
|
+
promptFeedback: (_s = value.promptFeedback) != null ? _s : null,
|
|
2229
2267
|
groundingMetadata: lastGroundingMetadata,
|
|
2230
2268
|
urlContextMetadata: lastUrlContextMetadata,
|
|
2231
|
-
safetyRatings: (
|
|
2269
|
+
safetyRatings: (_t = candidate.safetyRatings) != null ? _t : null,
|
|
2232
2270
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2233
|
-
finishMessage: (
|
|
2234
|
-
serviceTier: (
|
|
2271
|
+
finishMessage: (_u = candidate.finishMessage) != null ? _u : null,
|
|
2272
|
+
serviceTier: (_v = usage == null ? void 0 : usage.serviceTier) != null ? _v : null
|
|
2235
2273
|
}
|
|
2236
2274
|
};
|
|
2237
2275
|
}
|
|
@@ -2480,21 +2518,24 @@ var tokenDetailsSchema = z3.array(
|
|
|
2480
2518
|
z3.object({
|
|
2481
2519
|
modality: z3.string(),
|
|
2482
2520
|
tokenCount: z3.number()
|
|
2483
|
-
})
|
|
2521
|
+
}).catchall(z3.json())
|
|
2484
2522
|
).nullish();
|
|
2485
2523
|
var usageSchema = z3.object({
|
|
2486
2524
|
cachedContentTokenCount: z3.number().nullish(),
|
|
2487
2525
|
thoughtsTokenCount: z3.number().nullish(),
|
|
2488
2526
|
promptTokenCount: z3.number().nullish(),
|
|
2489
2527
|
candidatesTokenCount: z3.number().nullish(),
|
|
2528
|
+
toolUsePromptTokenCount: z3.number().nullish(),
|
|
2490
2529
|
totalTokenCount: z3.number().nullish(),
|
|
2491
2530
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2492
2531
|
trafficType: z3.string().nullish(),
|
|
2493
2532
|
serviceTier: z3.string().nullish(),
|
|
2494
2533
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2495
2534
|
promptTokensDetails: tokenDetailsSchema,
|
|
2496
|
-
|
|
2497
|
-
|
|
2535
|
+
cacheTokensDetails: tokenDetailsSchema,
|
|
2536
|
+
candidatesTokensDetails: tokenDetailsSchema,
|
|
2537
|
+
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
2538
|
+
}).catchall(z3.json());
|
|
2498
2539
|
var getUrlContextMetadataSchema = () => z3.object({
|
|
2499
2540
|
urlMetadata: z3.array(
|
|
2500
2541
|
z3.object({
|
|
@@ -2516,7 +2557,7 @@ var responseSchema = lazySchema3(
|
|
|
2516
2557
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2517
2558
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2518
2559
|
})
|
|
2519
|
-
),
|
|
2560
|
+
).nullish(),
|
|
2520
2561
|
usageMetadata: usageSchema.nullish(),
|
|
2521
2562
|
promptFeedback: z3.object({
|
|
2522
2563
|
blockReason: z3.string().nullish(),
|