@ai-sdk/google 3.0.22 → 3.0.24
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 +14 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -49
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +54 -48
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +54 -48
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +50 -52
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3b3e32f: fix(google): handle thoughtSignature on empty-text parts in doGenerate and doStream
|
|
8
|
+
|
|
9
|
+
## 3.0.23
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ba98c56: fix(google): make `codeExecutionResult.output` optional in response schema
|
|
14
|
+
|
|
15
|
+
Gemini 3 Flash omits the `output` field in `codeExecutionResult` when code execution produces no text output (e.g., only saves files). The Zod response schema now accepts a missing `output` field and defaults it to an empty string.
|
|
16
|
+
|
|
3
17
|
## 3.0.22
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -64,7 +64,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
64
64
|
} | null | undefined;
|
|
65
65
|
codeExecutionResult?: {
|
|
66
66
|
outcome: string;
|
|
67
|
-
output
|
|
67
|
+
output?: string | null | undefined;
|
|
68
68
|
} | null | undefined;
|
|
69
69
|
text?: string | null | undefined;
|
|
70
70
|
thought?: boolean | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
64
64
|
} | null | undefined;
|
|
65
65
|
codeExecutionResult?: {
|
|
66
66
|
outcome: string;
|
|
67
|
-
output
|
|
67
|
+
output?: string | null | undefined;
|
|
68
68
|
} | null | undefined;
|
|
69
69
|
text?: string | null | undefined;
|
|
70
70
|
thought?: boolean | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
30
30
|
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.24" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -1002,7 +1002,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1002
1002
|
};
|
|
1003
1003
|
}
|
|
1004
1004
|
async doGenerate(options) {
|
|
1005
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1005
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1006
1006
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1007
1007
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
|
1008
1008
|
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
@@ -1047,20 +1047,28 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1047
1047
|
toolName: "code_execution",
|
|
1048
1048
|
result: {
|
|
1049
1049
|
outcome: part.codeExecutionResult.outcome,
|
|
1050
|
-
output: part.codeExecutionResult.output
|
|
1050
|
+
output: (_d = part.codeExecutionResult.output) != null ? _d : ""
|
|
1051
1051
|
}
|
|
1052
1052
|
});
|
|
1053
1053
|
lastCodeExecutionToolCallId = void 0;
|
|
1054
|
-
} else if ("text" in part && part.text != null
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1054
|
+
} else if ("text" in part && part.text != null) {
|
|
1055
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? {
|
|
1056
|
+
[providerOptionsName]: {
|
|
1057
|
+
thoughtSignature: part.thoughtSignature
|
|
1058
|
+
}
|
|
1059
|
+
} : void 0;
|
|
1060
|
+
if (part.text.length === 0) {
|
|
1061
|
+
if (thoughtSignatureMetadata != null && content.length > 0) {
|
|
1062
|
+
const lastContent = content[content.length - 1];
|
|
1063
|
+
lastContent.providerMetadata = thoughtSignatureMetadata;
|
|
1064
|
+
}
|
|
1065
|
+
} else {
|
|
1066
|
+
content.push({
|
|
1067
|
+
type: part.thought === true ? "reasoning" : "text",
|
|
1068
|
+
text: part.text,
|
|
1069
|
+
providerMetadata: thoughtSignatureMetadata
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1064
1072
|
} else if ("functionCall" in part) {
|
|
1065
1073
|
content.push({
|
|
1066
1074
|
type: "tool-call",
|
|
@@ -1086,10 +1094,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1086
1094
|
});
|
|
1087
1095
|
}
|
|
1088
1096
|
}
|
|
1089
|
-
const sources = (
|
|
1097
|
+
const sources = (_e = extractSources({
|
|
1090
1098
|
groundingMetadata: candidate.groundingMetadata,
|
|
1091
1099
|
generateId: this.config.generateId
|
|
1092
|
-
})) != null ?
|
|
1100
|
+
})) != null ? _e : [];
|
|
1093
1101
|
for (const source of sources) {
|
|
1094
1102
|
content.push(source);
|
|
1095
1103
|
}
|
|
@@ -1103,16 +1111,16 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1103
1111
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1104
1112
|
)
|
|
1105
1113
|
}),
|
|
1106
|
-
raw: (
|
|
1114
|
+
raw: (_f = candidate.finishReason) != null ? _f : void 0
|
|
1107
1115
|
},
|
|
1108
1116
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
1109
1117
|
warnings,
|
|
1110
1118
|
providerMetadata: {
|
|
1111
1119
|
[providerOptionsName]: {
|
|
1112
|
-
promptFeedback: (
|
|
1113
|
-
groundingMetadata: (
|
|
1114
|
-
urlContextMetadata: (
|
|
1115
|
-
safetyRatings: (
|
|
1120
|
+
promptFeedback: (_g = response.promptFeedback) != null ? _g : null,
|
|
1121
|
+
groundingMetadata: (_h = candidate.groundingMetadata) != null ? _h : null,
|
|
1122
|
+
urlContextMetadata: (_i = candidate.urlContextMetadata) != null ? _i : null,
|
|
1123
|
+
safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
|
|
1116
1124
|
usageMetadata: usageMetadata != null ? usageMetadata : null
|
|
1117
1125
|
}
|
|
1118
1126
|
},
|
|
@@ -1161,7 +1169,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1161
1169
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1162
1170
|
},
|
|
1163
1171
|
transform(chunk, controller) {
|
|
1164
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1172
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1165
1173
|
if (options.includeRawChunks) {
|
|
1166
1174
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1167
1175
|
}
|
|
@@ -1213,13 +1221,27 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1213
1221
|
toolName: "code_execution",
|
|
1214
1222
|
result: {
|
|
1215
1223
|
outcome: part.codeExecutionResult.outcome,
|
|
1216
|
-
output: part.codeExecutionResult.output
|
|
1224
|
+
output: (_d = part.codeExecutionResult.output) != null ? _d : ""
|
|
1217
1225
|
}
|
|
1218
1226
|
});
|
|
1219
1227
|
lastCodeExecutionToolCallId = void 0;
|
|
1220
1228
|
}
|
|
1221
|
-
} else if ("text" in part && part.text != null
|
|
1222
|
-
|
|
1229
|
+
} else if ("text" in part && part.text != null) {
|
|
1230
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? {
|
|
1231
|
+
[providerOptionsName]: {
|
|
1232
|
+
thoughtSignature: part.thoughtSignature
|
|
1233
|
+
}
|
|
1234
|
+
} : void 0;
|
|
1235
|
+
if (part.text.length === 0) {
|
|
1236
|
+
if (thoughtSignatureMetadata != null && currentTextBlockId !== null) {
|
|
1237
|
+
controller.enqueue({
|
|
1238
|
+
type: "text-delta",
|
|
1239
|
+
id: currentTextBlockId,
|
|
1240
|
+
delta: "",
|
|
1241
|
+
providerMetadata: thoughtSignatureMetadata
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
} else if (part.thought === true) {
|
|
1223
1245
|
if (currentTextBlockId !== null) {
|
|
1224
1246
|
controller.enqueue({
|
|
1225
1247
|
type: "text-end",
|
|
@@ -1232,22 +1254,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1232
1254
|
controller.enqueue({
|
|
1233
1255
|
type: "reasoning-start",
|
|
1234
1256
|
id: currentReasoningBlockId,
|
|
1235
|
-
providerMetadata:
|
|
1236
|
-
[providerOptionsName]: {
|
|
1237
|
-
thoughtSignature: part.thoughtSignature
|
|
1238
|
-
}
|
|
1239
|
-
} : void 0
|
|
1257
|
+
providerMetadata: thoughtSignatureMetadata
|
|
1240
1258
|
});
|
|
1241
1259
|
}
|
|
1242
1260
|
controller.enqueue({
|
|
1243
1261
|
type: "reasoning-delta",
|
|
1244
1262
|
id: currentReasoningBlockId,
|
|
1245
1263
|
delta: part.text,
|
|
1246
|
-
providerMetadata:
|
|
1247
|
-
[providerOptionsName]: {
|
|
1248
|
-
thoughtSignature: part.thoughtSignature
|
|
1249
|
-
}
|
|
1250
|
-
} : void 0
|
|
1264
|
+
providerMetadata: thoughtSignatureMetadata
|
|
1251
1265
|
});
|
|
1252
1266
|
} else {
|
|
1253
1267
|
if (currentReasoningBlockId !== null) {
|
|
@@ -1262,22 +1276,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1262
1276
|
controller.enqueue({
|
|
1263
1277
|
type: "text-start",
|
|
1264
1278
|
id: currentTextBlockId,
|
|
1265
|
-
providerMetadata:
|
|
1266
|
-
[providerOptionsName]: {
|
|
1267
|
-
thoughtSignature: part.thoughtSignature
|
|
1268
|
-
}
|
|
1269
|
-
} : void 0
|
|
1279
|
+
providerMetadata: thoughtSignatureMetadata
|
|
1270
1280
|
});
|
|
1271
1281
|
}
|
|
1272
1282
|
controller.enqueue({
|
|
1273
1283
|
type: "text-delta",
|
|
1274
1284
|
id: currentTextBlockId,
|
|
1275
1285
|
delta: part.text,
|
|
1276
|
-
providerMetadata:
|
|
1277
|
-
[providerOptionsName]: {
|
|
1278
|
-
thoughtSignature: part.thoughtSignature
|
|
1279
|
-
}
|
|
1280
|
-
} : void 0
|
|
1286
|
+
providerMetadata: thoughtSignatureMetadata
|
|
1281
1287
|
});
|
|
1282
1288
|
}
|
|
1283
1289
|
} else if ("inlineData" in part) {
|
|
@@ -1333,10 +1339,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1333
1339
|
};
|
|
1334
1340
|
providerMetadata = {
|
|
1335
1341
|
[providerOptionsName]: {
|
|
1336
|
-
promptFeedback: (
|
|
1337
|
-
groundingMetadata: (
|
|
1338
|
-
urlContextMetadata: (
|
|
1339
|
-
safetyRatings: (
|
|
1342
|
+
promptFeedback: (_e = value.promptFeedback) != null ? _e : null,
|
|
1343
|
+
groundingMetadata: (_f = candidate.groundingMetadata) != null ? _f : null,
|
|
1344
|
+
urlContextMetadata: (_g = candidate.urlContextMetadata) != null ? _g : null,
|
|
1345
|
+
safetyRatings: (_h = candidate.safetyRatings) != null ? _h : null
|
|
1340
1346
|
}
|
|
1341
1347
|
};
|
|
1342
1348
|
if (usageMetadata != null) {
|
|
@@ -1542,7 +1548,7 @@ var getContentSchema = () => import_v45.z.object({
|
|
|
1542
1548
|
}).nullish(),
|
|
1543
1549
|
codeExecutionResult: import_v45.z.object({
|
|
1544
1550
|
outcome: import_v45.z.string(),
|
|
1545
|
-
output: import_v45.z.string()
|
|
1551
|
+
output: import_v45.z.string().nullish()
|
|
1546
1552
|
}).nullish(),
|
|
1547
1553
|
text: import_v45.z.string().nullish(),
|
|
1548
1554
|
thought: import_v45.z.boolean().nullish(),
|