@ai-sdk/google 3.0.123 → 3.0.124

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.
@@ -1674,7 +1674,7 @@ var GoogleGenerativeAILanguageModel = class {
1674
1674
  };
1675
1675
  }
1676
1676
  async doGenerate(options) {
1677
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
1677
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1678
1678
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1679
1679
  const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
1680
1680
  await (0, import_provider_utils4.resolve)(this.config.headers),
@@ -1698,15 +1698,18 @@ var GoogleGenerativeAILanguageModel = class {
1698
1698
  });
1699
1699
  const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
1700
1700
  const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
1701
- const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
1702
- const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
1701
+ const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
1702
+ promptBlockReason
1703
+ ) ? promptBlockReason : void 0;
1704
+ const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
1705
+ const rawFinishReason = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : confirmedPromptBlockReason;
1703
1706
  const content = [];
1704
- const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
1707
+ const parts = (_e = (_d = candidate == null ? void 0 : candidate.content) == null ? void 0 : _d.parts) != null ? _e : [];
1705
1708
  const usageMetadata = response.usageMetadata;
1706
1709
  let lastCodeExecutionToolCallId;
1707
1710
  let lastServerToolCallId;
1708
1711
  for (const part of parts) {
1709
- if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
1712
+ if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
1710
1713
  const toolCallId = this.config.generateId();
1711
1714
  lastCodeExecutionToolCallId = toolCallId;
1712
1715
  content.push({
@@ -1724,7 +1727,7 @@ var GoogleGenerativeAILanguageModel = class {
1724
1727
  toolName: "code_execution",
1725
1728
  result: {
1726
1729
  outcome: part.codeExecutionResult.outcome,
1727
- output: (_h = part.codeExecutionResult.output) != null ? _h : ""
1730
+ output: (_g = part.codeExecutionResult.output) != null ? _g : ""
1728
1731
  }
1729
1732
  });
1730
1733
  } else if ("text" in part && part.text != null) {
@@ -1748,9 +1751,9 @@ var GoogleGenerativeAILanguageModel = class {
1748
1751
  } else if ("functionCall" in part && part.functionCall.name != null) {
1749
1752
  content.push({
1750
1753
  type: "tool-call",
1751
- toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
1754
+ toolCallId: (_h = part.functionCall.id) != null ? _h : this.config.generateId(),
1752
1755
  toolName: part.functionCall.name,
1753
- input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
1756
+ input: JSON.stringify((_i = part.functionCall.args) != null ? _i : {}),
1754
1757
  providerMetadata: part.thoughtSignature ? {
1755
1758
  [providerOptionsName]: {
1756
1759
  thoughtSignature: part.thoughtSignature
@@ -1772,13 +1775,13 @@ var GoogleGenerativeAILanguageModel = class {
1772
1775
  } : void 0
1773
1776
  });
1774
1777
  } else if ("toolCall" in part && part.toolCall) {
1775
- const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
1778
+ const toolCallId = (_j = part.toolCall.id) != null ? _j : this.config.generateId();
1776
1779
  lastServerToolCallId = toolCallId;
1777
1780
  content.push({
1778
1781
  type: "tool-call",
1779
1782
  toolCallId,
1780
1783
  toolName: `server:${part.toolCall.toolType}`,
1781
- input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
1784
+ input: JSON.stringify((_k = part.toolCall.args) != null ? _k : {}),
1782
1785
  providerExecuted: true,
1783
1786
  dynamic: true,
1784
1787
  providerMetadata: part.thoughtSignature ? {
@@ -1795,12 +1798,12 @@ var GoogleGenerativeAILanguageModel = class {
1795
1798
  }
1796
1799
  });
1797
1800
  } else if ("toolResponse" in part && part.toolResponse) {
1798
- const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
1801
+ const responseToolCallId = (_l = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _l : this.config.generateId();
1799
1802
  content.push({
1800
1803
  type: "tool-result",
1801
1804
  toolCallId: responseToolCallId,
1802
1805
  toolName: `server:${part.toolResponse.toolType}`,
1803
- result: (_n = part.toolResponse.response) != null ? _n : {},
1806
+ result: (_m = part.toolResponse.response) != null ? _m : {},
1804
1807
  providerMetadata: part.thoughtSignature ? {
1805
1808
  [providerOptionsName]: {
1806
1809
  thoughtSignature: part.thoughtSignature,
@@ -1817,10 +1820,10 @@ var GoogleGenerativeAILanguageModel = class {
1817
1820
  lastServerToolCallId = void 0;
1818
1821
  }
1819
1822
  }
1820
- const sources = (_o = extractSources({
1823
+ const sources = (_n = extractSources({
1821
1824
  groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
1822
1825
  generateId: this.config.generateId
1823
- })) != null ? _o : [];
1826
+ })) != null ? _n : [];
1824
1827
  for (const source of sources) {
1825
1828
  content.push(source);
1826
1829
  }
@@ -1840,19 +1843,19 @@ var GoogleGenerativeAILanguageModel = class {
1840
1843
  warnings,
1841
1844
  providerMetadata: {
1842
1845
  [providerOptionsName]: {
1843
- promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
1844
- groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
1845
- urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
1846
- safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
1846
+ promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
1847
+ groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
1848
+ urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
1849
+ safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
1847
1850
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1848
- finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
1849
- serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
1851
+ finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
1852
+ serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
1850
1853
  }
1851
1854
  },
1852
1855
  request: { body: args },
1853
1856
  response: {
1854
1857
  // TODO timestamp, model id
1855
- id: (_v = response.responseId) != null ? _v : void 0,
1858
+ id: (_u = response.responseId) != null ? _u : void 0,
1856
1859
  headers: responseHeaders,
1857
1860
  body: rawResponse
1858
1861
  }