@ai-sdk/google 2.0.41 → 2.0.43

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 ? "2.0.41" : "0.0.0-test";
10
+ var VERSION = true ? "2.0.43" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -240,14 +240,16 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
240
240
  }
241
241
  if (type) {
242
242
  if (Array.isArray(type)) {
243
- if (type.includes("null")) {
244
- result.type = type.filter((t) => t !== "null")[0];
245
- result.nullable = true;
243
+ const hasNull = type.includes("null");
244
+ const nonNullTypes = type.filter((t) => t !== "null");
245
+ if (nonNullTypes.length === 0) {
246
+ result.type = "null";
246
247
  } else {
247
- result.type = type;
248
+ result.anyOf = nonNullTypes.map((t) => ({ type: t }));
249
+ if (hasNull) {
250
+ result.nullable = true;
251
+ }
248
252
  }
249
- } else if (type === "null") {
250
- result.type = "null";
251
253
  } else {
252
254
  result.type = type;
253
255
  }
@@ -729,7 +731,7 @@ function prepareTools({
729
731
  }
730
732
  if (toolChoice == null) {
731
733
  return {
732
- tools: { functionDeclarations },
734
+ tools: [{ functionDeclarations }],
733
735
  toolConfig: void 0,
734
736
  toolWarnings
735
737
  };
@@ -738,25 +740,25 @@ function prepareTools({
738
740
  switch (type) {
739
741
  case "auto":
740
742
  return {
741
- tools: { functionDeclarations },
743
+ tools: [{ functionDeclarations }],
742
744
  toolConfig: { functionCallingConfig: { mode: "AUTO" } },
743
745
  toolWarnings
744
746
  };
745
747
  case "none":
746
748
  return {
747
- tools: { functionDeclarations },
749
+ tools: [{ functionDeclarations }],
748
750
  toolConfig: { functionCallingConfig: { mode: "NONE" } },
749
751
  toolWarnings
750
752
  };
751
753
  case "required":
752
754
  return {
753
- tools: { functionDeclarations },
755
+ tools: [{ functionDeclarations }],
754
756
  toolConfig: { functionCallingConfig: { mode: "ANY" } },
755
757
  toolWarnings
756
758
  };
757
759
  case "tool":
758
760
  return {
759
- tools: { functionDeclarations },
761
+ tools: [{ functionDeclarations }],
760
762
  toolConfig: {
761
763
  functionCallingConfig: {
762
764
  mode: "ANY",
@@ -1175,11 +1177,7 @@ var GoogleGenerativeAILanguageModel = class {
1175
1177
  } : void 0
1176
1178
  });
1177
1179
  }
1178
- }
1179
- }
1180
- const inlineDataParts = getInlineDataParts(content.parts);
1181
- if (inlineDataParts != null) {
1182
- for (const part of inlineDataParts) {
1180
+ } else if ("inlineData" in part) {
1183
1181
  controller.enqueue({
1184
1182
  type: "file",
1185
1183
  mediaType: part.inlineData.mimeType,
@@ -1281,16 +1279,11 @@ function getToolCallsFromParts({
1281
1279
  providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1282
1280
  }));
1283
1281
  }
1284
- function getInlineDataParts(parts) {
1285
- return parts == null ? void 0 : parts.filter(
1286
- (part) => "inlineData" in part
1287
- );
1288
- }
1289
1282
  function extractSources({
1290
1283
  groundingMetadata,
1291
1284
  generateId: generateId3
1292
1285
  }) {
1293
- var _a, _b, _c;
1286
+ var _a, _b, _c, _d;
1294
1287
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1295
1288
  return void 0;
1296
1289
  }
@@ -1306,7 +1299,8 @@ function extractSources({
1306
1299
  });
1307
1300
  } else if (chunk.retrievedContext != null) {
1308
1301
  const uri = chunk.retrievedContext.uri;
1309
- if (uri.startsWith("http://") || uri.startsWith("https://")) {
1302
+ const fileSearchStore = chunk.retrievedContext.fileSearchStore;
1303
+ if (uri && (uri.startsWith("http://") || uri.startsWith("https://"))) {
1310
1304
  sources.push({
1311
1305
  type: "source",
1312
1306
  sourceType: "url",
@@ -1314,7 +1308,7 @@ function extractSources({
1314
1308
  url: uri,
1315
1309
  title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1316
1310
  });
1317
- } else {
1311
+ } else if (uri) {
1318
1312
  const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1319
1313
  let mediaType = "application/octet-stream";
1320
1314
  let filename = void 0;
@@ -1344,6 +1338,16 @@ function extractSources({
1344
1338
  title,
1345
1339
  filename
1346
1340
  });
1341
+ } else if (fileSearchStore) {
1342
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1343
+ sources.push({
1344
+ type: "source",
1345
+ sourceType: "document",
1346
+ id: generateId3(),
1347
+ mediaType: "application/octet-stream",
1348
+ title,
1349
+ filename: fileSearchStore.split("/").pop()
1350
+ });
1347
1351
  }
1348
1352
  }
1349
1353
  }
@@ -1357,9 +1361,10 @@ var getGroundingMetadataSchema = () => z5.object({
1357
1361
  z5.object({
1358
1362
  web: z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish(),
1359
1363
  retrievedContext: z5.object({
1360
- uri: z5.string(),
1364
+ uri: z5.string().nullish(),
1361
1365
  title: z5.string().nullish(),
1362
- text: z5.string().nullish()
1366
+ text: z5.string().nullish(),
1367
+ fileSearchStore: z5.string().nullish()
1363
1368
  }).nullish()
1364
1369
  })
1365
1370
  ).nullish(),