@ai-sdk/google 3.0.23 → 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 CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 3.0.23
4
10
 
5
11
  ### Patch Changes
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.23" : "0.0.0-test";
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");
@@ -1051,16 +1051,24 @@ var GoogleGenerativeAILanguageModel = class {
1051
1051
  }
1052
1052
  });
1053
1053
  lastCodeExecutionToolCallId = void 0;
1054
- } else if ("text" in part && part.text != null && part.text.length > 0) {
1055
- content.push({
1056
- type: part.thought === true ? "reasoning" : "text",
1057
- text: part.text,
1058
- providerMetadata: part.thoughtSignature ? {
1059
- [providerOptionsName]: {
1060
- thoughtSignature: part.thoughtSignature
1061
- }
1062
- } : void 0
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",
@@ -1218,8 +1226,22 @@ var GoogleGenerativeAILanguageModel = class {
1218
1226
  });
1219
1227
  lastCodeExecutionToolCallId = void 0;
1220
1228
  }
1221
- } else if ("text" in part && part.text != null && part.text.length > 0) {
1222
- if (part.thought === true) {
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: part.thoughtSignature ? {
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: part.thoughtSignature ? {
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: part.thoughtSignature ? {
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: part.thoughtSignature ? {
1277
- [providerOptionsName]: {
1278
- thoughtSignature: part.thoughtSignature
1279
- }
1280
- } : void 0
1286
+ providerMetadata: thoughtSignatureMetadata
1281
1287
  });
1282
1288
  }
1283
1289
  } else if ("inlineData" in part) {