@ai-sdk/google 4.0.114 → 4.0.117
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 +25 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -3
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +20 -9
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +1 -0
- package/package.json +3 -3
- package/src/google-json-accumulator.ts +21 -6
- package/src/google-language-model-options.ts +1 -0
- package/src/google-language-model.ts +11 -2
- package/src/google-model-catalog.ts +1 -0
- package/src/interactions/google-interactions-language-model-options.ts +1 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ type GoogleFunctionResponsePart = {
|
|
|
90
90
|
};
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/google-language-model-options.d.ts
|
|
93
|
-
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-4-argon' | 'gemini-nano-banana-2.1' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
93
|
+
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-4-argon' | 'gemini-4-carbon' | 'gemini-nano-banana-2.1' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
94
94
|
declare const googleLanguageModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
95
95
|
responseModalities?: ("TEXT" | "IMAGE" | "AUDIO")[] | undefined;
|
|
96
96
|
thinkingConfig?: {
|
|
@@ -246,9 +246,10 @@ export declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
246
246
|
toolNameMapping: import("@ai-sdk/provider-utils").ToolNameMapping;
|
|
247
247
|
}>;
|
|
248
248
|
private getArgs;
|
|
249
|
-
static convertGenerateContentResponse({ config, response, warnings, providerOptionsNames, toolNameMapping, jsonResponseToolName, initialPromptTokenCount, groundingMetadataPerRequest }: {
|
|
249
|
+
static convertGenerateContentResponse({ config, response, responseHeaders, warnings, providerOptionsNames, toolNameMapping, jsonResponseToolName, initialPromptTokenCount, groundingMetadataPerRequest }: {
|
|
250
250
|
config: GoogleLanguageModelConfig;
|
|
251
251
|
response: InferSchema<typeof responseSchema>;
|
|
252
|
+
responseHeaders?: Record<string, string>;
|
|
252
253
|
warnings: SharedV4Warning[];
|
|
253
254
|
providerOptionsNames: readonly string[];
|
|
254
255
|
toolNameMapping?: ReturnType<typeof createToolNameMapping>;
|
|
@@ -638,7 +639,7 @@ export declare const googleTools: {
|
|
|
638
639
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
639
640
|
* may diverge over time.
|
|
640
641
|
*/
|
|
641
|
-
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-4-argon' | 'gemini-nano-banana-2.1' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
642
|
+
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-4-argon' | 'gemini-4-carbon' | 'gemini-nano-banana-2.1' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
642
643
|
//#endregion
|
|
643
644
|
//#region src/interactions/google-interactions-language-model.d.ts
|
|
644
645
|
type GoogleInteractionsConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__google_prompt0.GoogleContent","_$__google_prompt0.GoogleSystemInstruction"],"sources":["../../src/google-prompt.ts","../../src/google-language-model-options.ts","../../src/google-language-model.ts","../../src/google-speech-model-options.ts","../../src/google-speech-model.ts","../../src/google-speech-input.ts","../../src/google-tools.ts","../../src/interactions/google-interactions-language-model-options.ts","../../src/interactions/google-interactions-language-model.ts","../../src/interactions/google-interactions-agent.ts","../../src/google-model-catalog.ts"],"mappings":";;;;KAcY;EACV,OAAO;IAAQ;;;KAGL;EACV;EACA,OAAO,MAAM;;cAGF,2BAAyB,EAAA;;;;GAOpC,EAAA,KAAA;;KAGU,sBAAsB,EAAE,aAAa;KAErC;EACN;EAAc;EAAmB;;EAEjC;IAAc;IAAkB;;EAChC,gBAAgB;EAChB;EACA;;EAGA;IAAgB;IAAa;IAAc;;EAC3C;;EAGA;IACE;IACA;IACA;IACA,QAAQ,MAAM;;;EAIhB;IAAY;IAAkB;;EAC9B,gBAAgB;EAChB;EACA;;EAGA;IACE;IACA;IACA;;EAEF;;EAGA;IACE;IACA;IACA;;EAEF;;EAGA;IACE;IACA;;;EAIF;IACE;IACA;;;KAII;EAEN;IAAc;IAAkB;;;EAGhC;IAAY;IAAkB;;;;;KCxFxB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__google_prompt0.GoogleContent","_$__google_prompt0.GoogleSystemInstruction"],"sources":["../../src/google-prompt.ts","../../src/google-language-model-options.ts","../../src/google-language-model.ts","../../src/google-speech-model-options.ts","../../src/google-speech-model.ts","../../src/google-speech-input.ts","../../src/google-tools.ts","../../src/interactions/google-interactions-language-model-options.ts","../../src/interactions/google-interactions-language-model.ts","../../src/interactions/google-interactions-agent.ts","../../src/google-model-catalog.ts"],"mappings":";;;;KAcY;EACV,OAAO;IAAQ;;;KAGL;EACV;EACA,OAAO,MAAM;;cAGF,2BAAyB,EAAA;;;;GAOpC,EAAA,KAAA;;KAGU,sBAAsB,EAAE,aAAa;KAErC;EACN;EAAc;EAAmB;;EAEjC;IAAc;IAAkB;;EAChC,gBAAgB;EAChB;EACA;;EAGA;IAAgB;IAAa;IAAc;;EAC3C;;EAGA;IACE;IACA;IACA;IACA,QAAQ,MAAM;;;EAIhB;IAAY;IAAkB;;EAC9B,gBAAgB;EAChB;EACA;;EAGA;IACE;IACA;IACA;;EAEF;;EAGA;IACE;IACA;IACA;;EAEF;;EAGA;IACE;IACA;;;EAIF;IACE;IACA;;;KAII;EAEN;IAAc;IAAkB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,cAAc;IACd,YAAY;IACZ;IACA;IACA;;EAEF,WAAW,YAAY;IACrB;IACA;;EAEF,UAAU,YAAY;IACpB,MAAM;IACN,WAAW;;EAEb;IACE;;;KAIC;EACH;EACA;EACA;EACA;;KAGU,2BAA2B;EACrC,UAAU;;EAEV;IAAgB,UAAU;;EAC1B;IACE,UAAU,OAAO,8BAA8B;;EAEjD;IAAiB,UAAU;;;wBA4Db,4BACd,kBACC"}
|
package/dist/internal/index.js
CHANGED
|
@@ -940,6 +940,7 @@ const googleModelCatalog = Object.fromEntries(Object.entries({
|
|
|
940
940
|
urlContext: false
|
|
941
941
|
},
|
|
942
942
|
"gemini-4-argon": standard,
|
|
943
|
+
"gemini-4-carbon": standard,
|
|
943
944
|
"gemini-3.8-flash": standard,
|
|
944
945
|
"gemini-3.7-flash": standard,
|
|
945
946
|
"gemini-3.6-flash": standard,
|
|
@@ -1264,7 +1265,7 @@ var GoogleJSONAccumulator = class {
|
|
|
1264
1265
|
const rawPath = (isArrayTerminator ? arg.jsonPath.slice(0, -2) : arg.jsonPath).replace(/^\$\./, "");
|
|
1265
1266
|
if (!rawPath || rawPath === "$") continue;
|
|
1266
1267
|
const segments = parsePath(rawPath);
|
|
1267
|
-
if (!
|
|
1268
|
+
if (!normalizeAndCheckIndexes(this.accumulatedArgs, segments)) continue;
|
|
1268
1269
|
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
1269
1270
|
if (arg.stringValue != null && existingValue !== void 0) {
|
|
1270
1271
|
const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
|
|
@@ -1490,17 +1491,26 @@ function getNestedValue(obj, segments) {
|
|
|
1490
1491
|
return current;
|
|
1491
1492
|
}
|
|
1492
1493
|
/**
|
|
1493
|
-
*
|
|
1494
|
-
* one. Arrays are streamed in order, and a
|
|
1495
|
-
* serialize one `null` per hole, so a tiny
|
|
1494
|
+
* Normalizes dotted array indexes in place and checks that every array index
|
|
1495
|
+
* is an existing element or the next one. Arrays are streamed in order, and a
|
|
1496
|
+
* sparse index would make `finalize()` serialize one `null` per hole, so a tiny
|
|
1497
|
+
* response could allocate without bound.
|
|
1496
1498
|
* A missing or `null` parent is replaced with a new array, so it starts at 0.
|
|
1497
1499
|
*
|
|
1498
1500
|
* Input: ({items:["a"]}, ["items",1]) or ({items:["a"]}, ["items",5])
|
|
1499
1501
|
* Output: true or false
|
|
1500
1502
|
*/
|
|
1501
|
-
function
|
|
1503
|
+
function normalizeAndCheckIndexes(obj, segments) {
|
|
1502
1504
|
let current = obj;
|
|
1503
|
-
for (
|
|
1505
|
+
for (let i = 0; i < segments.length; i++) {
|
|
1506
|
+
let pathSegment = segments[i];
|
|
1507
|
+
if (Array.isArray(current) && typeof pathSegment === "string") {
|
|
1508
|
+
const index = Number(pathSegment);
|
|
1509
|
+
if (Number.isInteger(index) && index >= 0 && index < 2 ** 32 - 1 && String(index) === pathSegment) {
|
|
1510
|
+
pathSegment = index;
|
|
1511
|
+
segments[i] = index;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1504
1514
|
if (typeof pathSegment === "number") {
|
|
1505
1515
|
const length = Array.isArray(current) ? current.length : current == null ? 0 : void 0;
|
|
1506
1516
|
if (length !== void 0 && pathSegment > length) return false;
|
|
@@ -1771,7 +1781,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1771
1781
|
jsonResponseToolName: jsonResponseTool?.name
|
|
1772
1782
|
};
|
|
1773
1783
|
}
|
|
1774
|
-
static convertGenerateContentResponse({ config, response, warnings, providerOptionsNames, toolNameMapping, jsonResponseToolName, initialPromptTokenCount, groundingMetadataPerRequest }) {
|
|
1784
|
+
static convertGenerateContentResponse({ config, response, responseHeaders, warnings, providerOptionsNames, toolNameMapping, jsonResponseToolName, initialPromptTokenCount, groundingMetadataPerRequest }) {
|
|
1775
1785
|
const wrapProviderMetadata = (payload) => Object.fromEntries(providerOptionsNames.map((name) => [name, payload]));
|
|
1776
1786
|
const candidate = response.candidates?.[0];
|
|
1777
1787
|
const promptBlockReason = response.promptFeedback?.blockReason;
|
|
@@ -1904,7 +1914,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1904
1914
|
safetyRatings: candidate?.safetyRatings ?? null,
|
|
1905
1915
|
usageMetadata: usageMetadata ?? null,
|
|
1906
1916
|
finishMessage: candidate?.finishMessage ?? null,
|
|
1907
|
-
serviceTier: usageMetadata?.serviceTier ?? null,
|
|
1917
|
+
serviceTier: usageMetadata?.serviceTier ?? responseHeaders?.["x-gemini-service-tier"] ?? null,
|
|
1908
1918
|
...candidate?.continuationToken != null ? { continuationToken: candidate.continuationToken } : {},
|
|
1909
1919
|
...initialPromptTokenCount != null ? { initialPromptTokenCount } : {}
|
|
1910
1920
|
}),
|
|
@@ -1954,6 +1964,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1954
1964
|
...response,
|
|
1955
1965
|
usageMetadata
|
|
1956
1966
|
},
|
|
1967
|
+
responseHeaders,
|
|
1957
1968
|
warnings,
|
|
1958
1969
|
providerOptionsNames,
|
|
1959
1970
|
toolNameMapping,
|
|
@@ -2474,7 +2485,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
2474
2485
|
safetyRatings: lastSafetyRatings,
|
|
2475
2486
|
usageMetadata: usage ?? null,
|
|
2476
2487
|
finishMessage: lastFinishMessage,
|
|
2477
|
-
serviceTier: usage?.serviceTier ?? null,
|
|
2488
|
+
serviceTier: usage?.serviceTier ?? responseHeaders?.["x-gemini-service-tier"] ?? null,
|
|
2478
2489
|
...lastContinuationToken != null && (finishReason.raw === "MAX_TOKENS" || finishReason.raw === "CONTINUATION") ? { continuationToken: lastContinuationToken } : {},
|
|
2479
2490
|
...initialPromptTokenCount != null ? { initialPromptTokenCount } : {}
|
|
2480
2491
|
})
|