@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.
@@ -1667,7 +1667,7 @@ var GoogleGenerativeAILanguageModel = class {
1667
1667
  };
1668
1668
  }
1669
1669
  async doGenerate(options) {
1670
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
1670
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1671
1671
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1672
1672
  const mergedHeaders = combineHeaders(
1673
1673
  await resolve(this.config.headers),
@@ -1691,15 +1691,18 @@ var GoogleGenerativeAILanguageModel = class {
1691
1691
  });
1692
1692
  const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
1693
1693
  const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
1694
- const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
1695
- const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
1694
+ const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
1695
+ promptBlockReason
1696
+ ) ? promptBlockReason : void 0;
1697
+ const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
1698
+ const rawFinishReason = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : confirmedPromptBlockReason;
1696
1699
  const content = [];
1697
- const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
1700
+ const parts = (_e = (_d = candidate == null ? void 0 : candidate.content) == null ? void 0 : _d.parts) != null ? _e : [];
1698
1701
  const usageMetadata = response.usageMetadata;
1699
1702
  let lastCodeExecutionToolCallId;
1700
1703
  let lastServerToolCallId;
1701
1704
  for (const part of parts) {
1702
- if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
1705
+ if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
1703
1706
  const toolCallId = this.config.generateId();
1704
1707
  lastCodeExecutionToolCallId = toolCallId;
1705
1708
  content.push({
@@ -1717,7 +1720,7 @@ var GoogleGenerativeAILanguageModel = class {
1717
1720
  toolName: "code_execution",
1718
1721
  result: {
1719
1722
  outcome: part.codeExecutionResult.outcome,
1720
- output: (_h = part.codeExecutionResult.output) != null ? _h : ""
1723
+ output: (_g = part.codeExecutionResult.output) != null ? _g : ""
1721
1724
  }
1722
1725
  });
1723
1726
  } else if ("text" in part && part.text != null) {
@@ -1741,9 +1744,9 @@ var GoogleGenerativeAILanguageModel = class {
1741
1744
  } else if ("functionCall" in part && part.functionCall.name != null) {
1742
1745
  content.push({
1743
1746
  type: "tool-call",
1744
- toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
1747
+ toolCallId: (_h = part.functionCall.id) != null ? _h : this.config.generateId(),
1745
1748
  toolName: part.functionCall.name,
1746
- input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
1749
+ input: JSON.stringify((_i = part.functionCall.args) != null ? _i : {}),
1747
1750
  providerMetadata: part.thoughtSignature ? {
1748
1751
  [providerOptionsName]: {
1749
1752
  thoughtSignature: part.thoughtSignature
@@ -1765,13 +1768,13 @@ var GoogleGenerativeAILanguageModel = class {
1765
1768
  } : void 0
1766
1769
  });
1767
1770
  } else if ("toolCall" in part && part.toolCall) {
1768
- const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
1771
+ const toolCallId = (_j = part.toolCall.id) != null ? _j : this.config.generateId();
1769
1772
  lastServerToolCallId = toolCallId;
1770
1773
  content.push({
1771
1774
  type: "tool-call",
1772
1775
  toolCallId,
1773
1776
  toolName: `server:${part.toolCall.toolType}`,
1774
- input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
1777
+ input: JSON.stringify((_k = part.toolCall.args) != null ? _k : {}),
1775
1778
  providerExecuted: true,
1776
1779
  dynamic: true,
1777
1780
  providerMetadata: part.thoughtSignature ? {
@@ -1788,12 +1791,12 @@ var GoogleGenerativeAILanguageModel = class {
1788
1791
  }
1789
1792
  });
1790
1793
  } else if ("toolResponse" in part && part.toolResponse) {
1791
- const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
1794
+ const responseToolCallId = (_l = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _l : this.config.generateId();
1792
1795
  content.push({
1793
1796
  type: "tool-result",
1794
1797
  toolCallId: responseToolCallId,
1795
1798
  toolName: `server:${part.toolResponse.toolType}`,
1796
- result: (_n = part.toolResponse.response) != null ? _n : {},
1799
+ result: (_m = part.toolResponse.response) != null ? _m : {},
1797
1800
  providerMetadata: part.thoughtSignature ? {
1798
1801
  [providerOptionsName]: {
1799
1802
  thoughtSignature: part.thoughtSignature,
@@ -1810,10 +1813,10 @@ var GoogleGenerativeAILanguageModel = class {
1810
1813
  lastServerToolCallId = void 0;
1811
1814
  }
1812
1815
  }
1813
- const sources = (_o = extractSources({
1816
+ const sources = (_n = extractSources({
1814
1817
  groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
1815
1818
  generateId: this.config.generateId
1816
- })) != null ? _o : [];
1819
+ })) != null ? _n : [];
1817
1820
  for (const source of sources) {
1818
1821
  content.push(source);
1819
1822
  }
@@ -1833,19 +1836,19 @@ var GoogleGenerativeAILanguageModel = class {
1833
1836
  warnings,
1834
1837
  providerMetadata: {
1835
1838
  [providerOptionsName]: {
1836
- promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
1837
- groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
1838
- urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
1839
- safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
1839
+ promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
1840
+ groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
1841
+ urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
1842
+ safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
1840
1843
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1841
- finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
1842
- serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
1844
+ finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
1845
+ serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
1843
1846
  }
1844
1847
  },
1845
1848
  request: { body: args },
1846
1849
  response: {
1847
1850
  // TODO timestamp, model id
1848
- id: (_v = response.responseId) != null ? _v : void 0,
1851
+ id: (_u = response.responseId) != null ? _u : void 0,
1849
1852
  headers: responseHeaders,
1850
1853
  body: rawResponse
1851
1854
  }