@ai-sdk/google 4.0.10 → 4.0.11

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.
@@ -274,7 +274,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
274
274
  });
275
275
  break;
276
276
  case "file": {
277
- if (contentPart.data.type === "data" && getTopLevelMediaType(contentPart.mediaType) === "image") {
277
+ if (contentPart.data.type === "data") {
278
+ const topLevelMediaType = getTopLevelMediaType(contentPart.mediaType);
278
279
  parts.push(
279
280
  {
280
281
  inlineData: {
@@ -283,7 +284,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
283
284
  }
284
285
  },
285
286
  {
286
- text: "Tool executed successfully and returned this image as a response"
287
+ text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
287
288
  }
288
289
  );
289
290
  } else {
@@ -1329,6 +1330,12 @@ function mapGoogleFinishReason({
1329
1330
  }
1330
1331
 
1331
1332
  // src/google-language-model.ts
1333
+ var configurableSafetySettingCategories = [
1334
+ "HARM_CATEGORY_HATE_SPEECH",
1335
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
1336
+ "HARM_CATEGORY_HARASSMENT",
1337
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT"
1338
+ ];
1332
1339
  var GoogleLanguageModel = class _GoogleLanguageModel {
1333
1340
  constructor(modelId, config) {
1334
1341
  this.specificationVersion = "v4";
@@ -1369,7 +1376,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1369
1376
  reasoning,
1370
1377
  providerOptions
1371
1378
  }, { isStreaming = false } = {}) {
1372
- var _a, _b;
1379
+ var _a, _b, _c;
1373
1380
  const warnings = [];
1374
1381
  const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
1375
1382
  let googleOptions;
@@ -1451,6 +1458,11 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1451
1458
  });
1452
1459
  const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
1453
1460
  const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
1461
+ const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
1462
+ const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
1463
+ category,
1464
+ threshold: safetyThreshold
1465
+ })) : void 0;
1454
1466
  const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1455
1467
  ...googleToolConfig,
1456
1468
  ...streamFunctionCallArguments && {
@@ -1480,7 +1492,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1480
1492
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
1481
1493
  // so this is needed as an escape hatch:
1482
1494
  // TODO convert into provider option
1483
- ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1495
+ ((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1484
1496
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
1485
1497
  audioTimestamp: googleOptions.audioTimestamp
1486
1498
  },
@@ -1496,7 +1508,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1496
1508
  },
1497
1509
  contents,
1498
1510
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1499
- safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1511
+ safetySettings,
1500
1512
  tools: googleTools2,
1501
1513
  toolConfig,
1502
1514
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,