@ai-sdk/amazon-bedrock 4.0.108 → 4.0.110

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,18 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 4.0.110
4
+
5
+ ### Patch Changes
6
+
7
+ - 20971fc: fix(amazon-bedrock): support document files in tool results
8
+
9
+ ## 4.0.109
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [263d3e6]
14
+ - @ai-sdk/anthropic@3.0.80
15
+
3
16
  ## 4.0.108
4
17
 
5
18
  ### Patch Changes
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
35
35
  var import_aws4fetch = require("aws4fetch");
36
36
 
37
37
  // src/version.ts
38
- var VERSION = true ? "4.0.108" : "0.0.0-test";
38
+ var VERSION = true ? "4.0.110" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch) {
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "4.0.108" : "0.0.0-test";
27
+ var VERSION = true ? "4.0.110" : "0.0.0-test";
28
28
 
29
29
  // src/bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch) {
package/dist/index.js CHANGED
@@ -516,32 +516,62 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
516
516
  const output = part.output;
517
517
  switch (output.type) {
518
518
  case "content": {
519
- toolResultContent = output.value.map((contentPart) => {
520
- switch (contentPart.type) {
521
- case "text":
522
- return { text: contentPart.text };
523
- case "image-data":
524
- if (!contentPart.mediaType.startsWith("image/")) {
519
+ toolResultContent = await Promise.all(
520
+ output.value.map(async (contentPart) => {
521
+ switch (contentPart.type) {
522
+ case "text":
523
+ return { text: contentPart.text };
524
+ case "image-data": {
525
+ return {
526
+ image: {
527
+ format: getBedrockImageFormat(
528
+ contentPart.mediaType
529
+ ),
530
+ source: {
531
+ bytes: (0, import_provider_utils3.convertToBase64)(contentPart.data)
532
+ }
533
+ }
534
+ };
535
+ }
536
+ case "file-data": {
537
+ if (!contentPart.mediaType.startsWith("image/")) {
538
+ const enableCitations = await shouldEnableCitations(
539
+ contentPart.providerOptions
540
+ );
541
+ return {
542
+ document: {
543
+ format: getBedrockDocumentFormat(
544
+ contentPart.mediaType
545
+ ),
546
+ name: "filename" in contentPart && contentPart.filename ? (0, import_provider_utils3.stripFileExtension)(contentPart.filename) : generateDocumentName(),
547
+ source: {
548
+ bytes: (0, import_provider_utils3.convertToBase64)(contentPart.data)
549
+ },
550
+ ...enableCitations && {
551
+ citations: { enabled: true }
552
+ }
553
+ }
554
+ };
555
+ }
556
+ return {
557
+ image: {
558
+ format: getBedrockImageFormat(
559
+ contentPart.mediaType
560
+ ),
561
+ source: {
562
+ bytes: (0, import_provider_utils3.convertToBase64)(contentPart.data)
563
+ }
564
+ }
565
+ };
566
+ }
567
+ default: {
525
568
  throw new import_provider3.UnsupportedFunctionalityError({
526
- functionality: `media type: ${contentPart.mediaType}`
569
+ functionality: `unsupported tool content part type: ${contentPart.type}`
527
570
  });
528
571
  }
529
- const format = getBedrockImageFormat(
530
- contentPart.mediaType
531
- );
532
- return {
533
- image: {
534
- format,
535
- source: { bytes: contentPart.data }
536
- }
537
- };
538
- default: {
539
- throw new import_provider3.UnsupportedFunctionalityError({
540
- functionality: `unsupported tool content part type: ${contentPart.type}`
541
- });
542
572
  }
543
- }
544
- });
573
+ })
574
+ );
545
575
  break;
546
576
  }
547
577
  case "text":
@@ -1981,7 +2011,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1981
2011
  var import_aws4fetch = require("aws4fetch");
1982
2012
 
1983
2013
  // src/version.ts
1984
- var VERSION = true ? "4.0.108" : "0.0.0-test";
2014
+ var VERSION = true ? "4.0.110" : "0.0.0-test";
1985
2015
 
1986
2016
  // src/bedrock-sigv4-fetch.ts
1987
2017
  function createSigV4FetchFunction(getCredentials, fetch) {