@ai-sdk/google 2.0.17 → 2.1.0-beta.1

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
@@ -2,13 +2,9 @@
2
2
  import {
3
3
  generateId as generateId2,
4
4
  loadApiKey,
5
- withoutTrailingSlash,
6
- withUserAgentSuffix
5
+ withoutTrailingSlash
7
6
  } from "@ai-sdk/provider-utils";
8
7
 
9
- // src/version.ts
10
- var VERSION = true ? "2.0.17" : "0.0.0-test";
11
-
12
8
  // src/google-generative-ai-embedding-model.ts
13
9
  import {
14
10
  TooManyEmbeddingValuesForCallError
@@ -204,12 +200,9 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
204
200
  enum: enumValues
205
201
  } = jsonSchema;
206
202
  const result = {};
207
- if (description)
208
- result.description = description;
209
- if (required)
210
- result.required = required;
211
- if (format)
212
- result.format = format;
203
+ if (description) result.description = description;
204
+ if (required) result.required = required;
205
+ if (format) result.format = format;
213
206
  if (constValue !== void 0) {
214
207
  result.enum = [constValue];
215
208
  }
@@ -847,7 +840,7 @@ var GoogleGenerativeAILanguageModel = class {
847
840
  };
848
841
  }
849
842
  async doGenerate(options) {
850
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
843
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
851
844
  const { args, warnings } = await this.getArgs(options);
852
845
  const body = JSON.stringify(args);
853
846
  const mergedHeaders = combineHeaders2(
@@ -943,10 +936,9 @@ var GoogleGenerativeAILanguageModel = class {
943
936
  warnings,
944
937
  providerMetadata: {
945
938
  google: {
946
- promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
947
- groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
948
- urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
949
- safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
939
+ groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
940
+ urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
941
+ safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
950
942
  usageMetadata: usageMetadata != null ? usageMetadata : null
951
943
  }
952
944
  },
@@ -997,7 +989,7 @@ var GoogleGenerativeAILanguageModel = class {
997
989
  controller.enqueue({ type: "stream-start", warnings });
998
990
  },
999
991
  transform(chunk, controller) {
1000
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
992
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1001
993
  if (options.includeRawChunks) {
1002
994
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1003
995
  }
@@ -1171,10 +1163,9 @@ var GoogleGenerativeAILanguageModel = class {
1171
1163
  });
1172
1164
  providerMetadata = {
1173
1165
  google: {
1174
- promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
1175
- groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
1176
- urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
1177
- safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null
1166
+ groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
1167
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
1168
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
1178
1169
  }
1179
1170
  };
1180
1171
  if (usageMetadata != null) {
@@ -1302,11 +1293,7 @@ var responseSchema = z7.object({
1302
1293
  urlContextMetadata: urlContextMetadataSchema.nullish()
1303
1294
  })
1304
1295
  ),
1305
- usageMetadata: usageSchema.nullish(),
1306
- promptFeedback: z7.object({
1307
- blockReason: z7.string().nullish(),
1308
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1309
- }).nullish()
1296
+ usageMetadata: usageSchema.nullish()
1310
1297
  });
1311
1298
  var chunkSchema = z7.object({
1312
1299
  candidates: z7.array(
@@ -1318,11 +1305,7 @@ var chunkSchema = z7.object({
1318
1305
  urlContextMetadata: urlContextMetadataSchema.nullish()
1319
1306
  })
1320
1307
  ).nullish(),
1321
- usageMetadata: usageSchema.nullish(),
1322
- promptFeedback: z7.object({
1323
- blockReason: z7.string().nullish(),
1324
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1325
- }).nullish()
1308
+ usageMetadata: usageSchema.nullish()
1326
1309
  });
1327
1310
 
1328
1311
  // src/tool/code-execution.ts
@@ -1478,17 +1461,14 @@ var googleImageProviderOptionsSchema = z9.object({
1478
1461
  function createGoogleGenerativeAI(options = {}) {
1479
1462
  var _a;
1480
1463
  const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1481
- const getHeaders = () => withUserAgentSuffix(
1482
- {
1483
- "x-goog-api-key": loadApiKey({
1484
- apiKey: options.apiKey,
1485
- environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1486
- description: "Google Generative AI"
1487
- }),
1488
- ...options.headers
1489
- },
1490
- `ai-sdk/google/${VERSION}`
1491
- );
1464
+ const getHeaders = () => ({
1465
+ "x-goog-api-key": loadApiKey({
1466
+ apiKey: options.apiKey,
1467
+ environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1468
+ description: "Google Generative AI"
1469
+ }),
1470
+ ...options.headers
1471
+ });
1492
1472
  const createChatModel = (modelId) => {
1493
1473
  var _a2;
1494
1474
  return new GoogleGenerativeAILanguageModel(modelId, {
@@ -1544,7 +1524,6 @@ function createGoogleGenerativeAI(options = {}) {
1544
1524
  }
1545
1525
  var google = createGoogleGenerativeAI();
1546
1526
  export {
1547
- VERSION,
1548
1527
  createGoogleGenerativeAI,
1549
1528
  google
1550
1529
  };