@ai-sdk/google 3.0.90 → 3.0.91

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
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "3.0.90" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.91" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -517,6 +517,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
517
517
  });
518
518
  break;
519
519
  case "image-data":
520
+ case "file-data": {
521
+ const topLevelMediaType = String(contentPart.mediaType).split("/")[0];
520
522
  parts.push(
521
523
  {
522
524
  inlineData: {
@@ -525,10 +527,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
525
527
  }
526
528
  },
527
529
  {
528
- text: "Tool executed successfully and returned this image as a response"
530
+ text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
529
531
  }
530
532
  );
531
533
  break;
534
+ }
532
535
  default:
533
536
  parts.push({ text: JSON.stringify(contentPart) });
534
537
  break;
@@ -1445,6 +1448,12 @@ function mapGoogleGenerativeAIFinishReason({
1445
1448
  }
1446
1449
 
1447
1450
  // src/google-generative-ai-language-model.ts
1451
+ var configurableSafetySettingCategories = [
1452
+ "HARM_CATEGORY_HATE_SPEECH",
1453
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
1454
+ "HARM_CATEGORY_HARASSMENT",
1455
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT"
1456
+ ];
1448
1457
  var GoogleGenerativeAILanguageModel = class {
1449
1458
  constructor(modelId, config) {
1450
1459
  this.specificationVersion = "v3";
@@ -1475,7 +1484,7 @@ var GoogleGenerativeAILanguageModel = class {
1475
1484
  toolChoice,
1476
1485
  providerOptions
1477
1486
  }, { isStreaming = false } = {}) {
1478
- var _a, _b;
1487
+ var _a, _b, _c;
1479
1488
  const warnings = [];
1480
1489
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1481
1490
  let googleOptions = await parseProviderOptions2({
@@ -1550,6 +1559,11 @@ var GoogleGenerativeAILanguageModel = class {
1550
1559
  isVertexProvider
1551
1560
  });
1552
1561
  const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
1562
+ const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
1563
+ const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
1564
+ category,
1565
+ threshold: safetyThreshold
1566
+ })) : void 0;
1553
1567
  const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1554
1568
  ...googleToolConfig,
1555
1569
  ...streamFunctionCallArguments && {
@@ -1579,7 +1593,7 @@ var GoogleGenerativeAILanguageModel = class {
1579
1593
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
1580
1594
  // so this is needed as an escape hatch:
1581
1595
  // TODO convert into provider option
1582
- ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1596
+ ((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1583
1597
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
1584
1598
  audioTimestamp: googleOptions.audioTimestamp
1585
1599
  },
@@ -1595,7 +1609,7 @@ var GoogleGenerativeAILanguageModel = class {
1595
1609
  },
1596
1610
  contents,
1597
1611
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1598
- safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1612
+ safetySettings,
1599
1613
  tools: googleTools2,
1600
1614
  toolConfig,
1601
1615
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
@@ -3012,31 +3026,32 @@ function convertFileToGoogleImage(file, warnings) {
3012
3026
  }
3013
3027
  const base64Data = typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data);
3014
3028
  return {
3015
- inlineData: {
3016
- mimeType: file.mediaType || "image/png",
3017
- data: base64Data
3018
- }
3029
+ bytesBase64Encoded: base64Data,
3030
+ mimeType: file.mediaType || "image/png"
3019
3031
  };
3020
3032
  }
3021
3033
  function convertProviderReferenceImage(refImg) {
3022
3034
  if (refImg.bytesBase64Encoded) {
3023
3035
  return {
3024
- inlineData: {
3025
- mimeType: "image/png",
3026
- data: refImg.bytesBase64Encoded
3036
+ image: {
3037
+ bytesBase64Encoded: refImg.bytesBase64Encoded,
3038
+ mimeType: "image/png"
3027
3039
  }
3028
3040
  };
3029
3041
  }
3030
3042
  if (refImg.gcsUri) {
3031
3043
  return {
3032
- gcsUri: refImg.gcsUri
3044
+ image: {
3045
+ gcsUri: refImg.gcsUri,
3046
+ mimeType: "image/png"
3047
+ }
3033
3048
  };
3034
3049
  }
3035
3050
  return refImg;
3036
3051
  }
3037
3052
  function convertInputReferenceImage(file, warnings) {
3038
3053
  const image = convertFileToGoogleImage(file, warnings);
3039
- return image != null ? { image, referenceType: "asset" } : void 0;
3054
+ return image != null ? { image } : void 0;
3040
3055
  }
3041
3056
  var GoogleGenerativeAIVideoModel = class {
3042
3057
  constructor(modelId, config) {