@ai-sdk/google 2.0.14 → 2.0.16

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,17 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 2.0.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 322901b: feat: add provider version to user-agent header
8
+
9
+ ## 2.0.15
10
+
11
+ ### Patch Changes
12
+
13
+ - 967c463: add promptFeedback outputs
14
+
3
15
  ## 2.0.14
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -240,4 +240,6 @@ Default Google Generative AI provider instance.
240
240
  */
241
241
  declare const google: GoogleGenerativeAIProvider;
242
242
 
243
- export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
243
+ declare const VERSION: string;
244
+
245
+ export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, VERSION, createGoogleGenerativeAI, google };
package/dist/index.d.ts CHANGED
@@ -240,4 +240,6 @@ Default Google Generative AI provider instance.
240
240
  */
241
241
  declare const google: GoogleGenerativeAIProvider;
242
242
 
243
- export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
243
+ declare const VERSION: string;
244
+
245
+ export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, VERSION, createGoogleGenerativeAI, google };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ VERSION: () => VERSION,
23
24
  createGoogleGenerativeAI: () => createGoogleGenerativeAI,
24
25
  google: () => google
25
26
  });
@@ -28,6 +29,9 @@ module.exports = __toCommonJS(src_exports);
28
29
  // src/google-provider.ts
29
30
  var import_provider_utils9 = require("@ai-sdk/provider-utils");
30
31
 
32
+ // src/version.ts
33
+ var VERSION = true ? "2.0.16" : "0.0.0-test";
34
+
31
35
  // src/google-generative-ai-embedding-model.ts
32
36
  var import_provider = require("@ai-sdk/provider");
33
37
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
@@ -846,7 +850,7 @@ var GoogleGenerativeAILanguageModel = class {
846
850
  };
847
851
  }
848
852
  async doGenerate(options) {
849
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
853
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
850
854
  const { args, warnings } = await this.getArgs(options);
851
855
  const body = JSON.stringify(args);
852
856
  const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
@@ -942,9 +946,10 @@ var GoogleGenerativeAILanguageModel = class {
942
946
  warnings,
943
947
  providerMetadata: {
944
948
  google: {
945
- groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
946
- urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
947
- safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
949
+ promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
950
+ groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
951
+ urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
952
+ safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
948
953
  usageMetadata: usageMetadata != null ? usageMetadata : null
949
954
  }
950
955
  },
@@ -995,7 +1000,7 @@ var GoogleGenerativeAILanguageModel = class {
995
1000
  controller.enqueue({ type: "stream-start", warnings });
996
1001
  },
997
1002
  transform(chunk, controller) {
998
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1003
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
999
1004
  if (options.includeRawChunks) {
1000
1005
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1001
1006
  }
@@ -1169,9 +1174,10 @@ var GoogleGenerativeAILanguageModel = class {
1169
1174
  });
1170
1175
  providerMetadata = {
1171
1176
  google: {
1172
- groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
1173
- urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
1174
- safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
1177
+ promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
1178
+ groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
1179
+ urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
1180
+ safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null
1175
1181
  }
1176
1182
  };
1177
1183
  if (usageMetadata != null) {
@@ -1299,7 +1305,11 @@ var responseSchema = import_v47.z.object({
1299
1305
  urlContextMetadata: urlContextMetadataSchema.nullish()
1300
1306
  })
1301
1307
  ),
1302
- usageMetadata: usageSchema.nullish()
1308
+ usageMetadata: usageSchema.nullish(),
1309
+ promptFeedback: import_v47.z.object({
1310
+ blockReason: import_v47.z.string().nullish(),
1311
+ safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
1312
+ }).nullish()
1303
1313
  });
1304
1314
  var chunkSchema = import_v47.z.object({
1305
1315
  candidates: import_v47.z.array(
@@ -1311,7 +1321,11 @@ var chunkSchema = import_v47.z.object({
1311
1321
  urlContextMetadata: urlContextMetadataSchema.nullish()
1312
1322
  })
1313
1323
  ).nullish(),
1314
- usageMetadata: usageSchema.nullish()
1324
+ usageMetadata: usageSchema.nullish(),
1325
+ promptFeedback: import_v47.z.object({
1326
+ blockReason: import_v47.z.string().nullish(),
1327
+ safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
1328
+ }).nullish()
1315
1329
  });
1316
1330
 
1317
1331
  // src/tool/code-execution.ts
@@ -1461,14 +1475,17 @@ var googleImageProviderOptionsSchema = import_v49.z.object({
1461
1475
  function createGoogleGenerativeAI(options = {}) {
1462
1476
  var _a;
1463
1477
  const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1464
- const getHeaders = () => ({
1465
- "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1466
- apiKey: options.apiKey,
1467
- environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1468
- description: "Google Generative AI"
1469
- }),
1470
- ...options.headers
1471
- });
1478
+ const getHeaders = () => (0, import_provider_utils9.withUserAgentSuffix)(
1479
+ {
1480
+ "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1481
+ apiKey: options.apiKey,
1482
+ environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1483
+ description: "Google Generative AI"
1484
+ }),
1485
+ ...options.headers
1486
+ },
1487
+ `ai-sdk/google/${VERSION}`
1488
+ );
1472
1489
  const createChatModel = (modelId) => {
1473
1490
  var _a2;
1474
1491
  return new GoogleGenerativeAILanguageModel(modelId, {
@@ -1525,6 +1542,7 @@ function createGoogleGenerativeAI(options = {}) {
1525
1542
  var google = createGoogleGenerativeAI();
1526
1543
  // Annotate the CommonJS export names for ESM import in node:
1527
1544
  0 && (module.exports = {
1545
+ VERSION,
1528
1546
  createGoogleGenerativeAI,
1529
1547
  google
1530
1548
  });