@ai-sdk/google 4.0.0-canary.50 → 4.0.0-canary.51

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,14 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.0-canary.51
4
+
5
+ ### Patch Changes
6
+
7
+ - 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
8
+ - Updated dependencies [5463d0d]
9
+ - @ai-sdk/provider-utils@5.0.0-canary.32
10
+ - @ai-sdk/provider@4.0.0-canary.16
11
+
3
12
  ## 4.0.0-canary.50
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "4.0.0-canary.50" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0-canary.51" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -425,6 +425,7 @@ import {
425
425
  } from "@ai-sdk/provider";
426
426
  import {
427
427
  convertToBase64,
428
+ getTopLevelMediaType,
428
429
  isFullMediaType,
429
430
  resolveFullMediaType,
430
431
  resolveProviderReference
@@ -461,21 +462,23 @@ function appendToolResultParts(parts, toolName, outputValue) {
461
462
  responseTextParts.push(contentPart.text);
462
463
  break;
463
464
  }
464
- case "file-data": {
465
- functionResponseParts.push({
466
- inlineData: {
467
- mimeType: contentPart.mediaType,
468
- data: contentPart.data
465
+ case "file": {
466
+ if (contentPart.data.type === "data") {
467
+ functionResponseParts.push({
468
+ inlineData: {
469
+ mimeType: resolveFullMediaType({ part: contentPart }),
470
+ data: convertToBase64(contentPart.data.data)
471
+ }
472
+ });
473
+ } else if (contentPart.data.type === "url") {
474
+ const functionResponsePart = convertUrlToolResultPart(
475
+ contentPart.data.url.toString()
476
+ );
477
+ if (functionResponsePart != null) {
478
+ functionResponseParts.push(functionResponsePart);
479
+ } else {
480
+ responseTextParts.push(JSON.stringify(contentPart));
469
481
  }
470
- });
471
- break;
472
- }
473
- case "file-url": {
474
- const functionResponsePart = convertUrlToolResultPart(
475
- contentPart.url
476
- );
477
- if (functionResponsePart != null) {
478
- functionResponseParts.push(functionResponsePart);
479
482
  } else {
480
483
  responseTextParts.push(JSON.stringify(contentPart));
481
484
  }
@@ -512,13 +515,13 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
512
515
  }
513
516
  });
514
517
  break;
515
- case "file-data":
516
- if (contentPart.mediaType.startsWith("image/")) {
518
+ case "file": {
519
+ if (contentPart.data.type === "data" && getTopLevelMediaType(contentPart.mediaType) === "image") {
517
520
  parts.push(
518
521
  {
519
522
  inlineData: {
520
- mimeType: contentPart.mediaType,
521
- data: contentPart.data
523
+ mimeType: resolveFullMediaType({ part: contentPart }),
524
+ data: convertToBase64(contentPart.data.data)
522
525
  }
523
526
  },
524
527
  {
@@ -529,6 +532,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
529
532
  parts.push({ text: JSON.stringify(contentPart) });
530
533
  }
531
534
  break;
535
+ }
532
536
  default:
533
537
  parts.push({ text: JSON.stringify(contentPart) });
534
538
  break;