@ai-sdk/google 2.0.78 → 2.0.79

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,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 2.0.79
4
+
5
+ ### Patch Changes
6
+
7
+ - af229e7: Expand standalone Google `threshold` provider options into safety settings.
8
+
3
9
  ## 2.0.78
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "2.0.78" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.79" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -951,6 +951,12 @@ function mapGoogleGenerativeAIFinishReason({
951
951
  }
952
952
 
953
953
  // src/google-generative-ai-language-model.ts
954
+ var configurableSafetySettingCategories = [
955
+ "HARM_CATEGORY_HATE_SPEECH",
956
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
957
+ "HARM_CATEGORY_HARASSMENT",
958
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT"
959
+ ];
954
960
  var GoogleGenerativeAILanguageModel = class {
955
961
  constructor(modelId, config) {
956
962
  this.specificationVersion = "v2";
@@ -981,7 +987,7 @@ var GoogleGenerativeAILanguageModel = class {
981
987
  toolChoice,
982
988
  providerOptions
983
989
  }) {
984
- var _a;
990
+ var _a, _b;
985
991
  const warnings = [];
986
992
  const googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
987
993
  provider: "google",
@@ -1001,6 +1007,11 @@ var GoogleGenerativeAILanguageModel = class {
1001
1007
  if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
1002
1008
  sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
1003
1009
  }
1010
+ const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
1011
+ const safetySettings = (_a = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _a : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
1012
+ category,
1013
+ threshold: safetyThreshold
1014
+ })) : void 0;
1004
1015
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1005
1016
  const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
1006
1017
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
@@ -1033,7 +1044,7 @@ var GoogleGenerativeAILanguageModel = class {
1033
1044
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
1034
1045
  // so this is needed as an escape hatch:
1035
1046
  // TODO convert into provider option
1036
- ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1047
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1037
1048
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
1038
1049
  audioTimestamp: googleOptions.audioTimestamp
1039
1050
  },
@@ -1049,7 +1060,7 @@ var GoogleGenerativeAILanguageModel = class {
1049
1060
  },
1050
1061
  contents,
1051
1062
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1052
- safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1063
+ safetySettings,
1053
1064
  tools: googleTools2,
1054
1065
  toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1055
1066
  ...googleToolConfig,