@ai-sdk/google 2.0.72 → 2.0.74
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +30 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +29 -21
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +29 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { Resolvable, FetchFunction, InferValidator } from '@ai-sdk/provider-util
|
|
|
3
3
|
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | '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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
6
|
+
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | '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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
7
7
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
9
9
|
provider: string;
|
|
@@ -88,6 +88,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
88
88
|
functionCall: {
|
|
89
89
|
name: string;
|
|
90
90
|
args: unknown;
|
|
91
|
+
id?: string | null | undefined;
|
|
91
92
|
};
|
|
92
93
|
thoughtSignature?: string | null | undefined;
|
|
93
94
|
} | {
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Resolvable, FetchFunction, InferValidator } from '@ai-sdk/provider-util
|
|
|
3
3
|
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | '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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
6
|
+
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | '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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
7
7
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
9
9
|
provider: string;
|
|
@@ -88,6 +88,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
88
88
|
functionCall: {
|
|
89
89
|
name: string;
|
|
90
90
|
args: unknown;
|
|
91
|
+
id?: string | null | undefined;
|
|
91
92
|
};
|
|
92
93
|
thoughtSignature?: string | null | undefined;
|
|
93
94
|
} | {
|
package/dist/internal/index.js
CHANGED
|
@@ -241,6 +241,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
241
241
|
case "tool-call": {
|
|
242
242
|
return {
|
|
243
243
|
functionCall: {
|
|
244
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
244
245
|
name: part.toolName,
|
|
245
246
|
args: part.input
|
|
246
247
|
},
|
|
@@ -266,6 +267,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
266
267
|
} else {
|
|
267
268
|
parts.push({
|
|
268
269
|
functionResponse: {
|
|
270
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
269
271
|
name: part.toolName,
|
|
270
272
|
response: {
|
|
271
273
|
name: part.toolName,
|
|
@@ -317,6 +319,7 @@ function appendToolResultParts({
|
|
|
317
319
|
const responseText = responseTextParts.length > 0 ? responseTextParts.join("\n") : "Tool executed successfully.";
|
|
318
320
|
parts.push({
|
|
319
321
|
functionResponse: {
|
|
322
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
320
323
|
name: part.toolName,
|
|
321
324
|
response: {
|
|
322
325
|
name: part.toolName,
|
|
@@ -336,6 +339,7 @@ function appendLegacyToolResultParts({
|
|
|
336
339
|
case "text":
|
|
337
340
|
parts.push({
|
|
338
341
|
functionResponse: {
|
|
342
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
339
343
|
name: part.toolName,
|
|
340
344
|
response: {
|
|
341
345
|
name: part.toolName,
|
|
@@ -869,7 +873,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
869
873
|
};
|
|
870
874
|
}
|
|
871
875
|
async doGenerate(options) {
|
|
872
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
876
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
873
877
|
const { args, warnings } = await this.getArgs(options);
|
|
874
878
|
const body = JSON.stringify(args);
|
|
875
879
|
const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
|
|
@@ -939,7 +943,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
939
943
|
} else if ("functionCall" in part) {
|
|
940
944
|
content.push({
|
|
941
945
|
type: "tool-call",
|
|
942
|
-
toolCallId: this.config.generateId(),
|
|
946
|
+
toolCallId: (_d = part.functionCall.id) != null ? _d : this.config.generateId(),
|
|
943
947
|
toolName: part.functionCall.name,
|
|
944
948
|
input: JSON.stringify(part.functionCall.args),
|
|
945
949
|
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
@@ -952,10 +956,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
952
956
|
});
|
|
953
957
|
}
|
|
954
958
|
}
|
|
955
|
-
const sources = (
|
|
959
|
+
const sources = (_e = extractSources({
|
|
956
960
|
groundingMetadata: candidate.groundingMetadata,
|
|
957
961
|
generateId: this.config.generateId
|
|
958
|
-
})) != null ?
|
|
962
|
+
})) != null ? _e : [];
|
|
959
963
|
for (const source of sources) {
|
|
960
964
|
content.push(source);
|
|
961
965
|
}
|
|
@@ -966,20 +970,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
966
970
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
967
971
|
}),
|
|
968
972
|
usage: {
|
|
969
|
-
inputTokens: (
|
|
970
|
-
outputTokens: (
|
|
971
|
-
totalTokens: (
|
|
972
|
-
reasoningTokens: (
|
|
973
|
-
cachedInputTokens: (
|
|
973
|
+
inputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _f : void 0,
|
|
974
|
+
outputTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _g : void 0,
|
|
975
|
+
totalTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _h : void 0,
|
|
976
|
+
reasoningTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _i : void 0,
|
|
977
|
+
cachedInputTokens: (_j = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _j : void 0
|
|
974
978
|
},
|
|
975
979
|
warnings,
|
|
976
980
|
providerMetadata: {
|
|
977
981
|
google: {
|
|
978
|
-
promptFeedback: (
|
|
979
|
-
groundingMetadata: (
|
|
980
|
-
urlContextMetadata: (
|
|
981
|
-
safetyRatings: (
|
|
982
|
-
serviceTier: (
|
|
982
|
+
promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
|
|
983
|
+
groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
|
|
984
|
+
urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
|
|
985
|
+
safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
|
|
986
|
+
serviceTier: (_o = response.serviceTier) != null ? _o : null
|
|
983
987
|
}
|
|
984
988
|
},
|
|
985
989
|
request: { body },
|
|
@@ -1259,13 +1263,16 @@ function getToolCallsFromParts({
|
|
|
1259
1263
|
const functionCallParts = parts == null ? void 0 : parts.filter(
|
|
1260
1264
|
(part) => "functionCall" in part
|
|
1261
1265
|
);
|
|
1262
|
-
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) =>
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1266
|
+
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => {
|
|
1267
|
+
var _a;
|
|
1268
|
+
return {
|
|
1269
|
+
type: "tool-call",
|
|
1270
|
+
toolCallId: (_a = part.functionCall.id) != null ? _a : generateId2(),
|
|
1271
|
+
toolName: part.functionCall.name,
|
|
1272
|
+
args: JSON.stringify(part.functionCall.args),
|
|
1273
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
1274
|
+
};
|
|
1275
|
+
});
|
|
1269
1276
|
}
|
|
1270
1277
|
function extractSources({
|
|
1271
1278
|
groundingMetadata,
|
|
@@ -1416,6 +1423,7 @@ var getContentSchema = () => import_v43.z.object({
|
|
|
1416
1423
|
// note: order matters since text can be fully empty
|
|
1417
1424
|
import_v43.z.object({
|
|
1418
1425
|
functionCall: import_v43.z.object({
|
|
1426
|
+
id: import_v43.z.string().nullish(),
|
|
1419
1427
|
name: import_v43.z.string(),
|
|
1420
1428
|
args: import_v43.z.unknown()
|
|
1421
1429
|
}),
|