@ai-sdk/google 3.0.70 → 3.0.71

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/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 ? "3.0.70" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.71" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -1499,7 +1499,7 @@ var GoogleGenerativeAILanguageModel = class {
1499
1499
  };
1500
1500
  }
1501
1501
  async doGenerate(options) {
1502
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1502
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1503
1503
  const { args, warnings, providerOptionsName } = await this.getArgs(options);
1504
1504
  const mergedHeaders = combineHeaders2(
1505
1505
  await resolve2(this.config.headers),
@@ -1567,12 +1567,12 @@ var GoogleGenerativeAILanguageModel = class {
1567
1567
  providerMetadata: thoughtSignatureMetadata
1568
1568
  });
1569
1569
  }
1570
- } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
1570
+ } else if ("functionCall" in part && part.functionCall.name != null) {
1571
1571
  content.push({
1572
1572
  type: "tool-call",
1573
1573
  toolCallId: this.config.generateId(),
1574
1574
  toolName: part.functionCall.name,
1575
- input: JSON.stringify(part.functionCall.args),
1575
+ input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
1576
1576
  providerMetadata: part.thoughtSignature ? {
1577
1577
  [providerOptionsName]: {
1578
1578
  thoughtSignature: part.thoughtSignature
@@ -1594,13 +1594,13 @@ var GoogleGenerativeAILanguageModel = class {
1594
1594
  } : void 0
1595
1595
  });
1596
1596
  } else if ("toolCall" in part && part.toolCall) {
1597
- const toolCallId = (_e = part.toolCall.id) != null ? _e : this.config.generateId();
1597
+ const toolCallId = (_f = part.toolCall.id) != null ? _f : this.config.generateId();
1598
1598
  lastServerToolCallId = toolCallId;
1599
1599
  content.push({
1600
1600
  type: "tool-call",
1601
1601
  toolCallId,
1602
1602
  toolName: `server:${part.toolCall.toolType}`,
1603
- input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1603
+ input: JSON.stringify((_g = part.toolCall.args) != null ? _g : {}),
1604
1604
  providerExecuted: true,
1605
1605
  dynamic: true,
1606
1606
  providerMetadata: part.thoughtSignature ? {
@@ -1617,12 +1617,12 @@ var GoogleGenerativeAILanguageModel = class {
1617
1617
  }
1618
1618
  });
1619
1619
  } else if ("toolResponse" in part && part.toolResponse) {
1620
- const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : this.config.generateId();
1620
+ const responseToolCallId = (_h = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _h : this.config.generateId();
1621
1621
  content.push({
1622
1622
  type: "tool-result",
1623
1623
  toolCallId: responseToolCallId,
1624
1624
  toolName: `server:${part.toolResponse.toolType}`,
1625
- result: (_h = part.toolResponse.response) != null ? _h : {},
1625
+ result: (_i = part.toolResponse.response) != null ? _i : {},
1626
1626
  providerMetadata: part.thoughtSignature ? {
1627
1627
  [providerOptionsName]: {
1628
1628
  thoughtSignature: part.thoughtSignature,
@@ -1639,10 +1639,10 @@ var GoogleGenerativeAILanguageModel = class {
1639
1639
  lastServerToolCallId = void 0;
1640
1640
  }
1641
1641
  }
1642
- const sources = (_i = extractSources({
1642
+ const sources = (_j = extractSources({
1643
1643
  groundingMetadata: candidate.groundingMetadata,
1644
1644
  generateId: this.config.generateId
1645
- })) != null ? _i : [];
1645
+ })) != null ? _j : [];
1646
1646
  for (const source of sources) {
1647
1647
  content.push(source);
1648
1648
  }
@@ -1656,19 +1656,19 @@ var GoogleGenerativeAILanguageModel = class {
1656
1656
  (part) => part.type === "tool-call" && !part.providerExecuted
1657
1657
  )
1658
1658
  }),
1659
- raw: (_j = candidate.finishReason) != null ? _j : void 0
1659
+ raw: (_k = candidate.finishReason) != null ? _k : void 0
1660
1660
  },
1661
1661
  usage: convertGoogleGenerativeAIUsage(usageMetadata),
1662
1662
  warnings,
1663
1663
  providerMetadata: {
1664
1664
  [providerOptionsName]: {
1665
- promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
1666
- groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
1667
- urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
1668
- safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
1665
+ promptFeedback: (_l = response.promptFeedback) != null ? _l : null,
1666
+ groundingMetadata: (_m = candidate.groundingMetadata) != null ? _m : null,
1667
+ urlContextMetadata: (_n = candidate.urlContextMetadata) != null ? _n : null,
1668
+ safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
1669
1669
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1670
- finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
1671
- serviceTier: (_p = response.serviceTier) != null ? _p : null
1670
+ finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
1671
+ serviceTier: (_q = response.serviceTier) != null ? _q : null
1672
1672
  }
1673
1673
  },
1674
1674
  request: { body: args },
@@ -1927,6 +1927,7 @@ var GoogleGenerativeAILanguageModel = class {
1927
1927
  const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1928
1928
  const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1929
1929
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1930
+ const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
1930
1931
  if (isStreamingChunk) {
1931
1932
  if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1932
1933
  const toolCallId = generateId3();
@@ -2023,6 +2024,28 @@ var GoogleGenerativeAILanguageModel = class {
2023
2024
  providerMetadata: providerMeta
2024
2025
  });
2025
2026
  hasToolCalls = true;
2027
+ } else if (isNoArgsCompleteCall) {
2028
+ const toolCallId = generateId3();
2029
+ const toolName = part.functionCall.name;
2030
+ controller.enqueue({
2031
+ type: "tool-input-start",
2032
+ id: toolCallId,
2033
+ toolName,
2034
+ providerMetadata: providerMeta
2035
+ });
2036
+ controller.enqueue({
2037
+ type: "tool-input-end",
2038
+ id: toolCallId,
2039
+ providerMetadata: providerMeta
2040
+ });
2041
+ controller.enqueue({
2042
+ type: "tool-call",
2043
+ toolCallId,
2044
+ toolName,
2045
+ input: "{}",
2046
+ providerMetadata: providerMeta
2047
+ });
2048
+ hasToolCalls = true;
2026
2049
  }
2027
2050
  }
2028
2051
  }