@ai-sdk/google 3.0.0-beta.53 → 3.0.0-beta.55

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 ? "3.0.0-beta.53" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.0-beta.55" : "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
  }
@@ -378,11 +380,6 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
378
380
  };
379
381
  }
380
382
  case "file": {
381
- if (part.mediaType !== "image/png") {
382
- throw new UnsupportedFunctionalityError({
383
- functionality: "Only PNG images are supported in assistant messages"
384
- });
385
- }
386
383
  if (part.data instanceof URL) {
387
384
  throw new UnsupportedFunctionalityError({
388
385
  functionality: "File data URLs in assistant messages are not supported"
@@ -392,7 +389,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
392
389
  inlineData: {
393
390
  mimeType: part.mediaType,
394
391
  data: convertToBase64(part.data)
395
- }
392
+ },
393
+ thoughtSignature
396
394
  };
397
395
  }
398
396
  case "tool-call": {
@@ -726,7 +724,7 @@ function prepareTools({
726
724
  }
727
725
  if (toolChoice == null) {
728
726
  return {
729
- tools: { functionDeclarations },
727
+ tools: [{ functionDeclarations }],
730
728
  toolConfig: void 0,
731
729
  toolWarnings
732
730
  };
@@ -735,25 +733,25 @@ function prepareTools({
735
733
  switch (type) {
736
734
  case "auto":
737
735
  return {
738
- tools: { functionDeclarations },
736
+ tools: [{ functionDeclarations }],
739
737
  toolConfig: { functionCallingConfig: { mode: "AUTO" } },
740
738
  toolWarnings
741
739
  };
742
740
  case "none":
743
741
  return {
744
- tools: { functionDeclarations },
742
+ tools: [{ functionDeclarations }],
745
743
  toolConfig: { functionCallingConfig: { mode: "NONE" } },
746
744
  toolWarnings
747
745
  };
748
746
  case "required":
749
747
  return {
750
- tools: { functionDeclarations },
748
+ tools: [{ functionDeclarations }],
751
749
  toolConfig: { functionCallingConfig: { mode: "ANY" } },
752
750
  toolWarnings
753
751
  };
754
752
  case "tool":
755
753
  return {
756
- tools: { functionDeclarations },
754
+ tools: [{ functionDeclarations }],
757
755
  toolConfig: {
758
756
  functionCallingConfig: {
759
757
  mode: "ANY",
@@ -969,7 +967,8 @@ var GoogleGenerativeAILanguageModel = class {
969
967
  content.push({
970
968
  type: "file",
971
969
  data: part.inlineData.data,
972
- mediaType: part.inlineData.mimeType
970
+ mediaType: part.inlineData.mimeType,
971
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
973
972
  });
974
973
  }
975
974
  }
@@ -1170,11 +1169,7 @@ var GoogleGenerativeAILanguageModel = class {
1170
1169
  } : void 0
1171
1170
  });
1172
1171
  }
1173
- }
1174
- }
1175
- const inlineDataParts = getInlineDataParts(content.parts);
1176
- if (inlineDataParts != null) {
1177
- for (const part of inlineDataParts) {
1172
+ } else if ("inlineData" in part) {
1178
1173
  controller.enqueue({
1179
1174
  type: "file",
1180
1175
  mediaType: part.inlineData.mimeType,
@@ -1276,11 +1271,6 @@ function getToolCallsFromParts({
1276
1271
  providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1277
1272
  }));
1278
1273
  }
1279
- function getInlineDataParts(parts) {
1280
- return parts == null ? void 0 : parts.filter(
1281
- (part) => "inlineData" in part
1282
- );
1283
- }
1284
1274
  function extractSources({
1285
1275
  groundingMetadata,
1286
1276
  generateId: generateId3
@@ -1394,7 +1384,8 @@ var getContentSchema = () => z5.object({
1394
1384
  inlineData: z5.object({
1395
1385
  mimeType: z5.string(),
1396
1386
  data: z5.string()
1397
- })
1387
+ }),
1388
+ thoughtSignature: z5.string().nullish()
1398
1389
  }),
1399
1390
  z5.object({
1400
1391
  executableCode: z5.object({