@ai-sdk/amazon-bedrock 4.0.138 → 4.0.139
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 +11 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +50 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -9
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/package.json +3 -3
- package/src/bedrock-api-types.ts +9 -3
- package/src/bedrock-chat-language-model.ts +1 -1
- package/src/convert-to-bedrock-chat-messages.ts +57 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 4.0.139
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7d821cf: Pass through `s3://` image URLs to Amazon Bedrock Converse as S3 image sources instead of downloading them.
|
|
8
|
+
- b52ca46: Sanitize invalid characters in replayed tool call names before sending conversation history to Amazon Bedrock.
|
|
9
|
+
- Updated dependencies [2f11af1]
|
|
10
|
+
- Updated dependencies [b7afc80]
|
|
11
|
+
- @ai-sdk/openai@3.0.87
|
|
12
|
+
- @ai-sdk/anthropic@3.0.100
|
|
13
|
+
|
|
3
14
|
## 4.0.138
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/anthropic/index.js
CHANGED
|
@@ -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.
|
|
38
|
+
var VERSION = true ? "4.0.139" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "4.0.
|
|
27
|
+
var VERSION = true ? "4.0.139" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/index.js
CHANGED
|
@@ -417,6 +417,32 @@ function pushCachePoint(content, providerMetadata) {
|
|
|
417
417
|
content.push(cachePoint);
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
function sanitizeToolName(toolName) {
|
|
421
|
+
return toolName.replace(/[^a-zA-Z0-9_-]/g, "") || "_";
|
|
422
|
+
}
|
|
423
|
+
function getBedrockImageSource({
|
|
424
|
+
data,
|
|
425
|
+
functionality
|
|
426
|
+
}) {
|
|
427
|
+
if (data instanceof URL) {
|
|
428
|
+
if (data.protocol !== "s3:") {
|
|
429
|
+
throw new import_provider3.UnsupportedFunctionalityError({ functionality });
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
s3Location: {
|
|
433
|
+
uri: data.toString()
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
return { bytes: (0, import_provider_utils3.convertToBase64)(data) };
|
|
438
|
+
}
|
|
439
|
+
function getBedrockImageFormatFromUrl(url) {
|
|
440
|
+
var _a;
|
|
441
|
+
const extension = (_a = url.pathname.split(".").pop()) == null ? void 0 : _a.toLowerCase();
|
|
442
|
+
return getBedrockImageFormat(
|
|
443
|
+
`image/${extension === "jpg" ? "jpeg" : extension}`
|
|
444
|
+
);
|
|
445
|
+
}
|
|
420
446
|
async function shouldEnableCitations(providerMetadata) {
|
|
421
447
|
var _a, _b;
|
|
422
448
|
const bedrockOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
@@ -469,19 +495,22 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
469
495
|
break;
|
|
470
496
|
}
|
|
471
497
|
case "file": {
|
|
472
|
-
if (part.data instanceof URL) {
|
|
473
|
-
throw new import_provider3.UnsupportedFunctionalityError({
|
|
474
|
-
functionality: "File URL data"
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
498
|
if (part.mediaType.startsWith("image/")) {
|
|
478
499
|
bedrockContent.push({
|
|
479
500
|
image: {
|
|
480
501
|
format: getBedrockImageFormat(part.mediaType),
|
|
481
|
-
source: {
|
|
502
|
+
source: getBedrockImageSource({
|
|
503
|
+
data: part.data,
|
|
504
|
+
functionality: "File URL data"
|
|
505
|
+
})
|
|
482
506
|
}
|
|
483
507
|
});
|
|
484
508
|
} else {
|
|
509
|
+
if (part.data instanceof URL) {
|
|
510
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
511
|
+
functionality: "File URL data"
|
|
512
|
+
});
|
|
513
|
+
}
|
|
485
514
|
if (!part.mediaType) {
|
|
486
515
|
throw new import_provider3.UnsupportedFunctionalityError({
|
|
487
516
|
functionality: "file without mime type",
|
|
@@ -535,6 +564,18 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
535
564
|
}
|
|
536
565
|
};
|
|
537
566
|
}
|
|
567
|
+
case "image-url": {
|
|
568
|
+
const url = new URL(contentPart.url);
|
|
569
|
+
return {
|
|
570
|
+
image: {
|
|
571
|
+
format: getBedrockImageFormatFromUrl(url),
|
|
572
|
+
source: getBedrockImageSource({
|
|
573
|
+
data: url,
|
|
574
|
+
functionality: `tool result image URL "${contentPart.url}"`
|
|
575
|
+
})
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
}
|
|
538
579
|
case "file-data": {
|
|
539
580
|
if (!contentPart.mediaType.startsWith("image/")) {
|
|
540
581
|
const enableCitations = await shouldEnableCitations(
|
|
@@ -675,7 +716,7 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
675
716
|
bedrockContent.push({
|
|
676
717
|
toolUse: {
|
|
677
718
|
toolUseId: normalizeToolCallId(part.toolCallId, isMistral),
|
|
678
|
-
name: part.toolName,
|
|
719
|
+
name: sanitizeToolName(part.toolName),
|
|
679
720
|
input: part.input
|
|
680
721
|
}
|
|
681
722
|
});
|
|
@@ -799,7 +840,7 @@ var BedrockChatLanguageModel = class {
|
|
|
799
840
|
this.specificationVersion = "v3";
|
|
800
841
|
this.provider = "amazon-bedrock";
|
|
801
842
|
this.supportedUrls = {
|
|
802
|
-
|
|
843
|
+
"image/*": [/^s3:\/\//]
|
|
803
844
|
};
|
|
804
845
|
}
|
|
805
846
|
async getArgs({
|
|
@@ -2101,7 +2142,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
2101
2142
|
var import_aws4fetch = require("aws4fetch");
|
|
2102
2143
|
|
|
2103
2144
|
// src/version.ts
|
|
2104
|
-
var VERSION = true ? "4.0.
|
|
2145
|
+
var VERSION = true ? "4.0.139" : "0.0.0-test";
|
|
2105
2146
|
|
|
2106
2147
|
// src/bedrock-sigv4-fetch.ts
|
|
2107
2148
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|