@ai-sdk/google 2.0.40 → 2.0.42

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.42
4
+
5
+ ### Patch Changes
6
+
7
+ - b60216b: Change streamText loop to merge file part processing into main parts loop
8
+
9
+ ## 2.0.41
10
+
11
+ ### Patch Changes
12
+
13
+ - 3438163: add `gemini-3-pro-preview` and `gemini-3-pro-image-preview` model IDs
14
+
3
15
  ## 2.0.40
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -11,7 +11,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
11
11
  }>;
12
12
  type GoogleErrorData = InferValidator<typeof googleErrorDataSchema>;
13
13
 
14
- type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
14
+ type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
15
15
  declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySchema<{
16
16
  responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
17
17
  thinkingConfig?: {
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
11
11
  }>;
12
12
  type GoogleErrorData = InferValidator<typeof googleErrorDataSchema>;
13
13
 
14
- type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
14
+ type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
15
15
  declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySchema<{
16
16
  responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
17
17
  thinkingConfig?: {
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils13 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "2.0.40" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.42" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -236,14 +236,16 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
236
236
  }
237
237
  if (type) {
238
238
  if (Array.isArray(type)) {
239
- if (type.includes("null")) {
240
- result.type = type.filter((t) => t !== "null")[0];
241
- result.nullable = true;
239
+ const hasNull = type.includes("null");
240
+ const nonNullTypes = type.filter((t) => t !== "null");
241
+ if (nonNullTypes.length === 0) {
242
+ result.type = "null";
242
243
  } else {
243
- result.type = type;
244
+ result.anyOf = nonNullTypes.map((t) => ({ type: t }));
245
+ if (hasNull) {
246
+ result.nullable = true;
247
+ }
244
248
  }
245
- } else if (type === "null") {
246
- result.type = "null";
247
249
  } else {
248
250
  result.type = type;
249
251
  }
@@ -718,7 +720,7 @@ function prepareTools({
718
720
  }
719
721
  if (toolChoice == null) {
720
722
  return {
721
- tools: { functionDeclarations },
723
+ tools: [{ functionDeclarations }],
722
724
  toolConfig: void 0,
723
725
  toolWarnings
724
726
  };
@@ -727,25 +729,25 @@ function prepareTools({
727
729
  switch (type) {
728
730
  case "auto":
729
731
  return {
730
- tools: { functionDeclarations },
732
+ tools: [{ functionDeclarations }],
731
733
  toolConfig: { functionCallingConfig: { mode: "AUTO" } },
732
734
  toolWarnings
733
735
  };
734
736
  case "none":
735
737
  return {
736
- tools: { functionDeclarations },
738
+ tools: [{ functionDeclarations }],
737
739
  toolConfig: { functionCallingConfig: { mode: "NONE" } },
738
740
  toolWarnings
739
741
  };
740
742
  case "required":
741
743
  return {
742
- tools: { functionDeclarations },
744
+ tools: [{ functionDeclarations }],
743
745
  toolConfig: { functionCallingConfig: { mode: "ANY" } },
744
746
  toolWarnings
745
747
  };
746
748
  case "tool":
747
749
  return {
748
- tools: { functionDeclarations },
750
+ tools: [{ functionDeclarations }],
749
751
  toolConfig: {
750
752
  functionCallingConfig: {
751
753
  mode: "ANY",
@@ -1164,11 +1166,7 @@ var GoogleGenerativeAILanguageModel = class {
1164
1166
  } : void 0
1165
1167
  });
1166
1168
  }
1167
- }
1168
- }
1169
- const inlineDataParts = getInlineDataParts(content.parts);
1170
- if (inlineDataParts != null) {
1171
- for (const part of inlineDataParts) {
1169
+ } else if ("inlineData" in part) {
1172
1170
  controller.enqueue({
1173
1171
  type: "file",
1174
1172
  mediaType: part.inlineData.mimeType,
@@ -1270,11 +1268,6 @@ function getToolCallsFromParts({
1270
1268
  providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1271
1269
  }));
1272
1270
  }
1273
- function getInlineDataParts(parts) {
1274
- return parts == null ? void 0 : parts.filter(
1275
- (part) => "inlineData" in part
1276
- );
1277
- }
1278
1271
  function extractSources({
1279
1272
  groundingMetadata,
1280
1273
  generateId: generateId3