@ai-sdk/amazon-bedrock 4.0.137 → 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 +21 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +55 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -12
- 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 +4 -6
- package/src/convert-to-bedrock-chat-messages.ts +57 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
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
|
+
|
|
14
|
+
## 4.0.138
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- db8cff6: fix(amazon-bedrock): sanitize unsupported JSON Schema constraints in native Anthropic structured output
|
|
19
|
+
- 3c68a20: fix(amazon-bedrock): encode slashes in ARN model IDs for Converse requests
|
|
20
|
+
- Updated dependencies [db8cff6]
|
|
21
|
+
- Updated dependencies [94d0f86]
|
|
22
|
+
- @ai-sdk/anthropic@3.0.99
|
|
23
|
+
|
|
3
24
|
## 4.0.137
|
|
4
25
|
|
|
5
26
|
### 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
|
@@ -27,11 +27,12 @@ __export(index_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/bedrock-provider.ts
|
|
30
|
-
var
|
|
30
|
+
var import_internal3 = require("@ai-sdk/anthropic/internal");
|
|
31
31
|
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/bedrock-chat-language-model.ts
|
|
34
34
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
35
|
+
var import_internal2 = require("@ai-sdk/anthropic/internal");
|
|
35
36
|
var import_v44 = require("zod/v4");
|
|
36
37
|
|
|
37
38
|
// src/bedrock-api-types.ts
|
|
@@ -416,6 +417,32 @@ function pushCachePoint(content, providerMetadata) {
|
|
|
416
417
|
content.push(cachePoint);
|
|
417
418
|
}
|
|
418
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
|
+
}
|
|
419
446
|
async function shouldEnableCitations(providerMetadata) {
|
|
420
447
|
var _a, _b;
|
|
421
448
|
const bedrockOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
@@ -468,19 +495,22 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
468
495
|
break;
|
|
469
496
|
}
|
|
470
497
|
case "file": {
|
|
471
|
-
if (part.data instanceof URL) {
|
|
472
|
-
throw new import_provider3.UnsupportedFunctionalityError({
|
|
473
|
-
functionality: "File URL data"
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
498
|
if (part.mediaType.startsWith("image/")) {
|
|
477
499
|
bedrockContent.push({
|
|
478
500
|
image: {
|
|
479
501
|
format: getBedrockImageFormat(part.mediaType),
|
|
480
|
-
source: {
|
|
502
|
+
source: getBedrockImageSource({
|
|
503
|
+
data: part.data,
|
|
504
|
+
functionality: "File URL data"
|
|
505
|
+
})
|
|
481
506
|
}
|
|
482
507
|
});
|
|
483
508
|
} else {
|
|
509
|
+
if (part.data instanceof URL) {
|
|
510
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
511
|
+
functionality: "File URL data"
|
|
512
|
+
});
|
|
513
|
+
}
|
|
484
514
|
if (!part.mediaType) {
|
|
485
515
|
throw new import_provider3.UnsupportedFunctionalityError({
|
|
486
516
|
functionality: "file without mime type",
|
|
@@ -534,6 +564,18 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
534
564
|
}
|
|
535
565
|
};
|
|
536
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
|
+
}
|
|
537
579
|
case "file-data": {
|
|
538
580
|
if (!contentPart.mediaType.startsWith("image/")) {
|
|
539
581
|
const enableCitations = await shouldEnableCitations(
|
|
@@ -674,7 +716,7 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
674
716
|
bedrockContent.push({
|
|
675
717
|
toolUse: {
|
|
676
718
|
toolUseId: normalizeToolCallId(part.toolCallId, isMistral),
|
|
677
|
-
name: part.toolName,
|
|
719
|
+
name: sanitizeToolName(part.toolName),
|
|
678
720
|
input: part.input
|
|
679
721
|
}
|
|
680
722
|
});
|
|
@@ -798,7 +840,7 @@ var BedrockChatLanguageModel = class {
|
|
|
798
840
|
this.specificationVersion = "v3";
|
|
799
841
|
this.provider = "amazon-bedrock";
|
|
800
842
|
this.supportedUrls = {
|
|
801
|
-
|
|
843
|
+
"image/*": [/^s3:\/\//]
|
|
802
844
|
};
|
|
803
845
|
}
|
|
804
846
|
async getArgs({
|
|
@@ -979,7 +1021,7 @@ var BedrockChatLanguageModel = class {
|
|
|
979
1021
|
...(_k = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _k.output_config,
|
|
980
1022
|
format: {
|
|
981
1023
|
type: "json_schema",
|
|
982
|
-
schema: responseFormat.schema
|
|
1024
|
+
schema: (0, import_internal2.sanitizeJsonSchema)(responseFormat.schema)
|
|
983
1025
|
}
|
|
984
1026
|
}
|
|
985
1027
|
};
|
|
@@ -1531,8 +1573,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1531
1573
|
};
|
|
1532
1574
|
}
|
|
1533
1575
|
getUrl(modelId) {
|
|
1534
|
-
|
|
1535
|
-
return `${this.config.baseUrl()}/model/${encodedModelId}`;
|
|
1576
|
+
return `${this.config.baseUrl()}/model/${encodeURIComponent(modelId)}`;
|
|
1536
1577
|
}
|
|
1537
1578
|
};
|
|
1538
1579
|
function bedrockChatModelSupportsStructuredOutput(modelId) {
|
|
@@ -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") {
|
|
@@ -2443,7 +2484,7 @@ Original error: ${errorMessage}`
|
|
|
2443
2484
|
provider.imageModel = createImageModel;
|
|
2444
2485
|
provider.reranking = createRerankingModel;
|
|
2445
2486
|
provider.rerankingModel = createRerankingModel;
|
|
2446
|
-
provider.tools =
|
|
2487
|
+
provider.tools = import_internal3.anthropicTools;
|
|
2447
2488
|
return provider;
|
|
2448
2489
|
}
|
|
2449
2490
|
var bedrock = createAmazonBedrock();
|