@ai-sdk/amazon-bedrock 4.0.174 → 4.0.176
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 +19 -0
- package/dist/anthropic/index.d.mts +3 -1
- package/dist/anthropic/index.d.ts +3 -1
- package/dist/anthropic/index.js +59 -24
- package/dist/anthropic/index.js.map +1 -1
- package/dist/anthropic/index.mjs +53 -16
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +67 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -27
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/docs/08-amazon-bedrock.mdx +7 -0
- package/package.json +5 -5
- package/src/anthropic/bedrock-anthropic-provider.ts +13 -7
- package/src/bedrock-provider.ts +22 -12
- package/src/resolve-bedrock-base-url.ts +51 -0
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
|
|
3
3
|
import {
|
|
4
4
|
generateId,
|
|
5
|
-
loadOptionalSetting,
|
|
5
|
+
loadOptionalSetting as loadOptionalSetting2,
|
|
6
6
|
loadSetting,
|
|
7
|
-
withoutTrailingSlash,
|
|
8
7
|
withUserAgentSuffix as withUserAgentSuffix2
|
|
9
8
|
} from "@ai-sdk/provider-utils";
|
|
10
9
|
|
|
@@ -2366,7 +2365,7 @@ import {
|
|
|
2366
2365
|
import { AwsV4Signer } from "aws4fetch";
|
|
2367
2366
|
|
|
2368
2367
|
// src/version.ts
|
|
2369
|
-
var VERSION = true ? "4.0.
|
|
2368
|
+
var VERSION = true ? "4.0.176" : "0.0.0-test";
|
|
2370
2369
|
|
|
2371
2370
|
// src/bedrock-sigv4-fetch.ts
|
|
2372
2371
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
|
@@ -2575,9 +2574,47 @@ var BedrockRerankingModel = class {
|
|
|
2575
2574
|
}
|
|
2576
2575
|
};
|
|
2577
2576
|
|
|
2577
|
+
// src/resolve-bedrock-base-url.ts
|
|
2578
|
+
import {
|
|
2579
|
+
loadOptionalSetting,
|
|
2580
|
+
withoutTrailingSlash
|
|
2581
|
+
} from "@ai-sdk/provider-utils";
|
|
2582
|
+
var AWS_PARTITION_DNS_SUFFIXES = [
|
|
2583
|
+
{ regionPrefix: "cn-", dnsSuffix: "amazonaws.com.cn" },
|
|
2584
|
+
{ regionPrefix: "us-iso-", dnsSuffix: "c2s.ic.gov" },
|
|
2585
|
+
{ regionPrefix: "us-isob-", dnsSuffix: "sc2s.sgov.gov" },
|
|
2586
|
+
{ regionPrefix: "eu-isoe-", dnsSuffix: "cloud.adc-e.uk" },
|
|
2587
|
+
{ regionPrefix: "us-isof-", dnsSuffix: "csp.hci.ic.gov" },
|
|
2588
|
+
{ regionPrefix: "eusc-", dnsSuffix: "amazonaws.eu" }
|
|
2589
|
+
];
|
|
2590
|
+
function resolveBedrockBaseURL({
|
|
2591
|
+
baseURL,
|
|
2592
|
+
getRegion,
|
|
2593
|
+
service,
|
|
2594
|
+
serviceEndpointUrlEnvironmentVariableName
|
|
2595
|
+
}) {
|
|
2596
|
+
var _a, _b, _c, _d, _e;
|
|
2597
|
+
const resolvedBaseURL = (_a = baseURL != null ? baseURL : loadOptionalSetting({
|
|
2598
|
+
settingValue: void 0,
|
|
2599
|
+
environmentVariableName: serviceEndpointUrlEnvironmentVariableName
|
|
2600
|
+
})) != null ? _a : loadOptionalSetting({
|
|
2601
|
+
settingValue: void 0,
|
|
2602
|
+
environmentVariableName: "AWS_ENDPOINT_URL"
|
|
2603
|
+
});
|
|
2604
|
+
if (resolvedBaseURL != null) {
|
|
2605
|
+
return (_b = withoutTrailingSlash(resolvedBaseURL)) != null ? _b : resolvedBaseURL;
|
|
2606
|
+
}
|
|
2607
|
+
const region = getRegion();
|
|
2608
|
+
const dnsSuffix = (_d = (_c = AWS_PARTITION_DNS_SUFFIXES.find(
|
|
2609
|
+
({ regionPrefix }) => region.startsWith(regionPrefix)
|
|
2610
|
+
)) == null ? void 0 : _c.dnsSuffix) != null ? _d : "amazonaws.com";
|
|
2611
|
+
const generatedBaseURL = `https://${service}.${region}.${dnsSuffix}`;
|
|
2612
|
+
return (_e = withoutTrailingSlash(generatedBaseURL)) != null ? _e : generatedBaseURL;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2578
2615
|
// src/bedrock-provider.ts
|
|
2579
2616
|
function createAmazonBedrock(options = {}) {
|
|
2580
|
-
const rawApiKey =
|
|
2617
|
+
const rawApiKey = loadOptionalSetting2({
|
|
2581
2618
|
settingValue: options.apiKey,
|
|
2582
2619
|
environmentVariableName: "AWS_BEARER_TOKEN_BEDROCK"
|
|
2583
2620
|
});
|
|
@@ -2617,7 +2654,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
2617
2654
|
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
2618
2655
|
description: "AWS secret access key"
|
|
2619
2656
|
}),
|
|
2620
|
-
sessionToken: options.accessKeyId != null && options.secretAccessKey != null ? options.sessionToken :
|
|
2657
|
+
sessionToken: options.accessKeyId != null && options.secretAccessKey != null ? options.sessionToken : loadOptionalSetting2({
|
|
2621
2658
|
settingValue: options.sessionToken,
|
|
2622
2659
|
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
2623
2660
|
})
|
|
@@ -2648,28 +2685,28 @@ Original error: ${errorMessage}`
|
|
|
2648
2685
|
const baseHeaders = (_a = options.headers) != null ? _a : {};
|
|
2649
2686
|
return withUserAgentSuffix2(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION}`);
|
|
2650
2687
|
};
|
|
2651
|
-
const getBedrockRuntimeBaseUrl = () => {
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
};
|
|
2662
|
-
const getBedrockAgentRuntimeBaseUrl = () => {
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
};
|
|
2688
|
+
const getBedrockRuntimeBaseUrl = () => resolveBedrockBaseURL({
|
|
2689
|
+
baseURL: options.baseURL,
|
|
2690
|
+
getRegion: () => loadSetting({
|
|
2691
|
+
settingValue: options.region,
|
|
2692
|
+
settingName: "region",
|
|
2693
|
+
environmentVariableName: "AWS_REGION",
|
|
2694
|
+
description: "AWS region"
|
|
2695
|
+
}),
|
|
2696
|
+
service: "bedrock-runtime",
|
|
2697
|
+
serviceEndpointUrlEnvironmentVariableName: "AWS_ENDPOINT_URL_BEDROCK_RUNTIME"
|
|
2698
|
+
});
|
|
2699
|
+
const getBedrockAgentRuntimeBaseUrl = () => resolveBedrockBaseURL({
|
|
2700
|
+
baseURL: options.baseURL,
|
|
2701
|
+
getRegion: () => loadSetting({
|
|
2702
|
+
settingValue: options.region,
|
|
2703
|
+
settingName: "region",
|
|
2704
|
+
environmentVariableName: "AWS_REGION",
|
|
2705
|
+
description: "AWS region"
|
|
2706
|
+
}),
|
|
2707
|
+
service: "bedrock-agent-runtime",
|
|
2708
|
+
serviceEndpointUrlEnvironmentVariableName: "AWS_ENDPOINT_URL_BEDROCK_AGENT_RUNTIME"
|
|
2709
|
+
});
|
|
2673
2710
|
const createChatModel = (modelId) => new BedrockChatLanguageModel(modelId, {
|
|
2674
2711
|
baseUrl: getBedrockRuntimeBaseUrl,
|
|
2675
2712
|
headers: getHeaders,
|