@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.
package/dist/index.mjs CHANGED
@@ -224,7 +224,7 @@ import {
224
224
  } from "@ai-sdk/provider-utils";
225
225
 
226
226
  // src/version.ts
227
- var VERSION = true ? "3.0.123" : "0.0.0-test";
227
+ var VERSION = true ? "3.0.124" : "0.0.0-test";
228
228
 
229
229
  // src/google-generative-ai-embedding-model.ts
230
230
  import {
@@ -2077,7 +2077,7 @@ var GoogleGenerativeAILanguageModel = class {
2077
2077
  };
2078
2078
  }
2079
2079
  async doGenerate(options) {
2080
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2080
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2081
2081
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
2082
2082
  const mergedHeaders = combineHeaders3(
2083
2083
  await resolve3(this.config.headers),
@@ -2101,15 +2101,18 @@ var GoogleGenerativeAILanguageModel = class {
2101
2101
  });
2102
2102
  const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
2103
2103
  const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
2104
- const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
2105
- const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
2104
+ const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
2105
+ promptBlockReason
2106
+ ) ? promptBlockReason : void 0;
2107
+ const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
2108
+ const rawFinishReason = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : confirmedPromptBlockReason;
2106
2109
  const content = [];
2107
- const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
2110
+ const parts = (_e = (_d = candidate == null ? void 0 : candidate.content) == null ? void 0 : _d.parts) != null ? _e : [];
2108
2111
  const usageMetadata = response.usageMetadata;
2109
2112
  let lastCodeExecutionToolCallId;
2110
2113
  let lastServerToolCallId;
2111
2114
  for (const part of parts) {
2112
- if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
2115
+ if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
2113
2116
  const toolCallId = this.config.generateId();
2114
2117
  lastCodeExecutionToolCallId = toolCallId;
2115
2118
  content.push({
@@ -2127,7 +2130,7 @@ var GoogleGenerativeAILanguageModel = class {
2127
2130
  toolName: "code_execution",
2128
2131
  result: {
2129
2132
  outcome: part.codeExecutionResult.outcome,
2130
- output: (_h = part.codeExecutionResult.output) != null ? _h : ""
2133
+ output: (_g = part.codeExecutionResult.output) != null ? _g : ""
2131
2134
  }
2132
2135
  });
2133
2136
  } else if ("text" in part && part.text != null) {
@@ -2151,9 +2154,9 @@ var GoogleGenerativeAILanguageModel = class {
2151
2154
  } else if ("functionCall" in part && part.functionCall.name != null) {
2152
2155
  content.push({
2153
2156
  type: "tool-call",
2154
- toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
2157
+ toolCallId: (_h = part.functionCall.id) != null ? _h : this.config.generateId(),
2155
2158
  toolName: part.functionCall.name,
2156
- input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
2159
+ input: JSON.stringify((_i = part.functionCall.args) != null ? _i : {}),
2157
2160
  providerMetadata: part.thoughtSignature ? {
2158
2161
  [providerOptionsName]: {
2159
2162
  thoughtSignature: part.thoughtSignature
@@ -2175,13 +2178,13 @@ var GoogleGenerativeAILanguageModel = class {
2175
2178
  } : void 0
2176
2179
  });
2177
2180
  } else if ("toolCall" in part && part.toolCall) {
2178
- const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
2181
+ const toolCallId = (_j = part.toolCall.id) != null ? _j : this.config.generateId();
2179
2182
  lastServerToolCallId = toolCallId;
2180
2183
  content.push({
2181
2184
  type: "tool-call",
2182
2185
  toolCallId,
2183
2186
  toolName: `server:${part.toolCall.toolType}`,
2184
- input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
2187
+ input: JSON.stringify((_k = part.toolCall.args) != null ? _k : {}),
2185
2188
  providerExecuted: true,
2186
2189
  dynamic: true,
2187
2190
  providerMetadata: part.thoughtSignature ? {
@@ -2198,12 +2201,12 @@ var GoogleGenerativeAILanguageModel = class {
2198
2201
  }
2199
2202
  });
2200
2203
  } else if ("toolResponse" in part && part.toolResponse) {
2201
- const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
2204
+ const responseToolCallId = (_l = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _l : this.config.generateId();
2202
2205
  content.push({
2203
2206
  type: "tool-result",
2204
2207
  toolCallId: responseToolCallId,
2205
2208
  toolName: `server:${part.toolResponse.toolType}`,
2206
- result: (_n = part.toolResponse.response) != null ? _n : {},
2209
+ result: (_m = part.toolResponse.response) != null ? _m : {},
2207
2210
  providerMetadata: part.thoughtSignature ? {
2208
2211
  [providerOptionsName]: {
2209
2212
  thoughtSignature: part.thoughtSignature,
@@ -2220,10 +2223,10 @@ var GoogleGenerativeAILanguageModel = class {
2220
2223
  lastServerToolCallId = void 0;
2221
2224
  }
2222
2225
  }
2223
- const sources = (_o = extractSources({
2226
+ const sources = (_n = extractSources({
2224
2227
  groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
2225
2228
  generateId: this.config.generateId
2226
- })) != null ? _o : [];
2229
+ })) != null ? _n : [];
2227
2230
  for (const source of sources) {
2228
2231
  content.push(source);
2229
2232
  }
@@ -2243,19 +2246,19 @@ var GoogleGenerativeAILanguageModel = class {
2243
2246
  warnings,
2244
2247
  providerMetadata: {
2245
2248
  [providerOptionsName]: {
2246
- promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
2247
- groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
2248
- urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
2249
- safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
2249
+ promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
2250
+ groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
2251
+ urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
2252
+ safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
2250
2253
  usageMetadata: usageMetadata != null ? usageMetadata : null,
2251
- finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
2252
- serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
2254
+ finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
2255
+ serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
2253
2256
  }
2254
2257
  },
2255
2258
  request: { body: args },
2256
2259
  response: {
2257
2260
  // TODO timestamp, model id
2258
- id: (_v = response.responseId) != null ? _v : void 0,
2261
+ id: (_u = response.responseId) != null ? _u : void 0,
2259
2262
  headers: responseHeaders,
2260
2263
  body: rawResponse
2261
2264
  }