@ai-sdk/amazon-bedrock 3.0.0-beta.1 → 3.0.0-beta.11
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 +71 -0
- package/README.md +75 -0
- package/dist/index.d.mts +28 -27
- package/dist/index.d.ts +28 -27
- package/dist/index.js +357 -185
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +282 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
30
30
|
|
|
31
31
|
// src/bedrock-chat-language-model.ts
|
|
32
32
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
33
|
-
var
|
|
33
|
+
var import_v43 = require("zod/v4");
|
|
34
34
|
|
|
35
35
|
// src/bedrock-api-types.ts
|
|
36
36
|
var BEDROCK_CACHE_POINT = {
|
|
@@ -48,27 +48,44 @@ var BEDROCK_STOP_REASONS = [
|
|
|
48
48
|
"tool-calls",
|
|
49
49
|
"tool_use"
|
|
50
50
|
];
|
|
51
|
+
var BEDROCK_IMAGE_MIME_TYPES = {
|
|
52
|
+
"image/jpeg": "jpeg",
|
|
53
|
+
"image/png": "png",
|
|
54
|
+
"image/gif": "gif",
|
|
55
|
+
"image/webp": "webp"
|
|
56
|
+
};
|
|
57
|
+
var BEDROCK_DOCUMENT_MIME_TYPES = {
|
|
58
|
+
"application/pdf": "pdf",
|
|
59
|
+
"text/csv": "csv",
|
|
60
|
+
"application/msword": "doc",
|
|
61
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
62
|
+
"application/vnd.ms-excel": "xls",
|
|
63
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
64
|
+
"text/html": "html",
|
|
65
|
+
"text/plain": "txt",
|
|
66
|
+
"text/markdown": "md"
|
|
67
|
+
};
|
|
51
68
|
|
|
52
69
|
// src/bedrock-chat-options.ts
|
|
53
|
-
var
|
|
54
|
-
var bedrockProviderOptions =
|
|
70
|
+
var import_v4 = require("zod/v4");
|
|
71
|
+
var bedrockProviderOptions = import_v4.z.object({
|
|
55
72
|
/**
|
|
56
73
|
* Additional inference parameters that the model supports,
|
|
57
74
|
* beyond the base set of inference parameters that Converse
|
|
58
75
|
* supports in the inferenceConfig field
|
|
59
76
|
*/
|
|
60
|
-
additionalModelRequestFields:
|
|
61
|
-
reasoningConfig:
|
|
62
|
-
type:
|
|
63
|
-
budgetTokens:
|
|
77
|
+
additionalModelRequestFields: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
|
|
78
|
+
reasoningConfig: import_v4.z.object({
|
|
79
|
+
type: import_v4.z.union([import_v4.z.literal("enabled"), import_v4.z.literal("disabled")]).optional(),
|
|
80
|
+
budgetTokens: import_v4.z.number().optional()
|
|
64
81
|
}).optional()
|
|
65
82
|
});
|
|
66
83
|
|
|
67
84
|
// src/bedrock-error.ts
|
|
68
|
-
var
|
|
69
|
-
var BedrockErrorSchema =
|
|
70
|
-
message:
|
|
71
|
-
type:
|
|
85
|
+
var import_v42 = require("zod/v4");
|
|
86
|
+
var BedrockErrorSchema = import_v42.z.object({
|
|
87
|
+
message: import_v42.z.string(),
|
|
88
|
+
type: import_v42.z.string().nullish()
|
|
72
89
|
});
|
|
73
90
|
|
|
74
91
|
// src/bedrock-event-stream-response-handler.ts
|
|
@@ -144,14 +161,29 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
|
|
|
144
161
|
|
|
145
162
|
// src/bedrock-prepare-tools.ts
|
|
146
163
|
var import_provider2 = require("@ai-sdk/provider");
|
|
164
|
+
function promptContainsToolContent(prompt) {
|
|
165
|
+
return prompt.some((message) => {
|
|
166
|
+
if ("content" in message && Array.isArray(message.content)) {
|
|
167
|
+
return message.content.some(
|
|
168
|
+
(part) => part.type === "tool-call" || part.type === "tool-result"
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
147
174
|
function prepareTools({
|
|
148
175
|
tools,
|
|
149
|
-
toolChoice
|
|
176
|
+
toolChoice,
|
|
177
|
+
prompt
|
|
150
178
|
}) {
|
|
151
179
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
180
|
+
const hasToolContent = promptContainsToolContent(prompt);
|
|
152
181
|
if (tools == null) {
|
|
153
182
|
return {
|
|
154
|
-
toolConfig: {
|
|
183
|
+
toolConfig: {
|
|
184
|
+
tools: hasToolContent ? [] : void 0,
|
|
185
|
+
toolChoice: void 0
|
|
186
|
+
},
|
|
155
187
|
toolWarnings: []
|
|
156
188
|
};
|
|
157
189
|
}
|
|
@@ -192,7 +224,10 @@ function prepareTools({
|
|
|
192
224
|
};
|
|
193
225
|
case "none":
|
|
194
226
|
return {
|
|
195
|
-
toolConfig: {
|
|
227
|
+
toolConfig: {
|
|
228
|
+
tools: hasToolContent ? [] : void 0,
|
|
229
|
+
toolChoice: void 0
|
|
230
|
+
},
|
|
196
231
|
toolWarnings
|
|
197
232
|
};
|
|
198
233
|
case "tool":
|
|
@@ -220,7 +255,6 @@ function getCachePoint(providerMetadata) {
|
|
|
220
255
|
return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
|
|
221
256
|
}
|
|
222
257
|
async function convertToBedrockChatMessages(prompt) {
|
|
223
|
-
var _a, _b, _c, _d;
|
|
224
258
|
const blocks = groupIntoBlocks(prompt);
|
|
225
259
|
let system = [];
|
|
226
260
|
const messages = [];
|
|
@@ -267,19 +301,22 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
267
301
|
});
|
|
268
302
|
}
|
|
269
303
|
if (part.mediaType.startsWith("image/")) {
|
|
270
|
-
const bedrockImageFormat = part.mediaType === "image/*" ? void 0 : (_b = (_a = part.mediaType) == null ? void 0 : _a.split("/")) == null ? void 0 : _b[1];
|
|
271
304
|
bedrockContent.push({
|
|
272
305
|
image: {
|
|
273
|
-
format:
|
|
306
|
+
format: getBedrockImageFormat(part.mediaType),
|
|
274
307
|
source: { bytes: (0, import_provider_utils2.convertToBase64)(part.data) }
|
|
275
308
|
}
|
|
276
309
|
});
|
|
277
310
|
} else {
|
|
311
|
+
if (!part.mediaType) {
|
|
312
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
313
|
+
functionality: "file without mime type",
|
|
314
|
+
message: "File mime type is required in user message part content"
|
|
315
|
+
});
|
|
316
|
+
}
|
|
278
317
|
bedrockContent.push({
|
|
279
318
|
document: {
|
|
280
|
-
format: (
|
|
281
|
-
"/"
|
|
282
|
-
)) == null ? void 0 : _d[1],
|
|
319
|
+
format: getBedrockDocumentFormat(part.mediaType),
|
|
283
320
|
name: generateDocumentName(),
|
|
284
321
|
source: { bytes: (0, import_provider_utils2.convertToBase64)(part.data) }
|
|
285
322
|
}
|
|
@@ -307,12 +344,9 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
307
344
|
functionality: `media type: ${contentPart.mediaType}`
|
|
308
345
|
});
|
|
309
346
|
}
|
|
310
|
-
const format =
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
functionality: `media type: ${contentPart.mediaType}`
|
|
314
|
-
});
|
|
315
|
-
}
|
|
347
|
+
const format = getBedrockImageFormat(
|
|
348
|
+
contentPart.mediaType
|
|
349
|
+
);
|
|
316
350
|
return {
|
|
317
351
|
image: {
|
|
318
352
|
format,
|
|
@@ -445,8 +479,31 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
445
479
|
}
|
|
446
480
|
return { system, messages };
|
|
447
481
|
}
|
|
448
|
-
function
|
|
449
|
-
|
|
482
|
+
function getBedrockImageFormat(mimeType) {
|
|
483
|
+
if (!mimeType) {
|
|
484
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
485
|
+
functionality: "image without mime type",
|
|
486
|
+
message: "Image mime type is required in user message part content"
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
const format = BEDROCK_IMAGE_MIME_TYPES[mimeType];
|
|
490
|
+
if (!format) {
|
|
491
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
492
|
+
functionality: `image mime type: ${mimeType}`,
|
|
493
|
+
message: `Unsupported image mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_IMAGE_MIME_TYPES).join(", ")}`
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
return format;
|
|
497
|
+
}
|
|
498
|
+
function getBedrockDocumentFormat(mimeType) {
|
|
499
|
+
const format = BEDROCK_DOCUMENT_MIME_TYPES[mimeType];
|
|
500
|
+
if (!format) {
|
|
501
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
502
|
+
functionality: `file mime type: ${mimeType}`,
|
|
503
|
+
message: `Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(", ")}`
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
return format;
|
|
450
507
|
}
|
|
451
508
|
function trimIfLast(isLastBlock, isLastMessage, isLastContentPart, text) {
|
|
452
509
|
return isLastBlock && isLastMessage && isLastContentPart ? text.trim() : text;
|
|
@@ -542,7 +599,7 @@ var BedrockChatLanguageModel = class {
|
|
|
542
599
|
toolChoice,
|
|
543
600
|
providerOptions
|
|
544
601
|
}) {
|
|
545
|
-
var _a, _b, _c, _d
|
|
602
|
+
var _a, _b, _c, _d;
|
|
546
603
|
const bedrockOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
547
604
|
provider: "bedrock",
|
|
548
605
|
providerOptions,
|
|
@@ -573,13 +630,27 @@ var BedrockChatLanguageModel = class {
|
|
|
573
630
|
setting: "topK"
|
|
574
631
|
});
|
|
575
632
|
}
|
|
576
|
-
if (responseFormat != null && responseFormat.type !== "text") {
|
|
633
|
+
if (responseFormat != null && responseFormat.type !== "text" && responseFormat.type !== "json") {
|
|
577
634
|
warnings.push({
|
|
578
635
|
type: "unsupported-setting",
|
|
579
636
|
setting: "responseFormat",
|
|
580
|
-
details: "
|
|
637
|
+
details: "Only text and json response formats are supported."
|
|
581
638
|
});
|
|
582
639
|
}
|
|
640
|
+
if (tools != null && (responseFormat == null ? void 0 : responseFormat.type) === "json") {
|
|
641
|
+
if (tools.length > 0) {
|
|
642
|
+
warnings.push({
|
|
643
|
+
type: "other",
|
|
644
|
+
message: "JSON response format does not support tools. The provided tools are ignored."
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null ? {
|
|
649
|
+
type: "function",
|
|
650
|
+
name: "json",
|
|
651
|
+
description: "Respond with a JSON object.",
|
|
652
|
+
inputSchema: responseFormat.schema
|
|
653
|
+
} : void 0;
|
|
583
654
|
const { system, messages } = await convertToBedrockChatMessages(prompt);
|
|
584
655
|
const isThinking = ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.type) === "enabled";
|
|
585
656
|
const thinkingBudget = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.budgetTokens;
|
|
@@ -597,7 +668,7 @@ var BedrockChatLanguageModel = class {
|
|
|
597
668
|
}
|
|
598
669
|
bedrockOptions.additionalModelRequestFields = {
|
|
599
670
|
...bedrockOptions.additionalModelRequestFields,
|
|
600
|
-
|
|
671
|
+
thinking: {
|
|
601
672
|
type: (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.type,
|
|
602
673
|
budget_tokens: thinkingBudget
|
|
603
674
|
}
|
|
@@ -619,7 +690,12 @@ var BedrockChatLanguageModel = class {
|
|
|
619
690
|
details: "topP is not supported when thinking is enabled"
|
|
620
691
|
});
|
|
621
692
|
}
|
|
622
|
-
const { toolConfig, toolWarnings } = prepareTools({
|
|
693
|
+
const { toolConfig, toolWarnings } = prepareTools({
|
|
694
|
+
tools: jsonResponseTool != null ? [jsonResponseTool] : tools != null ? tools : [],
|
|
695
|
+
toolChoice: jsonResponseTool != null ? { type: "tool", toolName: jsonResponseTool.name } : toolChoice,
|
|
696
|
+
prompt
|
|
697
|
+
});
|
|
698
|
+
const { reasoningConfig: _, ...filteredBedrockOptions } = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
|
|
623
699
|
return {
|
|
624
700
|
command: {
|
|
625
701
|
system,
|
|
@@ -628,15 +704,20 @@ var BedrockChatLanguageModel = class {
|
|
|
628
704
|
...Object.keys(inferenceConfig).length > 0 && {
|
|
629
705
|
inferenceConfig
|
|
630
706
|
},
|
|
631
|
-
...
|
|
632
|
-
...
|
|
707
|
+
...filteredBedrockOptions,
|
|
708
|
+
...toolConfig.tools !== void 0 ? { toolConfig } : {}
|
|
633
709
|
},
|
|
634
|
-
warnings: [...warnings, ...toolWarnings]
|
|
710
|
+
warnings: [...warnings, ...toolWarnings],
|
|
711
|
+
usesJsonResponseTool: jsonResponseTool != null
|
|
635
712
|
};
|
|
636
713
|
}
|
|
637
714
|
async doGenerate(options) {
|
|
638
715
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
639
|
-
const {
|
|
716
|
+
const {
|
|
717
|
+
command: args,
|
|
718
|
+
warnings,
|
|
719
|
+
usesJsonResponseTool
|
|
720
|
+
} = await this.getArgs(options);
|
|
640
721
|
const url = `${this.getUrl(this.modelId)}/converse`;
|
|
641
722
|
const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
|
|
642
723
|
url,
|
|
@@ -661,7 +742,9 @@ var BedrockChatLanguageModel = class {
|
|
|
661
742
|
const content = [];
|
|
662
743
|
for (const part of response.output.message.content) {
|
|
663
744
|
if (part.text) {
|
|
664
|
-
|
|
745
|
+
if (!usesJsonResponseTool) {
|
|
746
|
+
content.push({ type: "text", text: part.text });
|
|
747
|
+
}
|
|
665
748
|
}
|
|
666
749
|
if (part.reasoningContent) {
|
|
667
750
|
if ("reasoningText" in part.reasoningContent) {
|
|
@@ -690,22 +773,29 @@ var BedrockChatLanguageModel = class {
|
|
|
690
773
|
}
|
|
691
774
|
}
|
|
692
775
|
if (part.toolUse) {
|
|
693
|
-
content.push(
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
776
|
+
content.push(
|
|
777
|
+
// when a json response tool is used, the tool call becomes the text:
|
|
778
|
+
usesJsonResponseTool ? {
|
|
779
|
+
type: "text",
|
|
780
|
+
text: JSON.stringify(part.toolUse.input)
|
|
781
|
+
} : {
|
|
782
|
+
type: "tool-call",
|
|
783
|
+
toolCallId: (_c = (_b = part.toolUse) == null ? void 0 : _b.toolUseId) != null ? _c : this.config.generateId(),
|
|
784
|
+
toolName: (_e = (_d = part.toolUse) == null ? void 0 : _d.name) != null ? _e : `tool-${this.config.generateId()}`,
|
|
785
|
+
input: JSON.stringify((_g = (_f = part.toolUse) == null ? void 0 : _f.input) != null ? _g : "")
|
|
786
|
+
}
|
|
787
|
+
);
|
|
699
788
|
}
|
|
700
789
|
}
|
|
701
|
-
const providerMetadata = response.trace || response.usage ? {
|
|
790
|
+
const providerMetadata = response.trace || response.usage || usesJsonResponseTool ? {
|
|
702
791
|
bedrock: {
|
|
703
792
|
...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
|
|
704
793
|
...((_h = response.usage) == null ? void 0 : _h.cacheWriteInputTokens) != null && {
|
|
705
794
|
usage: {
|
|
706
795
|
cacheWriteInputTokens: response.usage.cacheWriteInputTokens
|
|
707
796
|
}
|
|
708
|
-
}
|
|
797
|
+
},
|
|
798
|
+
...usesJsonResponseTool && { isJsonResponseFromTool: true }
|
|
709
799
|
}
|
|
710
800
|
} : void 0;
|
|
711
801
|
return {
|
|
@@ -728,7 +818,11 @@ var BedrockChatLanguageModel = class {
|
|
|
728
818
|
};
|
|
729
819
|
}
|
|
730
820
|
async doStream(options) {
|
|
731
|
-
const {
|
|
821
|
+
const {
|
|
822
|
+
command: args,
|
|
823
|
+
warnings,
|
|
824
|
+
usesJsonResponseTool
|
|
825
|
+
} = await this.getArgs(options);
|
|
732
826
|
const url = `${this.getUrl(this.modelId)}/converse-stream`;
|
|
733
827
|
const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
|
|
734
828
|
url,
|
|
@@ -807,11 +901,14 @@ var BedrockChatLanguageModel = class {
|
|
|
807
901
|
const trace = value.metadata.trace ? {
|
|
808
902
|
trace: value.metadata.trace
|
|
809
903
|
} : void 0;
|
|
810
|
-
if (cacheUsage || trace) {
|
|
904
|
+
if (cacheUsage || trace || usesJsonResponseTool) {
|
|
811
905
|
providerMetadata = {
|
|
812
906
|
bedrock: {
|
|
813
907
|
...cacheUsage,
|
|
814
|
-
...trace
|
|
908
|
+
...trace,
|
|
909
|
+
...usesJsonResponseTool && {
|
|
910
|
+
isJsonResponseFromTool: true
|
|
911
|
+
}
|
|
815
912
|
}
|
|
816
913
|
};
|
|
817
914
|
}
|
|
@@ -828,16 +925,20 @@ var BedrockChatLanguageModel = class {
|
|
|
828
925
|
const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
|
|
829
926
|
if (contentBlocks[blockIndex] == null) {
|
|
830
927
|
contentBlocks[blockIndex] = { type: "text" };
|
|
928
|
+
if (!usesJsonResponseTool) {
|
|
929
|
+
controller.enqueue({
|
|
930
|
+
type: "text-start",
|
|
931
|
+
id: String(blockIndex)
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
if (!usesJsonResponseTool) {
|
|
831
936
|
controller.enqueue({
|
|
832
|
-
type: "text-
|
|
833
|
-
id: String(blockIndex)
|
|
937
|
+
type: "text-delta",
|
|
938
|
+
id: String(blockIndex),
|
|
939
|
+
delta: value.contentBlockDelta.delta.text
|
|
834
940
|
});
|
|
835
941
|
}
|
|
836
|
-
controller.enqueue({
|
|
837
|
-
type: "text-delta",
|
|
838
|
-
id: String(blockIndex),
|
|
839
|
-
delta: value.contentBlockDelta.delta.text
|
|
840
|
-
});
|
|
841
942
|
}
|
|
842
943
|
if (((_n = value.contentBlockStop) == null ? void 0 : _n.contentBlockIndex) != null) {
|
|
843
944
|
const blockIndex = value.contentBlockStop.contentBlockIndex;
|
|
@@ -849,21 +950,39 @@ var BedrockChatLanguageModel = class {
|
|
|
849
950
|
id: String(blockIndex)
|
|
850
951
|
});
|
|
851
952
|
} else if (contentBlock.type === "text") {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
953
|
+
if (!usesJsonResponseTool) {
|
|
954
|
+
controller.enqueue({
|
|
955
|
+
type: "text-end",
|
|
956
|
+
id: String(blockIndex)
|
|
957
|
+
});
|
|
958
|
+
}
|
|
856
959
|
} else if (contentBlock.type === "tool-call") {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
960
|
+
if (usesJsonResponseTool) {
|
|
961
|
+
controller.enqueue({
|
|
962
|
+
type: "text-start",
|
|
963
|
+
id: String(blockIndex)
|
|
964
|
+
});
|
|
965
|
+
controller.enqueue({
|
|
966
|
+
type: "text-delta",
|
|
967
|
+
id: String(blockIndex),
|
|
968
|
+
delta: contentBlock.jsonText
|
|
969
|
+
});
|
|
970
|
+
controller.enqueue({
|
|
971
|
+
type: "text-end",
|
|
972
|
+
id: String(blockIndex)
|
|
973
|
+
});
|
|
974
|
+
} else {
|
|
975
|
+
controller.enqueue({
|
|
976
|
+
type: "tool-input-end",
|
|
977
|
+
id: contentBlock.toolCallId
|
|
978
|
+
});
|
|
979
|
+
controller.enqueue({
|
|
980
|
+
type: "tool-call",
|
|
981
|
+
toolCallId: contentBlock.toolCallId,
|
|
982
|
+
toolName: contentBlock.toolName,
|
|
983
|
+
input: contentBlock.jsonText
|
|
984
|
+
});
|
|
985
|
+
}
|
|
867
986
|
}
|
|
868
987
|
delete contentBlocks[blockIndex];
|
|
869
988
|
}
|
|
@@ -918,11 +1037,13 @@ var BedrockChatLanguageModel = class {
|
|
|
918
1037
|
toolName: toolUse.name,
|
|
919
1038
|
jsonText: ""
|
|
920
1039
|
};
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1040
|
+
if (!usesJsonResponseTool) {
|
|
1041
|
+
controller.enqueue({
|
|
1042
|
+
type: "tool-input-start",
|
|
1043
|
+
id: toolUse.toolUseId,
|
|
1044
|
+
toolName: toolUse.name
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
926
1047
|
}
|
|
927
1048
|
const contentBlockDelta = value.contentBlockDelta;
|
|
928
1049
|
if ((contentBlockDelta == null ? void 0 : contentBlockDelta.delta) && "toolUse" in contentBlockDelta.delta && contentBlockDelta.delta.toolUse) {
|
|
@@ -930,11 +1051,13 @@ var BedrockChatLanguageModel = class {
|
|
|
930
1051
|
const contentBlock = contentBlocks[blockIndex];
|
|
931
1052
|
if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
|
|
932
1053
|
const delta = (_q = contentBlockDelta.delta.toolUse.input) != null ? _q : "";
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1054
|
+
if (!usesJsonResponseTool) {
|
|
1055
|
+
controller.enqueue({
|
|
1056
|
+
type: "tool-input-delta",
|
|
1057
|
+
id: contentBlock.toolCallId,
|
|
1058
|
+
delta
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
938
1061
|
contentBlock.jsonText += delta;
|
|
939
1062
|
}
|
|
940
1063
|
}
|
|
@@ -958,104 +1081,104 @@ var BedrockChatLanguageModel = class {
|
|
|
958
1081
|
return `${this.config.baseUrl()}/model/${encodedModelId}`;
|
|
959
1082
|
}
|
|
960
1083
|
};
|
|
961
|
-
var BedrockStopReasonSchema =
|
|
962
|
-
|
|
963
|
-
|
|
1084
|
+
var BedrockStopReasonSchema = import_v43.z.union([
|
|
1085
|
+
import_v43.z.enum(BEDROCK_STOP_REASONS),
|
|
1086
|
+
import_v43.z.string()
|
|
964
1087
|
]);
|
|
965
|
-
var BedrockToolUseSchema =
|
|
966
|
-
toolUseId:
|
|
967
|
-
name:
|
|
968
|
-
input:
|
|
1088
|
+
var BedrockToolUseSchema = import_v43.z.object({
|
|
1089
|
+
toolUseId: import_v43.z.string(),
|
|
1090
|
+
name: import_v43.z.string(),
|
|
1091
|
+
input: import_v43.z.unknown()
|
|
969
1092
|
});
|
|
970
|
-
var BedrockReasoningTextSchema =
|
|
971
|
-
signature:
|
|
972
|
-
text:
|
|
1093
|
+
var BedrockReasoningTextSchema = import_v43.z.object({
|
|
1094
|
+
signature: import_v43.z.string().nullish(),
|
|
1095
|
+
text: import_v43.z.string()
|
|
973
1096
|
});
|
|
974
|
-
var BedrockRedactedReasoningSchema =
|
|
975
|
-
data:
|
|
1097
|
+
var BedrockRedactedReasoningSchema = import_v43.z.object({
|
|
1098
|
+
data: import_v43.z.string()
|
|
976
1099
|
});
|
|
977
|
-
var BedrockResponseSchema =
|
|
978
|
-
metrics:
|
|
979
|
-
latencyMs:
|
|
1100
|
+
var BedrockResponseSchema = import_v43.z.object({
|
|
1101
|
+
metrics: import_v43.z.object({
|
|
1102
|
+
latencyMs: import_v43.z.number()
|
|
980
1103
|
}).nullish(),
|
|
981
|
-
output:
|
|
982
|
-
message:
|
|
983
|
-
content:
|
|
984
|
-
|
|
985
|
-
text:
|
|
1104
|
+
output: import_v43.z.object({
|
|
1105
|
+
message: import_v43.z.object({
|
|
1106
|
+
content: import_v43.z.array(
|
|
1107
|
+
import_v43.z.object({
|
|
1108
|
+
text: import_v43.z.string().nullish(),
|
|
986
1109
|
toolUse: BedrockToolUseSchema.nullish(),
|
|
987
|
-
reasoningContent:
|
|
988
|
-
|
|
1110
|
+
reasoningContent: import_v43.z.union([
|
|
1111
|
+
import_v43.z.object({
|
|
989
1112
|
reasoningText: BedrockReasoningTextSchema
|
|
990
1113
|
}),
|
|
991
|
-
|
|
1114
|
+
import_v43.z.object({
|
|
992
1115
|
redactedReasoning: BedrockRedactedReasoningSchema
|
|
993
1116
|
})
|
|
994
1117
|
]).nullish()
|
|
995
1118
|
})
|
|
996
1119
|
),
|
|
997
|
-
role:
|
|
1120
|
+
role: import_v43.z.string()
|
|
998
1121
|
})
|
|
999
1122
|
}),
|
|
1000
1123
|
stopReason: BedrockStopReasonSchema,
|
|
1001
|
-
trace:
|
|
1002
|
-
usage:
|
|
1003
|
-
inputTokens:
|
|
1004
|
-
outputTokens:
|
|
1005
|
-
totalTokens:
|
|
1006
|
-
cacheReadInputTokens:
|
|
1007
|
-
cacheWriteInputTokens:
|
|
1124
|
+
trace: import_v43.z.unknown().nullish(),
|
|
1125
|
+
usage: import_v43.z.object({
|
|
1126
|
+
inputTokens: import_v43.z.number(),
|
|
1127
|
+
outputTokens: import_v43.z.number(),
|
|
1128
|
+
totalTokens: import_v43.z.number(),
|
|
1129
|
+
cacheReadInputTokens: import_v43.z.number().nullish(),
|
|
1130
|
+
cacheWriteInputTokens: import_v43.z.number().nullish()
|
|
1008
1131
|
})
|
|
1009
1132
|
});
|
|
1010
|
-
var BedrockStreamSchema =
|
|
1011
|
-
contentBlockDelta:
|
|
1012
|
-
contentBlockIndex:
|
|
1013
|
-
delta:
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
reasoningContent:
|
|
1133
|
+
var BedrockStreamSchema = import_v43.z.object({
|
|
1134
|
+
contentBlockDelta: import_v43.z.object({
|
|
1135
|
+
contentBlockIndex: import_v43.z.number(),
|
|
1136
|
+
delta: import_v43.z.union([
|
|
1137
|
+
import_v43.z.object({ text: import_v43.z.string() }),
|
|
1138
|
+
import_v43.z.object({ toolUse: import_v43.z.object({ input: import_v43.z.string() }) }),
|
|
1139
|
+
import_v43.z.object({
|
|
1140
|
+
reasoningContent: import_v43.z.object({ text: import_v43.z.string() })
|
|
1018
1141
|
}),
|
|
1019
|
-
|
|
1020
|
-
reasoningContent:
|
|
1021
|
-
signature:
|
|
1142
|
+
import_v43.z.object({
|
|
1143
|
+
reasoningContent: import_v43.z.object({
|
|
1144
|
+
signature: import_v43.z.string()
|
|
1022
1145
|
})
|
|
1023
1146
|
}),
|
|
1024
|
-
|
|
1025
|
-
reasoningContent:
|
|
1147
|
+
import_v43.z.object({
|
|
1148
|
+
reasoningContent: import_v43.z.object({ data: import_v43.z.string() })
|
|
1026
1149
|
})
|
|
1027
1150
|
]).nullish()
|
|
1028
1151
|
}).nullish(),
|
|
1029
|
-
contentBlockStart:
|
|
1030
|
-
contentBlockIndex:
|
|
1031
|
-
start:
|
|
1152
|
+
contentBlockStart: import_v43.z.object({
|
|
1153
|
+
contentBlockIndex: import_v43.z.number(),
|
|
1154
|
+
start: import_v43.z.object({
|
|
1032
1155
|
toolUse: BedrockToolUseSchema.nullish()
|
|
1033
1156
|
}).nullish()
|
|
1034
1157
|
}).nullish(),
|
|
1035
|
-
contentBlockStop:
|
|
1036
|
-
contentBlockIndex:
|
|
1158
|
+
contentBlockStop: import_v43.z.object({
|
|
1159
|
+
contentBlockIndex: import_v43.z.number()
|
|
1037
1160
|
}).nullish(),
|
|
1038
|
-
internalServerException:
|
|
1039
|
-
messageStop:
|
|
1040
|
-
additionalModelResponseFields:
|
|
1161
|
+
internalServerException: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish(),
|
|
1162
|
+
messageStop: import_v43.z.object({
|
|
1163
|
+
additionalModelResponseFields: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish(),
|
|
1041
1164
|
stopReason: BedrockStopReasonSchema
|
|
1042
1165
|
}).nullish(),
|
|
1043
|
-
metadata:
|
|
1044
|
-
trace:
|
|
1045
|
-
usage:
|
|
1046
|
-
cacheReadInputTokens:
|
|
1047
|
-
cacheWriteInputTokens:
|
|
1048
|
-
inputTokens:
|
|
1049
|
-
outputTokens:
|
|
1166
|
+
metadata: import_v43.z.object({
|
|
1167
|
+
trace: import_v43.z.unknown().nullish(),
|
|
1168
|
+
usage: import_v43.z.object({
|
|
1169
|
+
cacheReadInputTokens: import_v43.z.number().nullish(),
|
|
1170
|
+
cacheWriteInputTokens: import_v43.z.number().nullish(),
|
|
1171
|
+
inputTokens: import_v43.z.number(),
|
|
1172
|
+
outputTokens: import_v43.z.number()
|
|
1050
1173
|
}).nullish()
|
|
1051
1174
|
}).nullish(),
|
|
1052
|
-
modelStreamErrorException:
|
|
1053
|
-
throttlingException:
|
|
1054
|
-
validationException:
|
|
1175
|
+
modelStreamErrorException: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish(),
|
|
1176
|
+
throttlingException: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish(),
|
|
1177
|
+
validationException: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish()
|
|
1055
1178
|
});
|
|
1056
|
-
var bedrockReasoningMetadataSchema =
|
|
1057
|
-
signature:
|
|
1058
|
-
redactedData:
|
|
1179
|
+
var bedrockReasoningMetadataSchema = import_v43.z.object({
|
|
1180
|
+
signature: import_v43.z.string().optional(),
|
|
1181
|
+
redactedData: import_v43.z.string().optional()
|
|
1059
1182
|
});
|
|
1060
1183
|
|
|
1061
1184
|
// src/bedrock-embedding-model.ts
|
|
@@ -1063,22 +1186,22 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
1063
1186
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1064
1187
|
|
|
1065
1188
|
// src/bedrock-embedding-options.ts
|
|
1066
|
-
var
|
|
1067
|
-
var bedrockEmbeddingProviderOptions =
|
|
1189
|
+
var import_v44 = require("zod/v4");
|
|
1190
|
+
var bedrockEmbeddingProviderOptions = import_v44.z.object({
|
|
1068
1191
|
/**
|
|
1069
1192
|
The number of dimensions the resulting output embeddings should have (defaults to 1024).
|
|
1070
1193
|
Only supported in amazon.titan-embed-text-v2:0.
|
|
1071
1194
|
*/
|
|
1072
|
-
dimensions:
|
|
1195
|
+
dimensions: import_v44.z.union([import_v44.z.literal(1024), import_v44.z.literal(512), import_v44.z.literal(256)]).optional(),
|
|
1073
1196
|
/**
|
|
1074
1197
|
Flag indicating whether or not to normalize the output embeddings. Defaults to true
|
|
1075
1198
|
Only supported in amazon.titan-embed-text-v2:0.
|
|
1076
1199
|
*/
|
|
1077
|
-
normalize:
|
|
1200
|
+
normalize: import_v44.z.boolean().optional()
|
|
1078
1201
|
});
|
|
1079
1202
|
|
|
1080
1203
|
// src/bedrock-embedding-model.ts
|
|
1081
|
-
var
|
|
1204
|
+
var import_v45 = require("zod/v4");
|
|
1082
1205
|
var BedrockEmbeddingModel = class {
|
|
1083
1206
|
constructor(modelId, config) {
|
|
1084
1207
|
this.modelId = modelId;
|
|
@@ -1140,9 +1263,9 @@ var BedrockEmbeddingModel = class {
|
|
|
1140
1263
|
};
|
|
1141
1264
|
}
|
|
1142
1265
|
};
|
|
1143
|
-
var BedrockEmbeddingResponseSchema =
|
|
1144
|
-
embedding:
|
|
1145
|
-
inputTextTokenCount:
|
|
1266
|
+
var BedrockEmbeddingResponseSchema = import_v45.z.object({
|
|
1267
|
+
embedding: import_v45.z.array(import_v45.z.number()),
|
|
1268
|
+
inputTextTokenCount: import_v45.z.number()
|
|
1146
1269
|
});
|
|
1147
1270
|
|
|
1148
1271
|
// src/bedrock-image-model.ts
|
|
@@ -1154,7 +1277,7 @@ var modelMaxImagesPerCall = {
|
|
|
1154
1277
|
};
|
|
1155
1278
|
|
|
1156
1279
|
// src/bedrock-image-model.ts
|
|
1157
|
-
var
|
|
1280
|
+
var import_v46 = require("zod/v4");
|
|
1158
1281
|
var BedrockImageModel = class {
|
|
1159
1282
|
constructor(modelId, config) {
|
|
1160
1283
|
this.modelId = modelId;
|
|
@@ -1180,7 +1303,7 @@ var BedrockImageModel = class {
|
|
|
1180
1303
|
headers,
|
|
1181
1304
|
abortSignal
|
|
1182
1305
|
}) {
|
|
1183
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1306
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1184
1307
|
const warnings = [];
|
|
1185
1308
|
const [width, height] = size ? size.split("x").map(Number) : [];
|
|
1186
1309
|
const args = {
|
|
@@ -1189,6 +1312,9 @@ var BedrockImageModel = class {
|
|
|
1189
1312
|
text: prompt,
|
|
1190
1313
|
...((_a = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _a.negativeText) ? {
|
|
1191
1314
|
negativeText: providerOptions.bedrock.negativeText
|
|
1315
|
+
} : {},
|
|
1316
|
+
...((_b = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _b.style) ? {
|
|
1317
|
+
style: providerOptions.bedrock.style
|
|
1192
1318
|
} : {}
|
|
1193
1319
|
},
|
|
1194
1320
|
imageGenerationConfig: {
|
|
@@ -1196,8 +1322,8 @@ var BedrockImageModel = class {
|
|
|
1196
1322
|
...height ? { height } : {},
|
|
1197
1323
|
...seed ? { seed } : {},
|
|
1198
1324
|
...n ? { numberOfImages: n } : {},
|
|
1199
|
-
...((
|
|
1200
|
-
...((
|
|
1325
|
+
...((_c = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _c.quality) ? { quality: providerOptions.bedrock.quality } : {},
|
|
1326
|
+
...((_d = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _d.cfgScale) ? { cfgScale: providerOptions.bedrock.cfgScale } : {}
|
|
1201
1327
|
}
|
|
1202
1328
|
};
|
|
1203
1329
|
if (aspectRatio != void 0) {
|
|
@@ -1207,7 +1333,7 @@ var BedrockImageModel = class {
|
|
|
1207
1333
|
details: "This model does not support aspect ratio. Use `size` instead."
|
|
1208
1334
|
});
|
|
1209
1335
|
}
|
|
1210
|
-
const currentDate = (
|
|
1336
|
+
const currentDate = (_g = (_f = (_e = this.config._internal) == null ? void 0 : _e.currentDate) == null ? void 0 : _f.call(_e)) != null ? _g : /* @__PURE__ */ new Date();
|
|
1211
1337
|
const { value: response, responseHeaders } = await (0, import_provider_utils5.postJsonToApi)({
|
|
1212
1338
|
url: this.getUrl(this.modelId),
|
|
1213
1339
|
headers: await (0, import_provider_utils5.resolve)(
|
|
@@ -1235,8 +1361,8 @@ var BedrockImageModel = class {
|
|
|
1235
1361
|
};
|
|
1236
1362
|
}
|
|
1237
1363
|
};
|
|
1238
|
-
var bedrockImageResponseSchema =
|
|
1239
|
-
images:
|
|
1364
|
+
var bedrockImageResponseSchema = import_v46.z.object({
|
|
1365
|
+
images: import_v46.z.array(import_v46.z.string())
|
|
1240
1366
|
});
|
|
1241
1367
|
|
|
1242
1368
|
// src/headers-utils.ts
|
|
@@ -1307,10 +1433,28 @@ function prepareBodyString(body) {
|
|
|
1307
1433
|
return JSON.stringify(body);
|
|
1308
1434
|
}
|
|
1309
1435
|
}
|
|
1436
|
+
function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
|
|
1437
|
+
return async (input, init) => {
|
|
1438
|
+
const originalHeaders = extractHeaders(init == null ? void 0 : init.headers);
|
|
1439
|
+
return fetch(input, {
|
|
1440
|
+
...init,
|
|
1441
|
+
headers: (0, import_provider_utils6.removeUndefinedEntries)(
|
|
1442
|
+
(0, import_provider_utils6.combineHeaders)(originalHeaders, {
|
|
1443
|
+
Authorization: `Bearer ${apiKey}`
|
|
1444
|
+
})
|
|
1445
|
+
)
|
|
1446
|
+
});
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1310
1449
|
|
|
1311
1450
|
// src/bedrock-provider.ts
|
|
1312
1451
|
function createAmazonBedrock(options = {}) {
|
|
1313
|
-
const
|
|
1452
|
+
const rawApiKey = (0, import_provider_utils7.loadOptionalSetting)({
|
|
1453
|
+
settingValue: options.apiKey,
|
|
1454
|
+
environmentVariableName: "AWS_BEARER_TOKEN_BEDROCK"
|
|
1455
|
+
});
|
|
1456
|
+
const apiKey = rawApiKey && rawApiKey.trim().length > 0 ? rawApiKey.trim() : void 0;
|
|
1457
|
+
const fetchFunction = apiKey ? createApiKeyFetchFunction(apiKey, options.fetch) : createSigV4FetchFunction(async () => {
|
|
1314
1458
|
const region = (0, import_provider_utils7.loadSetting)({
|
|
1315
1459
|
settingValue: options.region,
|
|
1316
1460
|
settingName: "region",
|
|
@@ -1318,30 +1462,58 @@ function createAmazonBedrock(options = {}) {
|
|
|
1318
1462
|
description: "AWS region"
|
|
1319
1463
|
});
|
|
1320
1464
|
if (options.credentialProvider) {
|
|
1465
|
+
try {
|
|
1466
|
+
return {
|
|
1467
|
+
...await options.credentialProvider(),
|
|
1468
|
+
region
|
|
1469
|
+
};
|
|
1470
|
+
} catch (error) {
|
|
1471
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1472
|
+
throw new Error(
|
|
1473
|
+
`AWS credential provider failed: ${errorMessage}. Please ensure your credential provider returns valid AWS credentials with accessKeyId and secretAccessKey properties.`
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
try {
|
|
1321
1478
|
return {
|
|
1322
|
-
|
|
1323
|
-
|
|
1479
|
+
region,
|
|
1480
|
+
accessKeyId: (0, import_provider_utils7.loadSetting)({
|
|
1481
|
+
settingValue: options.accessKeyId,
|
|
1482
|
+
settingName: "accessKeyId",
|
|
1483
|
+
environmentVariableName: "AWS_ACCESS_KEY_ID",
|
|
1484
|
+
description: "AWS access key ID"
|
|
1485
|
+
}),
|
|
1486
|
+
secretAccessKey: (0, import_provider_utils7.loadSetting)({
|
|
1487
|
+
settingValue: options.secretAccessKey,
|
|
1488
|
+
settingName: "secretAccessKey",
|
|
1489
|
+
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
1490
|
+
description: "AWS secret access key"
|
|
1491
|
+
}),
|
|
1492
|
+
sessionToken: (0, import_provider_utils7.loadOptionalSetting)({
|
|
1493
|
+
settingValue: options.sessionToken,
|
|
1494
|
+
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
1495
|
+
})
|
|
1324
1496
|
};
|
|
1497
|
+
} catch (error) {
|
|
1498
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1499
|
+
if (errorMessage.includes("AWS_ACCESS_KEY_ID") || errorMessage.includes("accessKeyId")) {
|
|
1500
|
+
throw new Error(
|
|
1501
|
+
`AWS SigV4 authentication requires AWS credentials. Please provide either:
|
|
1502
|
+
1. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
|
|
1503
|
+
2. Provide accessKeyId and secretAccessKey in options
|
|
1504
|
+
3. Use a credentialProvider function
|
|
1505
|
+
4. Use API key authentication with AWS_BEARER_TOKEN_BEDROCK or apiKey option
|
|
1506
|
+
Original error: ${errorMessage}`
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
if (errorMessage.includes("AWS_SECRET_ACCESS_KEY") || errorMessage.includes("secretAccessKey")) {
|
|
1510
|
+
throw new Error(
|
|
1511
|
+
`AWS SigV4 authentication requires both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Please ensure both credentials are provided.
|
|
1512
|
+
Original error: ${errorMessage}`
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
throw error;
|
|
1325
1516
|
}
|
|
1326
|
-
return {
|
|
1327
|
-
region,
|
|
1328
|
-
accessKeyId: (0, import_provider_utils7.loadSetting)({
|
|
1329
|
-
settingValue: options.accessKeyId,
|
|
1330
|
-
settingName: "accessKeyId",
|
|
1331
|
-
environmentVariableName: "AWS_ACCESS_KEY_ID",
|
|
1332
|
-
description: "AWS access key ID"
|
|
1333
|
-
}),
|
|
1334
|
-
secretAccessKey: (0, import_provider_utils7.loadSetting)({
|
|
1335
|
-
settingValue: options.secretAccessKey,
|
|
1336
|
-
settingName: "secretAccessKey",
|
|
1337
|
-
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
1338
|
-
description: "AWS secret access key"
|
|
1339
|
-
}),
|
|
1340
|
-
sessionToken: (0, import_provider_utils7.loadOptionalSetting)({
|
|
1341
|
-
settingValue: options.sessionToken,
|
|
1342
|
-
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
1343
|
-
})
|
|
1344
|
-
};
|
|
1345
1517
|
}, options.fetch);
|
|
1346
1518
|
const getBaseUrl = () => {
|
|
1347
1519
|
var _a, _b;
|
|
@@ -1359,7 +1531,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1359
1531
|
return new BedrockChatLanguageModel(modelId, {
|
|
1360
1532
|
baseUrl: getBaseUrl,
|
|
1361
1533
|
headers: (_a = options.headers) != null ? _a : {},
|
|
1362
|
-
fetch:
|
|
1534
|
+
fetch: fetchFunction,
|
|
1363
1535
|
generateId: import_provider_utils7.generateId
|
|
1364
1536
|
});
|
|
1365
1537
|
};
|
|
@@ -1376,7 +1548,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1376
1548
|
return new BedrockEmbeddingModel(modelId, {
|
|
1377
1549
|
baseUrl: getBaseUrl,
|
|
1378
1550
|
headers: (_a = options.headers) != null ? _a : {},
|
|
1379
|
-
fetch:
|
|
1551
|
+
fetch: fetchFunction
|
|
1380
1552
|
});
|
|
1381
1553
|
};
|
|
1382
1554
|
const createImageModel = (modelId) => {
|
|
@@ -1384,7 +1556,7 @@ function createAmazonBedrock(options = {}) {
|
|
|
1384
1556
|
return new BedrockImageModel(modelId, {
|
|
1385
1557
|
baseUrl: getBaseUrl,
|
|
1386
1558
|
headers: (_a = options.headers) != null ? _a : {},
|
|
1387
|
-
fetch:
|
|
1559
|
+
fetch: fetchFunction
|
|
1388
1560
|
});
|
|
1389
1561
|
};
|
|
1390
1562
|
provider.languageModel = createChatModel;
|