@ai-sdk/google 3.0.123 → 3.0.125

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,18 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.125
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [82e18b0]
8
+ - @ai-sdk/provider-utils@4.0.52
9
+
10
+ ## 3.0.124
11
+
12
+ ### Patch Changes
13
+
14
+ - 9548d8e: fix(google): ignore default prompt block reasons in non-streaming responses
15
+
3
16
  ## 3.0.123
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -235,7 +235,7 @@ var googleInteractionsTranscriptionResponseSchema = import_v43.z.object({
235
235
  var import_provider_utils24 = require("@ai-sdk/provider-utils");
236
236
 
237
237
  // src/version.ts
238
- var VERSION = true ? "3.0.123" : "0.0.0-test";
238
+ var VERSION = true ? "3.0.125" : "0.0.0-test";
239
239
 
240
240
  // src/google-generative-ai-embedding-model.ts
241
241
  var import_provider2 = require("@ai-sdk/provider");
@@ -2056,7 +2056,7 @@ var GoogleGenerativeAILanguageModel = class {
2056
2056
  };
2057
2057
  }
2058
2058
  async doGenerate(options) {
2059
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2059
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2060
2060
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
2061
2061
  const mergedHeaders = (0, import_provider_utils7.combineHeaders)(
2062
2062
  await (0, import_provider_utils7.resolve)(this.config.headers),
@@ -2080,15 +2080,18 @@ var GoogleGenerativeAILanguageModel = class {
2080
2080
  });
2081
2081
  const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
2082
2082
  const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
2083
- const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
2084
- const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
2083
+ const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
2084
+ promptBlockReason
2085
+ ) ? promptBlockReason : void 0;
2086
+ const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
2087
+ const rawFinishReason = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : confirmedPromptBlockReason;
2085
2088
  const content = [];
2086
- const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
2089
+ const parts = (_e = (_d = candidate == null ? void 0 : candidate.content) == null ? void 0 : _d.parts) != null ? _e : [];
2087
2090
  const usageMetadata = response.usageMetadata;
2088
2091
  let lastCodeExecutionToolCallId;
2089
2092
  let lastServerToolCallId;
2090
2093
  for (const part of parts) {
2091
- if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
2094
+ if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
2092
2095
  const toolCallId = this.config.generateId();
2093
2096
  lastCodeExecutionToolCallId = toolCallId;
2094
2097
  content.push({
@@ -2106,7 +2109,7 @@ var GoogleGenerativeAILanguageModel = class {
2106
2109
  toolName: "code_execution",
2107
2110
  result: {
2108
2111
  outcome: part.codeExecutionResult.outcome,
2109
- output: (_h = part.codeExecutionResult.output) != null ? _h : ""
2112
+ output: (_g = part.codeExecutionResult.output) != null ? _g : ""
2110
2113
  }
2111
2114
  });
2112
2115
  } else if ("text" in part && part.text != null) {
@@ -2130,9 +2133,9 @@ var GoogleGenerativeAILanguageModel = class {
2130
2133
  } else if ("functionCall" in part && part.functionCall.name != null) {
2131
2134
  content.push({
2132
2135
  type: "tool-call",
2133
- toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
2136
+ toolCallId: (_h = part.functionCall.id) != null ? _h : this.config.generateId(),
2134
2137
  toolName: part.functionCall.name,
2135
- input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
2138
+ input: JSON.stringify((_i = part.functionCall.args) != null ? _i : {}),
2136
2139
  providerMetadata: part.thoughtSignature ? {
2137
2140
  [providerOptionsName]: {
2138
2141
  thoughtSignature: part.thoughtSignature
@@ -2154,13 +2157,13 @@ var GoogleGenerativeAILanguageModel = class {
2154
2157
  } : void 0
2155
2158
  });
2156
2159
  } else if ("toolCall" in part && part.toolCall) {
2157
- const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
2160
+ const toolCallId = (_j = part.toolCall.id) != null ? _j : this.config.generateId();
2158
2161
  lastServerToolCallId = toolCallId;
2159
2162
  content.push({
2160
2163
  type: "tool-call",
2161
2164
  toolCallId,
2162
2165
  toolName: `server:${part.toolCall.toolType}`,
2163
- input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
2166
+ input: JSON.stringify((_k = part.toolCall.args) != null ? _k : {}),
2164
2167
  providerExecuted: true,
2165
2168
  dynamic: true,
2166
2169
  providerMetadata: part.thoughtSignature ? {
@@ -2177,12 +2180,12 @@ var GoogleGenerativeAILanguageModel = class {
2177
2180
  }
2178
2181
  });
2179
2182
  } else if ("toolResponse" in part && part.toolResponse) {
2180
- const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
2183
+ const responseToolCallId = (_l = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _l : this.config.generateId();
2181
2184
  content.push({
2182
2185
  type: "tool-result",
2183
2186
  toolCallId: responseToolCallId,
2184
2187
  toolName: `server:${part.toolResponse.toolType}`,
2185
- result: (_n = part.toolResponse.response) != null ? _n : {},
2188
+ result: (_m = part.toolResponse.response) != null ? _m : {},
2186
2189
  providerMetadata: part.thoughtSignature ? {
2187
2190
  [providerOptionsName]: {
2188
2191
  thoughtSignature: part.thoughtSignature,
@@ -2199,10 +2202,10 @@ var GoogleGenerativeAILanguageModel = class {
2199
2202
  lastServerToolCallId = void 0;
2200
2203
  }
2201
2204
  }
2202
- const sources = (_o = extractSources({
2205
+ const sources = (_n = extractSources({
2203
2206
  groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
2204
2207
  generateId: this.config.generateId
2205
- })) != null ? _o : [];
2208
+ })) != null ? _n : [];
2206
2209
  for (const source of sources) {
2207
2210
  content.push(source);
2208
2211
  }
@@ -2222,19 +2225,19 @@ var GoogleGenerativeAILanguageModel = class {
2222
2225
  warnings,
2223
2226
  providerMetadata: {
2224
2227
  [providerOptionsName]: {
2225
- promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
2226
- groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
2227
- urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
2228
- safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
2228
+ promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
2229
+ groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
2230
+ urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
2231
+ safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
2229
2232
  usageMetadata: usageMetadata != null ? usageMetadata : null,
2230
- finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
2231
- serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
2233
+ finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
2234
+ serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
2232
2235
  }
2233
2236
  },
2234
2237
  request: { body: args },
2235
2238
  response: {
2236
2239
  // TODO timestamp, model id
2237
- id: (_v = response.responseId) != null ? _v : void 0,
2240
+ id: (_u = response.responseId) != null ? _u : void 0,
2238
2241
  headers: responseHeaders,
2239
2242
  body: rawResponse
2240
2243
  }