@ai-sdk/amazon-bedrock 3.0.0-beta.1 → 3.0.0-beta.10
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 +65 -0
- package/README.md +75 -0
- package/dist/index.d.mts +28 -27
- package/dist/index.d.ts +28 -27
- package/dist/index.js +249 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +174 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
postJsonToApi,
|
|
16
16
|
resolve
|
|
17
17
|
} from "@ai-sdk/provider-utils";
|
|
18
|
-
import { z as z3 } from "zod";
|
|
18
|
+
import { z as z3 } from "zod/v4";
|
|
19
19
|
|
|
20
20
|
// src/bedrock-api-types.ts
|
|
21
21
|
var BEDROCK_CACHE_POINT = {
|
|
@@ -33,16 +33,33 @@ var BEDROCK_STOP_REASONS = [
|
|
|
33
33
|
"tool-calls",
|
|
34
34
|
"tool_use"
|
|
35
35
|
];
|
|
36
|
+
var BEDROCK_IMAGE_MIME_TYPES = {
|
|
37
|
+
"image/jpeg": "jpeg",
|
|
38
|
+
"image/png": "png",
|
|
39
|
+
"image/gif": "gif",
|
|
40
|
+
"image/webp": "webp"
|
|
41
|
+
};
|
|
42
|
+
var BEDROCK_DOCUMENT_MIME_TYPES = {
|
|
43
|
+
"application/pdf": "pdf",
|
|
44
|
+
"text/csv": "csv",
|
|
45
|
+
"application/msword": "doc",
|
|
46
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
47
|
+
"application/vnd.ms-excel": "xls",
|
|
48
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
49
|
+
"text/html": "html",
|
|
50
|
+
"text/plain": "txt",
|
|
51
|
+
"text/markdown": "md"
|
|
52
|
+
};
|
|
36
53
|
|
|
37
54
|
// src/bedrock-chat-options.ts
|
|
38
|
-
import { z } from "zod";
|
|
55
|
+
import { z } from "zod/v4";
|
|
39
56
|
var bedrockProviderOptions = z.object({
|
|
40
57
|
/**
|
|
41
58
|
* Additional inference parameters that the model supports,
|
|
42
59
|
* beyond the base set of inference parameters that Converse
|
|
43
60
|
* supports in the inferenceConfig field
|
|
44
61
|
*/
|
|
45
|
-
additionalModelRequestFields: z.record(z.any()).optional(),
|
|
62
|
+
additionalModelRequestFields: z.record(z.string(), z.any()).optional(),
|
|
46
63
|
reasoningConfig: z.object({
|
|
47
64
|
type: z.union([z.literal("enabled"), z.literal("disabled")]).optional(),
|
|
48
65
|
budgetTokens: z.number().optional()
|
|
@@ -50,7 +67,7 @@ var bedrockProviderOptions = z.object({
|
|
|
50
67
|
});
|
|
51
68
|
|
|
52
69
|
// src/bedrock-error.ts
|
|
53
|
-
import { z as z2 } from "zod";
|
|
70
|
+
import { z as z2 } from "zod/v4";
|
|
54
71
|
var BedrockErrorSchema = z2.object({
|
|
55
72
|
message: z2.string(),
|
|
56
73
|
type: z2.string().nullish()
|
|
@@ -135,14 +152,29 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
|
|
|
135
152
|
import {
|
|
136
153
|
UnsupportedFunctionalityError
|
|
137
154
|
} from "@ai-sdk/provider";
|
|
155
|
+
function promptContainsToolContent(prompt) {
|
|
156
|
+
return prompt.some((message) => {
|
|
157
|
+
if ("content" in message && Array.isArray(message.content)) {
|
|
158
|
+
return message.content.some(
|
|
159
|
+
(part) => part.type === "tool-call" || part.type === "tool-result"
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
138
165
|
function prepareTools({
|
|
139
166
|
tools,
|
|
140
|
-
toolChoice
|
|
167
|
+
toolChoice,
|
|
168
|
+
prompt
|
|
141
169
|
}) {
|
|
142
170
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
171
|
+
const hasToolContent = promptContainsToolContent(prompt);
|
|
143
172
|
if (tools == null) {
|
|
144
173
|
return {
|
|
145
|
-
toolConfig: {
|
|
174
|
+
toolConfig: {
|
|
175
|
+
tools: hasToolContent ? [] : void 0,
|
|
176
|
+
toolChoice: void 0
|
|
177
|
+
},
|
|
146
178
|
toolWarnings: []
|
|
147
179
|
};
|
|
148
180
|
}
|
|
@@ -183,7 +215,10 @@ function prepareTools({
|
|
|
183
215
|
};
|
|
184
216
|
case "none":
|
|
185
217
|
return {
|
|
186
|
-
toolConfig: {
|
|
218
|
+
toolConfig: {
|
|
219
|
+
tools: hasToolContent ? [] : void 0,
|
|
220
|
+
toolChoice: void 0
|
|
221
|
+
},
|
|
187
222
|
toolWarnings
|
|
188
223
|
};
|
|
189
224
|
case "tool":
|
|
@@ -213,7 +248,6 @@ function getCachePoint(providerMetadata) {
|
|
|
213
248
|
return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
|
|
214
249
|
}
|
|
215
250
|
async function convertToBedrockChatMessages(prompt) {
|
|
216
|
-
var _a, _b, _c, _d;
|
|
217
251
|
const blocks = groupIntoBlocks(prompt);
|
|
218
252
|
let system = [];
|
|
219
253
|
const messages = [];
|
|
@@ -260,19 +294,22 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
260
294
|
});
|
|
261
295
|
}
|
|
262
296
|
if (part.mediaType.startsWith("image/")) {
|
|
263
|
-
const bedrockImageFormat = part.mediaType === "image/*" ? void 0 : (_b = (_a = part.mediaType) == null ? void 0 : _a.split("/")) == null ? void 0 : _b[1];
|
|
264
297
|
bedrockContent.push({
|
|
265
298
|
image: {
|
|
266
|
-
format:
|
|
299
|
+
format: getBedrockImageFormat(part.mediaType),
|
|
267
300
|
source: { bytes: convertToBase64(part.data) }
|
|
268
301
|
}
|
|
269
302
|
});
|
|
270
303
|
} else {
|
|
304
|
+
if (!part.mediaType) {
|
|
305
|
+
throw new UnsupportedFunctionalityError2({
|
|
306
|
+
functionality: "file without mime type",
|
|
307
|
+
message: "File mime type is required in user message part content"
|
|
308
|
+
});
|
|
309
|
+
}
|
|
271
310
|
bedrockContent.push({
|
|
272
311
|
document: {
|
|
273
|
-
format: (
|
|
274
|
-
"/"
|
|
275
|
-
)) == null ? void 0 : _d[1],
|
|
312
|
+
format: getBedrockDocumentFormat(part.mediaType),
|
|
276
313
|
name: generateDocumentName(),
|
|
277
314
|
source: { bytes: convertToBase64(part.data) }
|
|
278
315
|
}
|
|
@@ -300,12 +337,9 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
300
337
|
functionality: `media type: ${contentPart.mediaType}`
|
|
301
338
|
});
|
|
302
339
|
}
|
|
303
|
-
const format =
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
functionality: `media type: ${contentPart.mediaType}`
|
|
307
|
-
});
|
|
308
|
-
}
|
|
340
|
+
const format = getBedrockImageFormat(
|
|
341
|
+
contentPart.mediaType
|
|
342
|
+
);
|
|
309
343
|
return {
|
|
310
344
|
image: {
|
|
311
345
|
format,
|
|
@@ -438,8 +472,31 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
438
472
|
}
|
|
439
473
|
return { system, messages };
|
|
440
474
|
}
|
|
441
|
-
function
|
|
442
|
-
|
|
475
|
+
function getBedrockImageFormat(mimeType) {
|
|
476
|
+
if (!mimeType) {
|
|
477
|
+
throw new UnsupportedFunctionalityError2({
|
|
478
|
+
functionality: "image without mime type",
|
|
479
|
+
message: "Image mime type is required in user message part content"
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
const format = BEDROCK_IMAGE_MIME_TYPES[mimeType];
|
|
483
|
+
if (!format) {
|
|
484
|
+
throw new UnsupportedFunctionalityError2({
|
|
485
|
+
functionality: `image mime type: ${mimeType}`,
|
|
486
|
+
message: `Unsupported image mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_IMAGE_MIME_TYPES).join(", ")}`
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return format;
|
|
490
|
+
}
|
|
491
|
+
function getBedrockDocumentFormat(mimeType) {
|
|
492
|
+
const format = BEDROCK_DOCUMENT_MIME_TYPES[mimeType];
|
|
493
|
+
if (!format) {
|
|
494
|
+
throw new UnsupportedFunctionalityError2({
|
|
495
|
+
functionality: `file mime type: ${mimeType}`,
|
|
496
|
+
message: `Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(", ")}`
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return format;
|
|
443
500
|
}
|
|
444
501
|
function trimIfLast(isLastBlock, isLastMessage, isLastContentPart, text) {
|
|
445
502
|
return isLastBlock && isLastMessage && isLastContentPart ? text.trim() : text;
|
|
@@ -535,7 +592,7 @@ var BedrockChatLanguageModel = class {
|
|
|
535
592
|
toolChoice,
|
|
536
593
|
providerOptions
|
|
537
594
|
}) {
|
|
538
|
-
var _a, _b, _c, _d
|
|
595
|
+
var _a, _b, _c, _d;
|
|
539
596
|
const bedrockOptions = (_a = await parseProviderOptions2({
|
|
540
597
|
provider: "bedrock",
|
|
541
598
|
providerOptions,
|
|
@@ -590,7 +647,7 @@ var BedrockChatLanguageModel = class {
|
|
|
590
647
|
}
|
|
591
648
|
bedrockOptions.additionalModelRequestFields = {
|
|
592
649
|
...bedrockOptions.additionalModelRequestFields,
|
|
593
|
-
|
|
650
|
+
thinking: {
|
|
594
651
|
type: (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.type,
|
|
595
652
|
budget_tokens: thinkingBudget
|
|
596
653
|
}
|
|
@@ -612,7 +669,12 @@ var BedrockChatLanguageModel = class {
|
|
|
612
669
|
details: "topP is not supported when thinking is enabled"
|
|
613
670
|
});
|
|
614
671
|
}
|
|
615
|
-
const { toolConfig, toolWarnings } = prepareTools({
|
|
672
|
+
const { toolConfig, toolWarnings } = prepareTools({
|
|
673
|
+
tools,
|
|
674
|
+
toolChoice,
|
|
675
|
+
prompt
|
|
676
|
+
});
|
|
677
|
+
const { reasoningConfig: _, ...filteredBedrockOptions } = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
|
|
616
678
|
return {
|
|
617
679
|
command: {
|
|
618
680
|
system,
|
|
@@ -621,8 +683,8 @@ var BedrockChatLanguageModel = class {
|
|
|
621
683
|
...Object.keys(inferenceConfig).length > 0 && {
|
|
622
684
|
inferenceConfig
|
|
623
685
|
},
|
|
624
|
-
...
|
|
625
|
-
...
|
|
686
|
+
...filteredBedrockOptions,
|
|
687
|
+
...toolConfig.tools !== void 0 ? { toolConfig } : {}
|
|
626
688
|
},
|
|
627
689
|
warnings: [...warnings, ...toolWarnings]
|
|
628
690
|
};
|
|
@@ -1028,9 +1090,9 @@ var BedrockStreamSchema = z3.object({
|
|
|
1028
1090
|
contentBlockStop: z3.object({
|
|
1029
1091
|
contentBlockIndex: z3.number()
|
|
1030
1092
|
}).nullish(),
|
|
1031
|
-
internalServerException: z3.record(z3.unknown()).nullish(),
|
|
1093
|
+
internalServerException: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
1032
1094
|
messageStop: z3.object({
|
|
1033
|
-
additionalModelResponseFields: z3.record(z3.unknown()).nullish(),
|
|
1095
|
+
additionalModelResponseFields: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
1034
1096
|
stopReason: BedrockStopReasonSchema
|
|
1035
1097
|
}).nullish(),
|
|
1036
1098
|
metadata: z3.object({
|
|
@@ -1042,9 +1104,9 @@ var BedrockStreamSchema = z3.object({
|
|
|
1042
1104
|
outputTokens: z3.number()
|
|
1043
1105
|
}).nullish()
|
|
1044
1106
|
}).nullish(),
|
|
1045
|
-
modelStreamErrorException: z3.record(z3.unknown()).nullish(),
|
|
1046
|
-
throttlingException: z3.record(z3.unknown()).nullish(),
|
|
1047
|
-
validationException: z3.record(z3.unknown()).nullish()
|
|
1107
|
+
modelStreamErrorException: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
1108
|
+
throttlingException: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
1109
|
+
validationException: z3.record(z3.string(), z3.unknown()).nullish()
|
|
1048
1110
|
});
|
|
1049
1111
|
var bedrockReasoningMetadataSchema = z3.object({
|
|
1050
1112
|
signature: z3.string().optional(),
|
|
@@ -1065,7 +1127,7 @@ import {
|
|
|
1065
1127
|
} from "@ai-sdk/provider-utils";
|
|
1066
1128
|
|
|
1067
1129
|
// src/bedrock-embedding-options.ts
|
|
1068
|
-
import { z as z4 } from "zod";
|
|
1130
|
+
import { z as z4 } from "zod/v4";
|
|
1069
1131
|
var bedrockEmbeddingProviderOptions = z4.object({
|
|
1070
1132
|
/**
|
|
1071
1133
|
The number of dimensions the resulting output embeddings should have (defaults to 1024).
|
|
@@ -1080,7 +1142,7 @@ var bedrockEmbeddingProviderOptions = z4.object({
|
|
|
1080
1142
|
});
|
|
1081
1143
|
|
|
1082
1144
|
// src/bedrock-embedding-model.ts
|
|
1083
|
-
import { z as z5 } from "zod";
|
|
1145
|
+
import { z as z5 } from "zod/v4";
|
|
1084
1146
|
var BedrockEmbeddingModel = class {
|
|
1085
1147
|
constructor(modelId, config) {
|
|
1086
1148
|
this.modelId = modelId;
|
|
@@ -1162,7 +1224,7 @@ var modelMaxImagesPerCall = {
|
|
|
1162
1224
|
};
|
|
1163
1225
|
|
|
1164
1226
|
// src/bedrock-image-model.ts
|
|
1165
|
-
import { z as z6 } from "zod";
|
|
1227
|
+
import { z as z6 } from "zod/v4";
|
|
1166
1228
|
var BedrockImageModel = class {
|
|
1167
1229
|
constructor(modelId, config) {
|
|
1168
1230
|
this.modelId = modelId;
|
|
@@ -1188,7 +1250,7 @@ var BedrockImageModel = class {
|
|
|
1188
1250
|
headers,
|
|
1189
1251
|
abortSignal
|
|
1190
1252
|
}) {
|
|
1191
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1253
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1192
1254
|
const warnings = [];
|
|
1193
1255
|
const [width, height] = size ? size.split("x").map(Number) : [];
|
|
1194
1256
|
const args = {
|
|
@@ -1197,6 +1259,9 @@ var BedrockImageModel = class {
|
|
|
1197
1259
|
text: prompt,
|
|
1198
1260
|
...((_a = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _a.negativeText) ? {
|
|
1199
1261
|
negativeText: providerOptions.bedrock.negativeText
|
|
1262
|
+
} : {},
|
|
1263
|
+
...((_b = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _b.style) ? {
|
|
1264
|
+
style: providerOptions.bedrock.style
|
|
1200
1265
|
} : {}
|
|
1201
1266
|
},
|
|
1202
1267
|
imageGenerationConfig: {
|
|
@@ -1204,8 +1269,8 @@ var BedrockImageModel = class {
|
|
|
1204
1269
|
...height ? { height } : {},
|
|
1205
1270
|
...seed ? { seed } : {},
|
|
1206
1271
|
...n ? { numberOfImages: n } : {},
|
|
1207
|
-
...((
|
|
1208
|
-
...((
|
|
1272
|
+
...((_c = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _c.quality) ? { quality: providerOptions.bedrock.quality } : {},
|
|
1273
|
+
...((_d = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _d.cfgScale) ? { cfgScale: providerOptions.bedrock.cfgScale } : {}
|
|
1209
1274
|
}
|
|
1210
1275
|
};
|
|
1211
1276
|
if (aspectRatio != void 0) {
|
|
@@ -1215,7 +1280,7 @@ var BedrockImageModel = class {
|
|
|
1215
1280
|
details: "This model does not support aspect ratio. Use `size` instead."
|
|
1216
1281
|
});
|
|
1217
1282
|
}
|
|
1218
|
-
const currentDate = (
|
|
1283
|
+
const currentDate = (_g = (_f = (_e = this.config._internal) == null ? void 0 : _e.currentDate) == null ? void 0 : _f.call(_e)) != null ? _g : /* @__PURE__ */ new Date();
|
|
1219
1284
|
const { value: response, responseHeaders } = await postJsonToApi3({
|
|
1220
1285
|
url: this.getUrl(this.modelId),
|
|
1221
1286
|
headers: await resolve3(
|
|
@@ -1318,10 +1383,28 @@ function prepareBodyString(body) {
|
|
|
1318
1383
|
return JSON.stringify(body);
|
|
1319
1384
|
}
|
|
1320
1385
|
}
|
|
1386
|
+
function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
|
|
1387
|
+
return async (input, init) => {
|
|
1388
|
+
const originalHeaders = extractHeaders(init == null ? void 0 : init.headers);
|
|
1389
|
+
return fetch(input, {
|
|
1390
|
+
...init,
|
|
1391
|
+
headers: removeUndefinedEntries(
|
|
1392
|
+
combineHeaders4(originalHeaders, {
|
|
1393
|
+
Authorization: `Bearer ${apiKey}`
|
|
1394
|
+
})
|
|
1395
|
+
)
|
|
1396
|
+
});
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1321
1399
|
|
|
1322
1400
|
// src/bedrock-provider.ts
|
|
1323
1401
|
function createAmazonBedrock(options = {}) {
|
|
1324
|
-
const
|
|
1402
|
+
const rawApiKey = loadOptionalSetting({
|
|
1403
|
+
settingValue: options.apiKey,
|
|
1404
|
+
environmentVariableName: "AWS_BEARER_TOKEN_BEDROCK"
|
|
1405
|
+
});
|
|
1406
|
+
const apiKey = rawApiKey && rawApiKey.trim().length > 0 ? rawApiKey.trim() : void 0;
|
|
1407
|
+
const fetchFunction = apiKey ? createApiKeyFetchFunction(apiKey, options.fetch) : createSigV4FetchFunction(async () => {
|
|
1325
1408
|
const region = loadSetting({
|
|
1326
1409
|
settingValue: options.region,
|
|
1327
1410
|
settingName: "region",
|
|
@@ -1329,30 +1412,58 @@ function createAmazonBedrock(options = {}) {
|
|
|
1329
1412
|
description: "AWS region"
|
|
1330
1413
|
});
|
|
1331
1414
|
if (options.credentialProvider) {
|
|
1415
|
+
try {
|
|
1416
|
+
return {
|
|
1417
|
+
...await options.credentialProvider(),
|
|
1418
|
+
region
|
|
1419
|
+
};
|
|
1420
|
+
} catch (error) {
|
|
1421
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1422
|
+
throw new Error(
|
|
1423
|
+
`AWS credential provider failed: ${errorMessage}. Please ensure your credential provider returns valid AWS credentials with accessKeyId and secretAccessKey properties.`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
try {
|
|
1332
1428
|
return {
|
|
1333
|
-
|
|
1334
|
-
|
|
1429
|
+
region,
|
|
1430
|
+
accessKeyId: loadSetting({
|
|
1431
|
+
settingValue: options.accessKeyId,
|
|
1432
|
+
settingName: "accessKeyId",
|
|
1433
|
+
environmentVariableName: "AWS_ACCESS_KEY_ID",
|
|
1434
|
+
description: "AWS access key ID"
|
|
1435
|
+
}),
|
|
1436
|
+
secretAccessKey: loadSetting({
|
|
1437
|
+
settingValue: options.secretAccessKey,
|
|
1438
|
+
settingName: "secretAccessKey",
|
|
1439
|
+
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
1440
|
+
description: "AWS secret access key"
|
|
1441
|
+
}),
|
|
1442
|
+
sessionToken: loadOptionalSetting({
|
|
1443
|
+
settingValue: options.sessionToken,
|
|
1444
|
+
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
1445
|
+
})
|
|
1335
1446
|
};
|
|
1447
|
+
} catch (error) {
|
|
1448
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1449
|
+
if (errorMessage.includes("AWS_ACCESS_KEY_ID") || errorMessage.includes("accessKeyId")) {
|
|
1450
|
+
throw new Error(
|
|
1451
|
+
`AWS SigV4 authentication requires AWS credentials. Please provide either:
|
|
1452
|
+
1. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
|
|
1453
|
+
2. Provide accessKeyId and secretAccessKey in options
|
|
1454
|
+
3. Use a credentialProvider function
|
|
1455
|
+
4. Use API key authentication with AWS_BEARER_TOKEN_BEDROCK or apiKey option
|
|
1456
|
+
Original error: ${errorMessage}`
|
|
1457
|
+
);
|
|
1458
|
+
}
|
|
1459
|
+
if (errorMessage.includes("AWS_SECRET_ACCESS_KEY") || errorMessage.includes("secretAccessKey")) {
|
|
1460
|
+
throw new Error(
|
|
1461
|
+
`AWS SigV4 authentication requires both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Please ensure both credentials are provided.
|
|
1462
|
+
Original error: ${errorMessage}`
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
throw error;
|
|
1336
1466
|
}
|
|
1337
|
-
return {
|
|
1338
|
-
region,
|
|
1339
|
-
accessKeyId: loadSetting({
|
|
1340
|
-
settingValue: options.accessKeyId,
|
|
1341
|
-
settingName: "accessKeyId",
|
|
1342
|
-
environmentVariableName: "AWS_ACCESS_KEY_ID",
|
|
1343
|
-
description: "AWS access key ID"
|
|
1344
|
-
}),
|
|
1345
|
-
secretAccessKey: loadSetting({
|
|
1346
|
-
settingValue: options.secretAccessKey,
|
|
1347
|
-
settingName: "secretAccessKey",
|
|
1348
|
-
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
1349
|
-
description: "AWS secret access key"
|
|
1350
|
-
}),
|
|
1351
|
-
sessionToken: loadOptionalSetting({
|
|
1352
|
-
settingValue: options.sessionToken,
|
|
1353
|
-
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
1354
|
-
})
|
|
1355
|
-
};
|
|
1356
1467
|
}, options.fetch);
|
|
1357
1468
|
const getBaseUrl = () => {
|
|
1358
1469
|
var _a, _b;
|
|
@@ -1370,7 +1481,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1370
1481
|
return new BedrockChatLanguageModel(modelId, {
|
|
1371
1482
|
baseUrl: getBaseUrl,
|
|
1372
1483
|
headers: (_a = options.headers) != null ? _a : {},
|
|
1373
|
-
fetch:
|
|
1484
|
+
fetch: fetchFunction,
|
|
1374
1485
|
generateId
|
|
1375
1486
|
});
|
|
1376
1487
|
};
|
|
@@ -1387,7 +1498,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1387
1498
|
return new BedrockEmbeddingModel(modelId, {
|
|
1388
1499
|
baseUrl: getBaseUrl,
|
|
1389
1500
|
headers: (_a = options.headers) != null ? _a : {},
|
|
1390
|
-
fetch:
|
|
1501
|
+
fetch: fetchFunction
|
|
1391
1502
|
});
|
|
1392
1503
|
};
|
|
1393
1504
|
const createImageModel = (modelId) => {
|
|
@@ -1395,7 +1506,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1395
1506
|
return new BedrockImageModel(modelId, {
|
|
1396
1507
|
baseUrl: getBaseUrl,
|
|
1397
1508
|
headers: (_a = options.headers) != null ? _a : {},
|
|
1398
|
-
fetch:
|
|
1509
|
+
fetch: fetchFunction
|
|
1399
1510
|
});
|
|
1400
1511
|
};
|
|
1401
1512
|
provider.languageModel = createChatModel;
|