@ai-sdk/amazon-bedrock 4.0.99 → 4.0.101
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 +14 -0
- package/dist/anthropic/index.js +8 -6
- package/dist/anthropic/index.js.map +1 -1
- package/dist/anthropic/index.mjs +8 -6
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/bedrock-chat-language-model.ts +1 -1
- package/src/bedrock-sigv4-fetch.ts +9 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.101",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@smithy/eventstream-codec": "^4.0.1",
|
|
39
39
|
"@smithy/util-utf8": "^4.0.0",
|
|
40
40
|
"aws4fetch": "^1.0.20",
|
|
41
|
-
"@ai-sdk/anthropic": "3.0.
|
|
41
|
+
"@ai-sdk/anthropic": "3.0.75",
|
|
42
42
|
"@ai-sdk/provider": "3.0.10",
|
|
43
43
|
"@ai-sdk/provider-utils": "4.0.26"
|
|
44
44
|
},
|
|
@@ -1013,7 +1013,7 @@ const BedrockAdditionalModelResponseFieldsSchema = z
|
|
|
1013
1013
|
const BedrockToolUseSchema = z.object({
|
|
1014
1014
|
toolUseId: z.string(),
|
|
1015
1015
|
name: z.string(),
|
|
1016
|
-
input: z.unknown(),
|
|
1016
|
+
input: z.unknown().optional(),
|
|
1017
1017
|
});
|
|
1018
1018
|
|
|
1019
1019
|
const BedrockReasoningTextSchema = z.object({
|
|
@@ -24,12 +24,14 @@ export interface BedrockCredentials {
|
|
|
24
24
|
*/
|
|
25
25
|
export function createSigV4FetchFunction(
|
|
26
26
|
getCredentials: () => BedrockCredentials | PromiseLike<BedrockCredentials>,
|
|
27
|
-
fetch
|
|
27
|
+
fetch?: FetchFunction,
|
|
28
28
|
): FetchFunction {
|
|
29
29
|
return async (
|
|
30
30
|
input: RequestInfo | URL,
|
|
31
31
|
init?: RequestInit,
|
|
32
32
|
): Promise<Response> => {
|
|
33
|
+
// avoid caching globalThis.fetch in case it is patched by other libraries
|
|
34
|
+
const effectiveFetch = fetch ?? globalThis.fetch;
|
|
33
35
|
const request = input instanceof Request ? input : undefined;
|
|
34
36
|
const originalHeaders = combineHeaders(
|
|
35
37
|
normalizeHeaders(request?.headers),
|
|
@@ -51,7 +53,7 @@ export function createSigV4FetchFunction(
|
|
|
51
53
|
const effectiveMethod = init?.method ?? request?.method;
|
|
52
54
|
|
|
53
55
|
if (effectiveMethod?.toUpperCase() !== 'POST' || !effectiveBody) {
|
|
54
|
-
return
|
|
56
|
+
return effectiveFetch(input, {
|
|
55
57
|
...init,
|
|
56
58
|
headers: headersWithUserAgent as HeadersInit,
|
|
57
59
|
});
|
|
@@ -84,7 +86,7 @@ export function createSigV4FetchFunction(
|
|
|
84
86
|
// Use the combined headers directly as HeadersInit
|
|
85
87
|
const combinedHeaders = combineHeaders(headersWithUserAgent, signedHeaders);
|
|
86
88
|
|
|
87
|
-
return
|
|
89
|
+
return effectiveFetch(input, {
|
|
88
90
|
...init,
|
|
89
91
|
body,
|
|
90
92
|
headers: combinedHeaders as HeadersInit,
|
|
@@ -113,12 +115,14 @@ function prepareBodyString(body: BodyInit | undefined): string {
|
|
|
113
115
|
*/
|
|
114
116
|
export function createApiKeyFetchFunction(
|
|
115
117
|
apiKey: string,
|
|
116
|
-
fetch
|
|
118
|
+
fetch?: FetchFunction,
|
|
117
119
|
): FetchFunction {
|
|
118
120
|
return async (
|
|
119
121
|
input: RequestInfo | URL,
|
|
120
122
|
init?: RequestInit,
|
|
121
123
|
): Promise<Response> => {
|
|
124
|
+
// avoid caching globalThis.fetch in case it is patched by other libraries
|
|
125
|
+
const effectiveFetch = fetch ?? globalThis.fetch;
|
|
122
126
|
const originalHeaders = normalizeHeaders(init?.headers);
|
|
123
127
|
const headersWithUserAgent = withUserAgentSuffix(
|
|
124
128
|
originalHeaders,
|
|
@@ -130,7 +134,7 @@ export function createApiKeyFetchFunction(
|
|
|
130
134
|
Authorization: `Bearer ${apiKey}`,
|
|
131
135
|
});
|
|
132
136
|
|
|
133
|
-
return
|
|
137
|
+
return effectiveFetch(input, {
|
|
134
138
|
...init,
|
|
135
139
|
headers: finalHeaders as HeadersInit,
|
|
136
140
|
});
|