@ai-sdk/amazon-bedrock 3.0.130 → 3.0.131
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 +6 -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 +55 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// src/bedrock-provider.ts
|
|
2
2
|
import {
|
|
3
3
|
generateId,
|
|
4
|
-
loadOptionalSetting,
|
|
4
|
+
loadOptionalSetting as loadOptionalSetting2,
|
|
5
5
|
loadSetting,
|
|
6
|
-
withoutTrailingSlash,
|
|
7
6
|
withUserAgentSuffix as withUserAgentSuffix2
|
|
8
7
|
} from "@ai-sdk/provider-utils";
|
|
9
8
|
|
|
10
9
|
// src/version.ts
|
|
11
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.131" : "0.0.0-test";
|
|
12
11
|
|
|
13
12
|
// src/bedrock-provider.ts
|
|
14
13
|
import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
|
|
@@ -1944,9 +1943,47 @@ function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
|
|
|
1944
1943
|
};
|
|
1945
1944
|
}
|
|
1946
1945
|
|
|
1946
|
+
// src/resolve-bedrock-base-url.ts
|
|
1947
|
+
import {
|
|
1948
|
+
loadOptionalSetting,
|
|
1949
|
+
withoutTrailingSlash
|
|
1950
|
+
} from "@ai-sdk/provider-utils";
|
|
1951
|
+
var AWS_PARTITION_DNS_SUFFIXES = [
|
|
1952
|
+
{ regionPrefix: "cn-", dnsSuffix: "amazonaws.com.cn" },
|
|
1953
|
+
{ regionPrefix: "us-iso-", dnsSuffix: "c2s.ic.gov" },
|
|
1954
|
+
{ regionPrefix: "us-isob-", dnsSuffix: "sc2s.sgov.gov" },
|
|
1955
|
+
{ regionPrefix: "eu-isoe-", dnsSuffix: "cloud.adc-e.uk" },
|
|
1956
|
+
{ regionPrefix: "us-isof-", dnsSuffix: "csp.hci.ic.gov" },
|
|
1957
|
+
{ regionPrefix: "eusc-", dnsSuffix: "amazonaws.eu" }
|
|
1958
|
+
];
|
|
1959
|
+
function resolveBedrockBaseURL({
|
|
1960
|
+
baseURL,
|
|
1961
|
+
getRegion,
|
|
1962
|
+
service,
|
|
1963
|
+
serviceEndpointUrlEnvironmentVariableName
|
|
1964
|
+
}) {
|
|
1965
|
+
var _a, _b, _c, _d, _e;
|
|
1966
|
+
const resolvedBaseURL = (_a = baseURL != null ? baseURL : loadOptionalSetting({
|
|
1967
|
+
settingValue: void 0,
|
|
1968
|
+
environmentVariableName: serviceEndpointUrlEnvironmentVariableName
|
|
1969
|
+
})) != null ? _a : loadOptionalSetting({
|
|
1970
|
+
settingValue: void 0,
|
|
1971
|
+
environmentVariableName: "AWS_ENDPOINT_URL"
|
|
1972
|
+
});
|
|
1973
|
+
if (resolvedBaseURL != null) {
|
|
1974
|
+
return (_b = withoutTrailingSlash(resolvedBaseURL)) != null ? _b : resolvedBaseURL;
|
|
1975
|
+
}
|
|
1976
|
+
const region = getRegion();
|
|
1977
|
+
const dnsSuffix = (_d = (_c = AWS_PARTITION_DNS_SUFFIXES.find(
|
|
1978
|
+
({ regionPrefix }) => region.startsWith(regionPrefix)
|
|
1979
|
+
)) == null ? void 0 : _c.dnsSuffix) != null ? _d : "amazonaws.com";
|
|
1980
|
+
const generatedBaseURL = `https://${service}.${region}.${dnsSuffix}`;
|
|
1981
|
+
return (_e = withoutTrailingSlash(generatedBaseURL)) != null ? _e : generatedBaseURL;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1947
1984
|
// src/bedrock-provider.ts
|
|
1948
1985
|
function createAmazonBedrock(options = {}) {
|
|
1949
|
-
const rawApiKey =
|
|
1986
|
+
const rawApiKey = loadOptionalSetting2({
|
|
1950
1987
|
settingValue: options.apiKey,
|
|
1951
1988
|
environmentVariableName: "AWS_BEARER_TOKEN_BEDROCK"
|
|
1952
1989
|
});
|
|
@@ -1986,7 +2023,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1986
2023
|
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
1987
2024
|
description: "AWS secret access key"
|
|
1988
2025
|
}),
|
|
1989
|
-
sessionToken:
|
|
2026
|
+
sessionToken: loadOptionalSetting2({
|
|
1990
2027
|
settingValue: options.sessionToken,
|
|
1991
2028
|
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
1992
2029
|
})
|
|
@@ -2012,17 +2049,17 @@ Original error: ${errorMessage}`
|
|
|
2012
2049
|
throw error;
|
|
2013
2050
|
}
|
|
2014
2051
|
}, options.fetch);
|
|
2015
|
-
const getBaseUrl = () => {
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
};
|
|
2052
|
+
const getBaseUrl = () => resolveBedrockBaseURL({
|
|
2053
|
+
baseURL: options.baseURL,
|
|
2054
|
+
getRegion: () => loadSetting({
|
|
2055
|
+
settingValue: options.region,
|
|
2056
|
+
settingName: "region",
|
|
2057
|
+
environmentVariableName: "AWS_REGION",
|
|
2058
|
+
description: "AWS region"
|
|
2059
|
+
}),
|
|
2060
|
+
service: "bedrock-runtime",
|
|
2061
|
+
serviceEndpointUrlEnvironmentVariableName: "AWS_ENDPOINT_URL_BEDROCK_RUNTIME"
|
|
2062
|
+
});
|
|
2026
2063
|
const getHeaders = () => {
|
|
2027
2064
|
var _a;
|
|
2028
2065
|
const baseHeaders = (_a = options.headers) != null ? _a : {};
|