@ai-sdk/google 4.0.79 → 4.0.80

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,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.80
4
+
5
+ ### Patch Changes
6
+
7
+ - 8beac3e: fix(google): serialize JSON Schema references in function responses
8
+
3
9
  ## 4.0.79
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -35,7 +35,7 @@ import { google } from '@ai-sdk/google';
35
35
  import { generateText } from 'ai';
36
36
 
37
37
  const { text } = await generateText({
38
- model: google('gemini-2.5-pro'),
38
+ model: google('gemini-3.1-pro-preview'),
39
39
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
40
40
  });
41
41
  ```
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import { Experimental_EvaluationLanguageModel as EvaluationLanguageModel } from "@ai-sdk/provider-utils/experimental-evaluation";
9
9
 
10
10
  // src/version.ts
11
- var VERSION = true ? "4.0.79" : "0.0.0-test";
11
+ var VERSION = true ? "4.0.80" : "0.0.0-test";
12
12
 
13
13
  // src/google-embedding-model.ts
14
14
  import {
@@ -413,6 +413,20 @@ function convertUrlToolResultPart(url) {
413
413
  }
414
414
  };
415
415
  }
416
+ function containsJSONSchemaReference(value) {
417
+ if (Array.isArray(value)) {
418
+ return value.some(containsJSONSchemaReference);
419
+ }
420
+ if (typeof value !== "object" || value === null) {
421
+ return false;
422
+ }
423
+ return Object.entries(value).some(
424
+ ([key, nestedValue]) => key === "$ref" || containsJSONSchemaReference(nestedValue)
425
+ );
426
+ }
427
+ function serializeFunctionResponseContent(value) {
428
+ return containsJSONSchemaReference(value) ? JSON.stringify(value) : value;
429
+ }
416
430
  function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
417
431
  const functionResponseParts = [];
418
432
  const responseTextParts = [];
@@ -821,7 +835,7 @@ function convertToGoogleMessages(prompt, options) {
821
835
  name: part.toolName,
822
836
  response: {
823
837
  name: part.toolName,
824
- content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
838
+ content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : serializeFunctionResponseContent(output.value)
825
839
  }
826
840
  }
827
841
  });