@ai-sdk/google 3.0.70 → 3.0.72

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.
@@ -1296,7 +1296,7 @@ var GoogleGenerativeAILanguageModel = class {
1296
1296
  };
1297
1297
  }
1298
1298
  async doGenerate(options) {
1299
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1299
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1300
1300
  const { args, warnings, providerOptionsName } = await this.getArgs(options);
1301
1301
  const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
1302
1302
  await (0, import_provider_utils4.resolve)(this.config.headers),
@@ -1364,12 +1364,12 @@ var GoogleGenerativeAILanguageModel = class {
1364
1364
  providerMetadata: thoughtSignatureMetadata
1365
1365
  });
1366
1366
  }
1367
- } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
1367
+ } else if ("functionCall" in part && part.functionCall.name != null) {
1368
1368
  content.push({
1369
1369
  type: "tool-call",
1370
1370
  toolCallId: this.config.generateId(),
1371
1371
  toolName: part.functionCall.name,
1372
- input: JSON.stringify(part.functionCall.args),
1372
+ input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
1373
1373
  providerMetadata: part.thoughtSignature ? {
1374
1374
  [providerOptionsName]: {
1375
1375
  thoughtSignature: part.thoughtSignature
@@ -1391,13 +1391,13 @@ var GoogleGenerativeAILanguageModel = class {
1391
1391
  } : void 0
1392
1392
  });
1393
1393
  } else if ("toolCall" in part && part.toolCall) {
1394
- const toolCallId = (_e = part.toolCall.id) != null ? _e : this.config.generateId();
1394
+ const toolCallId = (_f = part.toolCall.id) != null ? _f : this.config.generateId();
1395
1395
  lastServerToolCallId = toolCallId;
1396
1396
  content.push({
1397
1397
  type: "tool-call",
1398
1398
  toolCallId,
1399
1399
  toolName: `server:${part.toolCall.toolType}`,
1400
- input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1400
+ input: JSON.stringify((_g = part.toolCall.args) != null ? _g : {}),
1401
1401
  providerExecuted: true,
1402
1402
  dynamic: true,
1403
1403
  providerMetadata: part.thoughtSignature ? {
@@ -1414,12 +1414,12 @@ var GoogleGenerativeAILanguageModel = class {
1414
1414
  }
1415
1415
  });
1416
1416
  } else if ("toolResponse" in part && part.toolResponse) {
1417
- const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : this.config.generateId();
1417
+ const responseToolCallId = (_h = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _h : this.config.generateId();
1418
1418
  content.push({
1419
1419
  type: "tool-result",
1420
1420
  toolCallId: responseToolCallId,
1421
1421
  toolName: `server:${part.toolResponse.toolType}`,
1422
- result: (_h = part.toolResponse.response) != null ? _h : {},
1422
+ result: (_i = part.toolResponse.response) != null ? _i : {},
1423
1423
  providerMetadata: part.thoughtSignature ? {
1424
1424
  [providerOptionsName]: {
1425
1425
  thoughtSignature: part.thoughtSignature,
@@ -1436,10 +1436,10 @@ var GoogleGenerativeAILanguageModel = class {
1436
1436
  lastServerToolCallId = void 0;
1437
1437
  }
1438
1438
  }
1439
- const sources = (_i = extractSources({
1439
+ const sources = (_j = extractSources({
1440
1440
  groundingMetadata: candidate.groundingMetadata,
1441
1441
  generateId: this.config.generateId
1442
- })) != null ? _i : [];
1442
+ })) != null ? _j : [];
1443
1443
  for (const source of sources) {
1444
1444
  content.push(source);
1445
1445
  }
@@ -1453,19 +1453,19 @@ var GoogleGenerativeAILanguageModel = class {
1453
1453
  (part) => part.type === "tool-call" && !part.providerExecuted
1454
1454
  )
1455
1455
  }),
1456
- raw: (_j = candidate.finishReason) != null ? _j : void 0
1456
+ raw: (_k = candidate.finishReason) != null ? _k : void 0
1457
1457
  },
1458
1458
  usage: convertGoogleGenerativeAIUsage(usageMetadata),
1459
1459
  warnings,
1460
1460
  providerMetadata: {
1461
1461
  [providerOptionsName]: {
1462
- promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
1463
- groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
1464
- urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
1465
- safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
1462
+ promptFeedback: (_l = response.promptFeedback) != null ? _l : null,
1463
+ groundingMetadata: (_m = candidate.groundingMetadata) != null ? _m : null,
1464
+ urlContextMetadata: (_n = candidate.urlContextMetadata) != null ? _n : null,
1465
+ safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
1466
1466
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1467
- finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
1468
- serviceTier: (_p = response.serviceTier) != null ? _p : null
1467
+ finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
1468
+ serviceTier: (_q = response.serviceTier) != null ? _q : null
1469
1469
  }
1470
1470
  },
1471
1471
  request: { body: args },
@@ -1724,6 +1724,7 @@ var GoogleGenerativeAILanguageModel = class {
1724
1724
  const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1725
1725
  const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1726
1726
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1727
+ const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
1727
1728
  if (isStreamingChunk) {
1728
1729
  if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1729
1730
  const toolCallId = generateId2();
@@ -1820,6 +1821,28 @@ var GoogleGenerativeAILanguageModel = class {
1820
1821
  providerMetadata: providerMeta
1821
1822
  });
1822
1823
  hasToolCalls = true;
1824
+ } else if (isNoArgsCompleteCall) {
1825
+ const toolCallId = generateId2();
1826
+ const toolName = part.functionCall.name;
1827
+ controller.enqueue({
1828
+ type: "tool-input-start",
1829
+ id: toolCallId,
1830
+ toolName,
1831
+ providerMetadata: providerMeta
1832
+ });
1833
+ controller.enqueue({
1834
+ type: "tool-input-end",
1835
+ id: toolCallId,
1836
+ providerMetadata: providerMeta
1837
+ });
1838
+ controller.enqueue({
1839
+ type: "tool-call",
1840
+ toolCallId,
1841
+ toolName,
1842
+ input: "{}",
1843
+ providerMetadata: providerMeta
1844
+ });
1845
+ hasToolCalls = true;
1823
1846
  }
1824
1847
  }
1825
1848
  }