@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/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "2.0.
|
|
10
|
+
var VERSION = true ? "2.0.73" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -456,6 +456,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
456
456
|
case "tool-call": {
|
|
457
457
|
return {
|
|
458
458
|
functionCall: {
|
|
459
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
459
460
|
name: part.toolName,
|
|
460
461
|
args: part.input
|
|
461
462
|
},
|
|
@@ -481,6 +482,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
481
482
|
} else {
|
|
482
483
|
parts.push({
|
|
483
484
|
functionResponse: {
|
|
485
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
484
486
|
name: part.toolName,
|
|
485
487
|
response: {
|
|
486
488
|
name: part.toolName,
|
|
@@ -532,6 +534,7 @@ function appendToolResultParts({
|
|
|
532
534
|
const responseText = responseTextParts.length > 0 ? responseTextParts.join("\n") : "Tool executed successfully.";
|
|
533
535
|
parts.push({
|
|
534
536
|
functionResponse: {
|
|
537
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
535
538
|
name: part.toolName,
|
|
536
539
|
response: {
|
|
537
540
|
name: part.toolName,
|
|
@@ -551,6 +554,7 @@ function appendLegacyToolResultParts({
|
|
|
551
554
|
case "text":
|
|
552
555
|
parts.push({
|
|
553
556
|
functionResponse: {
|
|
557
|
+
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
554
558
|
name: part.toolName,
|
|
555
559
|
response: {
|
|
556
560
|
name: part.toolName,
|
|
@@ -1070,7 +1074,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1070
1074
|
};
|
|
1071
1075
|
}
|
|
1072
1076
|
async doGenerate(options) {
|
|
1073
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1077
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1074
1078
|
const { args, warnings } = await this.getArgs(options);
|
|
1075
1079
|
const body = JSON.stringify(args);
|
|
1076
1080
|
const mergedHeaders = combineHeaders2(
|
|
@@ -1140,7 +1144,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1140
1144
|
} else if ("functionCall" in part) {
|
|
1141
1145
|
content.push({
|
|
1142
1146
|
type: "tool-call",
|
|
1143
|
-
toolCallId: this.config.generateId(),
|
|
1147
|
+
toolCallId: (_d = part.functionCall.id) != null ? _d : this.config.generateId(),
|
|
1144
1148
|
toolName: part.functionCall.name,
|
|
1145
1149
|
input: JSON.stringify(part.functionCall.args),
|
|
1146
1150
|
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
@@ -1153,10 +1157,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1153
1157
|
});
|
|
1154
1158
|
}
|
|
1155
1159
|
}
|
|
1156
|
-
const sources = (
|
|
1160
|
+
const sources = (_e = extractSources({
|
|
1157
1161
|
groundingMetadata: candidate.groundingMetadata,
|
|
1158
1162
|
generateId: this.config.generateId
|
|
1159
|
-
})) != null ?
|
|
1163
|
+
})) != null ? _e : [];
|
|
1160
1164
|
for (const source of sources) {
|
|
1161
1165
|
content.push(source);
|
|
1162
1166
|
}
|
|
@@ -1167,20 +1171,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1167
1171
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
1168
1172
|
}),
|
|
1169
1173
|
usage: {
|
|
1170
|
-
inputTokens: (
|
|
1171
|
-
outputTokens: (
|
|
1172
|
-
totalTokens: (
|
|
1173
|
-
reasoningTokens: (
|
|
1174
|
-
cachedInputTokens: (
|
|
1174
|
+
inputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _f : void 0,
|
|
1175
|
+
outputTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _g : void 0,
|
|
1176
|
+
totalTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _h : void 0,
|
|
1177
|
+
reasoningTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _i : void 0,
|
|
1178
|
+
cachedInputTokens: (_j = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _j : void 0
|
|
1175
1179
|
},
|
|
1176
1180
|
warnings,
|
|
1177
1181
|
providerMetadata: {
|
|
1178
1182
|
google: {
|
|
1179
|
-
promptFeedback: (
|
|
1180
|
-
groundingMetadata: (
|
|
1181
|
-
urlContextMetadata: (
|
|
1182
|
-
safetyRatings: (
|
|
1183
|
-
serviceTier: (
|
|
1183
|
+
promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
|
|
1184
|
+
groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
|
|
1185
|
+
urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
|
|
1186
|
+
safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
|
|
1187
|
+
serviceTier: (_o = response.serviceTier) != null ? _o : null
|
|
1184
1188
|
}
|
|
1185
1189
|
},
|
|
1186
1190
|
request: { body },
|
|
@@ -1460,13 +1464,16 @@ function getToolCallsFromParts({
|
|
|
1460
1464
|
const functionCallParts = parts == null ? void 0 : parts.filter(
|
|
1461
1465
|
(part) => "functionCall" in part
|
|
1462
1466
|
);
|
|
1463
|
-
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) =>
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1467
|
+
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => {
|
|
1468
|
+
var _a;
|
|
1469
|
+
return {
|
|
1470
|
+
type: "tool-call",
|
|
1471
|
+
toolCallId: (_a = part.functionCall.id) != null ? _a : generateId3(),
|
|
1472
|
+
toolName: part.functionCall.name,
|
|
1473
|
+
args: JSON.stringify(part.functionCall.args),
|
|
1474
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
1475
|
+
};
|
|
1476
|
+
});
|
|
1470
1477
|
}
|
|
1471
1478
|
function extractSources({
|
|
1472
1479
|
groundingMetadata,
|
|
@@ -1617,6 +1624,7 @@ var getContentSchema = () => z5.object({
|
|
|
1617
1624
|
// note: order matters since text can be fully empty
|
|
1618
1625
|
z5.object({
|
|
1619
1626
|
functionCall: z5.object({
|
|
1627
|
+
id: z5.string().nullish(),
|
|
1620
1628
|
name: z5.string(),
|
|
1621
1629
|
args: z5.unknown()
|
|
1622
1630
|
}),
|