@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.
@@ -40,9 +40,10 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
40
40
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
41
  }, z.core.$strip>>>;
42
42
  retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
43
- uri: z.ZodString;
43
+ uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
44
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
45
  text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ fileSearchStore: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
47
  }, z.core.$strip>>>;
47
48
  }, z.core.$strip>>>>;
48
49
  groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
@@ -116,9 +117,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
116
117
  title?: string | null | undefined;
117
118
  } | null | undefined;
118
119
  retrievedContext?: {
119
- uri: string;
120
+ uri?: string | null | undefined;
120
121
  title?: string | null | undefined;
121
122
  text?: string | null | undefined;
123
+ fileSearchStore?: string | null | undefined;
122
124
  } | null | undefined;
123
125
  }[] | null | undefined;
124
126
  groundingSupports?: {
@@ -40,9 +40,10 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
40
40
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
41
  }, z.core.$strip>>>;
42
42
  retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
43
- uri: z.ZodString;
43
+ uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
44
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
45
  text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ fileSearchStore: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
47
  }, z.core.$strip>>>;
47
48
  }, z.core.$strip>>>>;
48
49
  groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
@@ -116,9 +117,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
116
117
  title?: string | null | undefined;
117
118
  } | null | undefined;
118
119
  retrievedContext?: {
119
- uri: string;
120
+ uri?: string | null | undefined;
120
121
  title?: string | null | undefined;
121
122
  text?: string | null | undefined;
123
+ fileSearchStore?: string | null | undefined;
122
124
  } | null | undefined;
123
125
  }[] | null | undefined;
124
126
  groundingSupports?: {
@@ -62,14 +62,16 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
62
62
  }
63
63
  if (type) {
64
64
  if (Array.isArray(type)) {
65
- if (type.includes("null")) {
66
- result.type = type.filter((t) => t !== "null")[0];
67
- result.nullable = true;
65
+ const hasNull = type.includes("null");
66
+ const nonNullTypes = type.filter((t) => t !== "null");
67
+ if (nonNullTypes.length === 0) {
68
+ result.type = "null";
68
69
  } else {
69
- result.type = type;
70
+ result.anyOf = nonNullTypes.map((t) => ({ type: t }));
71
+ if (hasNull) {
72
+ result.nullable = true;
73
+ }
70
74
  }
71
- } else if (type === "null") {
72
- result.type = "null";
73
75
  } else {
74
76
  result.type = type;
75
77
  }
@@ -563,7 +565,7 @@ function prepareTools({
563
565
  }
564
566
  if (toolChoice == null) {
565
567
  return {
566
- tools: { functionDeclarations },
568
+ tools: [{ functionDeclarations }],
567
569
  toolConfig: void 0,
568
570
  toolWarnings
569
571
  };
@@ -572,25 +574,25 @@ function prepareTools({
572
574
  switch (type) {
573
575
  case "auto":
574
576
  return {
575
- tools: { functionDeclarations },
577
+ tools: [{ functionDeclarations }],
576
578
  toolConfig: { functionCallingConfig: { mode: "AUTO" } },
577
579
  toolWarnings
578
580
  };
579
581
  case "none":
580
582
  return {
581
- tools: { functionDeclarations },
583
+ tools: [{ functionDeclarations }],
582
584
  toolConfig: { functionCallingConfig: { mode: "NONE" } },
583
585
  toolWarnings
584
586
  };
585
587
  case "required":
586
588
  return {
587
- tools: { functionDeclarations },
589
+ tools: [{ functionDeclarations }],
588
590
  toolConfig: { functionCallingConfig: { mode: "ANY" } },
589
591
  toolWarnings
590
592
  };
591
593
  case "tool":
592
594
  return {
593
- tools: { functionDeclarations },
595
+ tools: [{ functionDeclarations }],
594
596
  toolConfig: {
595
597
  functionCallingConfig: {
596
598
  mode: "ANY",
@@ -1009,11 +1011,7 @@ var GoogleGenerativeAILanguageModel = class {
1009
1011
  } : void 0
1010
1012
  });
1011
1013
  }
1012
- }
1013
- }
1014
- const inlineDataParts = getInlineDataParts(content.parts);
1015
- if (inlineDataParts != null) {
1016
- for (const part of inlineDataParts) {
1014
+ } else if ("inlineData" in part) {
1017
1015
  controller.enqueue({
1018
1016
  type: "file",
1019
1017
  mediaType: part.inlineData.mimeType,
@@ -1115,16 +1113,11 @@ function getToolCallsFromParts({
1115
1113
  providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1116
1114
  }));
1117
1115
  }
1118
- function getInlineDataParts(parts) {
1119
- return parts == null ? void 0 : parts.filter(
1120
- (part) => "inlineData" in part
1121
- );
1122
- }
1123
1116
  function extractSources({
1124
1117
  groundingMetadata,
1125
1118
  generateId: generateId2
1126
1119
  }) {
1127
- var _a, _b, _c;
1120
+ var _a, _b, _c, _d;
1128
1121
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1129
1122
  return void 0;
1130
1123
  }
@@ -1140,7 +1133,8 @@ function extractSources({
1140
1133
  });
1141
1134
  } else if (chunk.retrievedContext != null) {
1142
1135
  const uri = chunk.retrievedContext.uri;
1143
- if (uri.startsWith("http://") || uri.startsWith("https://")) {
1136
+ const fileSearchStore = chunk.retrievedContext.fileSearchStore;
1137
+ if (uri && (uri.startsWith("http://") || uri.startsWith("https://"))) {
1144
1138
  sources.push({
1145
1139
  type: "source",
1146
1140
  sourceType: "url",
@@ -1148,7 +1142,7 @@ function extractSources({
1148
1142
  url: uri,
1149
1143
  title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1150
1144
  });
1151
- } else {
1145
+ } else if (uri) {
1152
1146
  const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1153
1147
  let mediaType = "application/octet-stream";
1154
1148
  let filename = void 0;
@@ -1178,6 +1172,16 @@ function extractSources({
1178
1172
  title,
1179
1173
  filename
1180
1174
  });
1175
+ } else if (fileSearchStore) {
1176
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1177
+ sources.push({
1178
+ type: "source",
1179
+ sourceType: "document",
1180
+ id: generateId2(),
1181
+ mediaType: "application/octet-stream",
1182
+ title,
1183
+ filename: fileSearchStore.split("/").pop()
1184
+ });
1181
1185
  }
1182
1186
  }
1183
1187
  }
@@ -1191,9 +1195,10 @@ var getGroundingMetadataSchema = () => import_v43.z.object({
1191
1195
  import_v43.z.object({
1192
1196
  web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string().nullish() }).nullish(),
1193
1197
  retrievedContext: import_v43.z.object({
1194
- uri: import_v43.z.string(),
1198
+ uri: import_v43.z.string().nullish(),
1195
1199
  title: import_v43.z.string().nullish(),
1196
- text: import_v43.z.string().nullish()
1200
+ text: import_v43.z.string().nullish(),
1201
+ fileSearchStore: import_v43.z.string().nullish()
1197
1202
  }).nullish()
1198
1203
  })
1199
1204
  ).nullish(),