@ai-sdk/google 2.0.71 → 2.0.73
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 +15 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- 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 +1 -0
- package/dist/internal/index.d.ts +1 -0
- 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 +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 2.0.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f081ba8: fix(provider/google): support `functionCall.id` when returned by Gemini API and provide matching `functionResponse.id`
|
|
8
|
+
|
|
9
|
+
## 2.0.72
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 783fa6c: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
14
|
+
- Updated dependencies [783fa6c]
|
|
15
|
+
- @ai-sdk/provider-utils@3.0.25
|
|
16
|
+
- @ai-sdk/provider@2.0.3
|
|
17
|
+
|
|
3
18
|
## 2.0.71
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.73" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -450,6 +450,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
450
450
|
case "tool-call": {
|
|
451
451
|
return {
|
|
452
452
|
functionCall: {
|
|
453
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
453
454
|
name: part.toolName,
|
|
454
455
|
args: part.input
|
|
455
456
|
},
|
|
@@ -475,6 +476,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
475
476
|
} else {
|
|
476
477
|
parts.push({
|
|
477
478
|
functionResponse: {
|
|
479
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
478
480
|
name: part.toolName,
|
|
479
481
|
response: {
|
|
480
482
|
name: part.toolName,
|
|
@@ -526,6 +528,7 @@ function appendToolResultParts({
|
|
|
526
528
|
const responseText = responseTextParts.length > 0 ? responseTextParts.join("\n") : "Tool executed successfully.";
|
|
527
529
|
parts.push({
|
|
528
530
|
functionResponse: {
|
|
531
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
529
532
|
name: part.toolName,
|
|
530
533
|
response: {
|
|
531
534
|
name: part.toolName,
|
|
@@ -545,6 +548,7 @@ function appendLegacyToolResultParts({
|
|
|
545
548
|
case "text":
|
|
546
549
|
parts.push({
|
|
547
550
|
functionResponse: {
|
|
551
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
548
552
|
name: part.toolName,
|
|
549
553
|
response: {
|
|
550
554
|
name: part.toolName,
|
|
@@ -1059,7 +1063,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1059
1063
|
};
|
|
1060
1064
|
}
|
|
1061
1065
|
async doGenerate(options) {
|
|
1062
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1066
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1063
1067
|
const { args, warnings } = await this.getArgs(options);
|
|
1064
1068
|
const body = JSON.stringify(args);
|
|
1065
1069
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
|
@@ -1129,7 +1133,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1129
1133
|
} else if ("functionCall" in part) {
|
|
1130
1134
|
content.push({
|
|
1131
1135
|
type: "tool-call",
|
|
1132
|
-
toolCallId: this.config.generateId(),
|
|
1136
|
+
toolCallId: (_d = part.functionCall.id) != null ? _d : this.config.generateId(),
|
|
1133
1137
|
toolName: part.functionCall.name,
|
|
1134
1138
|
input: JSON.stringify(part.functionCall.args),
|
|
1135
1139
|
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
@@ -1142,10 +1146,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1142
1146
|
});
|
|
1143
1147
|
}
|
|
1144
1148
|
}
|
|
1145
|
-
const sources = (
|
|
1149
|
+
const sources = (_e = extractSources({
|
|
1146
1150
|
groundingMetadata: candidate.groundingMetadata,
|
|
1147
1151
|
generateId: this.config.generateId
|
|
1148
|
-
})) != null ?
|
|
1152
|
+
})) != null ? _e : [];
|
|
1149
1153
|
for (const source of sources) {
|
|
1150
1154
|
content.push(source);
|
|
1151
1155
|
}
|
|
@@ -1156,20 +1160,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1156
1160
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
1157
1161
|
}),
|
|
1158
1162
|
usage: {
|
|
1159
|
-
inputTokens: (
|
|
1160
|
-
outputTokens: (
|
|
1161
|
-
totalTokens: (
|
|
1162
|
-
reasoningTokens: (
|
|
1163
|
-
cachedInputTokens: (
|
|
1163
|
+
inputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _f : void 0,
|
|
1164
|
+
outputTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _g : void 0,
|
|
1165
|
+
totalTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _h : void 0,
|
|
1166
|
+
reasoningTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _i : void 0,
|
|
1167
|
+
cachedInputTokens: (_j = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _j : void 0
|
|
1164
1168
|
},
|
|
1165
1169
|
warnings,
|
|
1166
1170
|
providerMetadata: {
|
|
1167
1171
|
google: {
|
|
1168
|
-
promptFeedback: (
|
|
1169
|
-
groundingMetadata: (
|
|
1170
|
-
urlContextMetadata: (
|
|
1171
|
-
safetyRatings: (
|
|
1172
|
-
serviceTier: (
|
|
1172
|
+
promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
|
|
1173
|
+
groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
|
|
1174
|
+
urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
|
|
1175
|
+
safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
|
|
1176
|
+
serviceTier: (_o = response.serviceTier) != null ? _o : null
|
|
1173
1177
|
}
|
|
1174
1178
|
},
|
|
1175
1179
|
request: { body },
|
|
@@ -1449,13 +1453,16 @@ function getToolCallsFromParts({
|
|
|
1449
1453
|
const functionCallParts = parts == null ? void 0 : parts.filter(
|
|
1450
1454
|
(part) => "functionCall" in part
|
|
1451
1455
|
);
|
|
1452
|
-
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) =>
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1456
|
+
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => {
|
|
1457
|
+
var _a;
|
|
1458
|
+
return {
|
|
1459
|
+
type: "tool-call",
|
|
1460
|
+
toolCallId: (_a = part.functionCall.id) != null ? _a : generateId3(),
|
|
1461
|
+
toolName: part.functionCall.name,
|
|
1462
|
+
args: JSON.stringify(part.functionCall.args),
|
|
1463
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
1464
|
+
};
|
|
1465
|
+
});
|
|
1459
1466
|
}
|
|
1460
1467
|
function extractSources({
|
|
1461
1468
|
groundingMetadata,
|
|
@@ -1606,6 +1613,7 @@ var getContentSchema = () => import_v45.z.object({
|
|
|
1606
1613
|
// note: order matters since text can be fully empty
|
|
1607
1614
|
import_v45.z.object({
|
|
1608
1615
|
functionCall: import_v45.z.object({
|
|
1616
|
+
id: import_v45.z.string().nullish(),
|
|
1609
1617
|
name: import_v45.z.string(),
|
|
1610
1618
|
args: import_v45.z.unknown()
|
|
1611
1619
|
}),
|