@ai-sdk/amazon-bedrock 2.2.10 → 3.0.0-alpha.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/dist/index.mjs CHANGED
@@ -7,18 +7,15 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/bedrock-chat-language-model.ts
10
- import {
11
- InvalidArgumentError,
12
- UnsupportedFunctionalityError as UnsupportedFunctionalityError3
13
- } from "@ai-sdk/provider";
14
10
  import {
15
11
  combineHeaders,
16
12
  createJsonErrorResponseHandler,
17
13
  createJsonResponseHandler,
14
+ parseProviderOptions as parseProviderOptions2,
18
15
  postJsonToApi,
19
16
  resolve
20
17
  } from "@ai-sdk/provider-utils";
21
- import { z as z2 } from "zod";
18
+ import { z as z3 } from "zod";
22
19
 
23
20
  // src/bedrock-api-types.ts
24
21
  var BEDROCK_CACHE_POINT = {
@@ -37,11 +34,26 @@ var BEDROCK_STOP_REASONS = [
37
34
  "tool_use"
38
35
  ];
39
36
 
40
- // src/bedrock-error.ts
37
+ // src/bedrock-chat-options.ts
41
38
  import { z } from "zod";
42
- var BedrockErrorSchema = z.object({
43
- message: z.string(),
44
- type: z.string().nullish()
39
+ var bedrockProviderOptions = z.object({
40
+ /**
41
+ * Additional inference parameters that the model supports,
42
+ * beyond the base set of inference parameters that Converse
43
+ * supports in the inferenceConfig field
44
+ */
45
+ additionalModelRequestFields: z.record(z.any()).optional(),
46
+ reasoningConfig: z.object({
47
+ type: z.union([z.literal("enabled"), z.literal("disabled")]).optional(),
48
+ budgetTokens: z.number().optional()
49
+ }).optional()
50
+ });
51
+
52
+ // src/bedrock-error.ts
53
+ import { z as z2 } from "zod";
54
+ var BedrockErrorSchema = z2.object({
55
+ message: z2.string(),
56
+ type: z2.string().nullish()
45
57
  });
46
58
 
47
59
  // src/bedrock-event-stream-response-handler.ts
@@ -65,7 +77,7 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
65
77
  responseHeaders,
66
78
  value: response.body.pipeThrough(
67
79
  new TransformStream({
68
- transform(chunk, controller) {
80
+ async transform(chunk, controller) {
69
81
  var _a, _b;
70
82
  const newBuffer = new Uint8Array(buffer.length + chunk.length);
71
83
  newBuffer.set(buffer);
@@ -86,7 +98,7 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
86
98
  buffer = buffer.slice(totalLength);
87
99
  if (((_a = decoded.headers[":message-type"]) == null ? void 0 : _a.value) === "event") {
88
100
  const data = textDecoder.decode(decoded.body);
89
- const parsedDataResult = safeParseJSON({ text: data });
101
+ const parsedDataResult = await safeParseJSON({ text: data });
90
102
  if (!parsedDataResult.success) {
91
103
  controller.enqueue(parsedDataResult);
92
104
  break;
@@ -95,7 +107,7 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
95
107
  let wrappedData = {
96
108
  [(_b = decoded.headers[":event-type"]) == null ? void 0 : _b.value]: parsedDataResult.value
97
109
  };
98
- const validatedWrappedData = safeValidateTypes({
110
+ const validatedWrappedData = await safeValidateTypes({
99
111
  value: wrappedData,
100
112
  schema: chunkSchema
101
113
  });
@@ -123,9 +135,11 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
123
135
  import {
124
136
  UnsupportedFunctionalityError
125
137
  } from "@ai-sdk/provider";
126
- function prepareTools(mode) {
127
- var _a;
128
- const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
138
+ function prepareTools({
139
+ tools,
140
+ toolChoice
141
+ }) {
142
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
129
143
  if (tools == null) {
130
144
  return {
131
145
  toolConfig: { tools: void 0, toolChoice: void 0 },
@@ -149,7 +163,6 @@ function prepareTools(mode) {
149
163
  });
150
164
  }
151
165
  }
152
- const toolChoice = mode.toolChoice;
153
166
  if (toolChoice == null) {
154
167
  return {
155
168
  toolConfig: { tools: bedrockTools, toolChoice: void 0 },
@@ -184,7 +197,7 @@ function prepareTools(mode) {
184
197
  default: {
185
198
  const _exhaustiveCheck = type;
186
199
  throw new UnsupportedFunctionalityError({
187
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
200
+ functionality: `tool choice type: ${_exhaustiveCheck}`
188
201
  });
189
202
  }
190
203
  }
@@ -195,16 +208,17 @@ import {
195
208
  UnsupportedFunctionalityError as UnsupportedFunctionalityError2
196
209
  } from "@ai-sdk/provider";
197
210
  import {
198
- convertUint8ArrayToBase64,
199
- createIdGenerator
211
+ convertToBase64,
212
+ createIdGenerator,
213
+ parseProviderOptions
200
214
  } from "@ai-sdk/provider-utils";
201
215
  var generateFileId = createIdGenerator({ prefix: "file", size: 16 });
202
216
  function getCachePoint(providerMetadata) {
203
217
  var _a;
204
218
  return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
205
219
  }
206
- function convertToBedrockChatMessages(prompt) {
207
- var _a, _b, _c, _d, _e;
220
+ async function convertToBedrockChatMessages(prompt) {
221
+ var _a, _b, _c, _d;
208
222
  const blocks = groupIntoBlocks(prompt);
209
223
  let system = [];
210
224
  const messages = [];
@@ -221,7 +235,7 @@ function convertToBedrockChatMessages(prompt) {
221
235
  }
222
236
  for (const message of block.messages) {
223
237
  system.push({ text: message.content });
224
- if (getCachePoint(message.providerMetadata)) {
238
+ if (getCachePoint(message.providerOptions)) {
225
239
  system.push(BEDROCK_CACHE_POINT);
226
240
  }
227
241
  }
@@ -230,7 +244,7 @@ function convertToBedrockChatMessages(prompt) {
230
244
  case "user": {
231
245
  const bedrockContent = [];
232
246
  for (const message of block.messages) {
233
- const { role, content, providerMetadata } = message;
247
+ const { role, content, providerOptions } = message;
234
248
  switch (role) {
235
249
  case "user": {
236
250
  for (let j = 0; j < content.length; j++) {
@@ -242,43 +256,31 @@ function convertToBedrockChatMessages(prompt) {
242
256
  });
243
257
  break;
244
258
  }
245
- case "image": {
246
- if (part.image instanceof URL) {
247
- throw new UnsupportedFunctionalityError2({
248
- functionality: "Image URLs in user messages"
249
- });
250
- }
251
- bedrockContent.push({
252
- image: {
253
- format: (_b = (_a = part.mimeType) == null ? void 0 : _a.split(
254
- "/"
255
- )) == null ? void 0 : _b[1],
256
- source: {
257
- bytes: convertUint8ArrayToBase64(
258
- (_c = part.image) != null ? _c : part.image
259
- )
260
- }
261
- }
262
- });
263
- break;
264
- }
265
259
  case "file": {
266
260
  if (part.data instanceof URL) {
267
261
  throw new UnsupportedFunctionalityError2({
268
- functionality: "File URLs in user messages"
262
+ functionality: "File URL data"
269
263
  });
270
264
  }
271
- bedrockContent.push({
272
- document: {
273
- format: (_e = (_d = part.mimeType) == null ? void 0 : _d.split(
274
- "/"
275
- )) == null ? void 0 : _e[1],
276
- name: generateFileId(),
277
- source: {
278
- bytes: part.data
265
+ if (part.mediaType.startsWith("image/")) {
266
+ const bedrockImageFormat = part.mediaType === "image/*" ? void 0 : (_b = (_a = part.mediaType) == null ? void 0 : _a.split("/")) == null ? void 0 : _b[1];
267
+ bedrockContent.push({
268
+ image: {
269
+ format: bedrockImageFormat,
270
+ source: { bytes: convertToBase64(part.data) }
279
271
  }
280
- }
281
- });
272
+ });
273
+ } else {
274
+ bedrockContent.push({
275
+ document: {
276
+ format: (_d = (_c = part.mediaType) == null ? void 0 : _c.split(
277
+ "/"
278
+ )) == null ? void 0 : _d[1],
279
+ name: generateFileId(),
280
+ source: { bytes: convertToBase64(part.data) }
281
+ }
282
+ });
283
+ }
282
284
  break;
283
285
  }
284
286
  }
@@ -295,12 +297,12 @@ function convertToBedrockChatMessages(prompt) {
295
297
  text: part2.text
296
298
  };
297
299
  case "image":
298
- if (!part2.mimeType) {
300
+ if (!part2.mediaType) {
299
301
  throw new Error(
300
302
  "Image mime type is required in tool result part content"
301
303
  );
302
304
  }
303
- const format = part2.mimeType.split("/")[1];
305
+ const format = part2.mediaType.split("/")[1];
304
306
  if (!isBedrockImageFormat(format)) {
305
307
  throw new Error(
306
308
  `Unsupported image format: ${format}`
@@ -330,7 +332,7 @@ function convertToBedrockChatMessages(prompt) {
330
332
  throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
331
333
  }
332
334
  }
333
- if (getCachePoint(providerMetadata)) {
335
+ if (getCachePoint(providerOptions)) {
334
336
  bedrockContent.push(BEDROCK_CACHE_POINT);
335
337
  }
336
338
  }
@@ -364,32 +366,39 @@ function convertToBedrockChatMessages(prompt) {
364
366
  break;
365
367
  }
366
368
  case "reasoning": {
367
- bedrockContent.push({
368
- reasoningContent: {
369
- reasoningText: {
370
- // trim the last text part if it's the last message in the block
371
- // because Bedrock does not allow trailing whitespace
372
- // in pre-filled assistant responses
373
- text: trimIfLast(
374
- isLastBlock,
375
- isLastMessage,
376
- isLastContentPart,
377
- part.text
378
- ),
379
- signature: part.signature
380
- }
381
- }
369
+ const reasoningMetadata = await parseProviderOptions({
370
+ provider: "bedrock",
371
+ providerOptions: part.providerOptions,
372
+ schema: bedrockReasoningMetadataSchema
382
373
  });
383
- break;
384
- }
385
- case "redacted-reasoning": {
386
- bedrockContent.push({
387
- reasoningContent: {
388
- redactedReasoning: {
389
- data: part.data
390
- }
374
+ if (reasoningMetadata != null) {
375
+ if (reasoningMetadata.signature != null) {
376
+ bedrockContent.push({
377
+ reasoningContent: {
378
+ reasoningText: {
379
+ // trim the last text part if it's the last message in the block
380
+ // because Bedrock does not allow trailing whitespace
381
+ // in pre-filled assistant responses
382
+ text: trimIfLast(
383
+ isLastBlock,
384
+ isLastMessage,
385
+ isLastContentPart,
386
+ part.text
387
+ ),
388
+ signature: reasoningMetadata.signature
389
+ }
390
+ }
391
+ });
392
+ } else if (reasoningMetadata.redactedData != null) {
393
+ bedrockContent.push({
394
+ reasoningContent: {
395
+ redactedReasoning: {
396
+ data: reasoningMetadata.redactedData
397
+ }
398
+ }
399
+ });
391
400
  }
392
- });
401
+ }
393
402
  break;
394
403
  }
395
404
  case "tool-call": {
@@ -404,7 +413,7 @@ function convertToBedrockChatMessages(prompt) {
404
413
  }
405
414
  }
406
415
  }
407
- if (getCachePoint(message.providerMetadata)) {
416
+ if (getCachePoint(message.providerOptions)) {
408
417
  bedrockContent.push(BEDROCK_CACHE_POINT);
409
418
  }
410
419
  }
@@ -492,19 +501,18 @@ function mapBedrockFinishReason(finishReason) {
492
501
 
493
502
  // src/bedrock-chat-language-model.ts
494
503
  var BedrockChatLanguageModel = class {
495
- constructor(modelId, settings, config) {
504
+ constructor(modelId, config) {
496
505
  this.modelId = modelId;
497
- this.settings = settings;
498
506
  this.config = config;
499
- this.specificationVersion = "v1";
507
+ this.specificationVersion = "v2";
500
508
  this.provider = "amazon-bedrock";
501
- this.defaultObjectGenerationMode = "tool";
502
- this.supportsImageUrls = false;
509
+ this.supportedUrls = {
510
+ // no supported urls for bedrock
511
+ };
503
512
  }
504
- getArgs({
505
- mode,
513
+ async getArgs({
506
514
  prompt,
507
- maxTokens,
515
+ maxOutputTokens,
508
516
  temperature,
509
517
  topP,
510
518
  topK,
@@ -513,10 +521,16 @@ var BedrockChatLanguageModel = class {
513
521
  stopSequences,
514
522
  responseFormat,
515
523
  seed,
516
- providerMetadata
524
+ tools,
525
+ toolChoice,
526
+ providerOptions
517
527
  }) {
518
- var _a, _b, _c, _d, _e, _f, _g;
519
- const type = mode.type;
528
+ var _a, _b, _c, _d, _e;
529
+ const bedrockOptions = (_a = await parseProviderOptions2({
530
+ provider: "bedrock",
531
+ providerOptions,
532
+ schema: bedrockProviderOptions
533
+ })) != null ? _a : {};
520
534
  const warnings = [];
521
535
  if (frequencyPenalty != null) {
522
536
  warnings.push({
@@ -549,35 +563,25 @@ var BedrockChatLanguageModel = class {
549
563
  details: "JSON response format is not supported."
550
564
  });
551
565
  }
552
- const { system, messages } = convertToBedrockChatMessages(prompt);
553
- const reasoningConfigOptions = BedrockReasoningConfigOptionsSchema.safeParse(
554
- (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.reasoning_config
555
- );
556
- if (!reasoningConfigOptions.success) {
557
- throw new InvalidArgumentError({
558
- argument: "providerOptions.bedrock.reasoning_config",
559
- message: "invalid reasoning configuration options",
560
- cause: reasoningConfigOptions.error
561
- });
562
- }
563
- const isThinking = ((_b = reasoningConfigOptions.data) == null ? void 0 : _b.type) === "enabled";
564
- const thinkingBudget = (_e = (_c = reasoningConfigOptions.data) == null ? void 0 : _c.budgetTokens) != null ? _e : (_d = reasoningConfigOptions.data) == null ? void 0 : _d.budget_tokens;
566
+ const { system, messages } = await convertToBedrockChatMessages(prompt);
567
+ const isThinking = ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.type) === "enabled";
568
+ const thinkingBudget = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.budgetTokens;
565
569
  const inferenceConfig = {
566
- ...maxTokens != null && { maxTokens },
570
+ ...maxOutputTokens != null && { maxOutputTokens },
567
571
  ...temperature != null && { temperature },
568
572
  ...topP != null && { topP },
569
573
  ...stopSequences != null && { stopSequences }
570
574
  };
571
575
  if (isThinking && thinkingBudget != null) {
572
- if (inferenceConfig.maxTokens != null) {
573
- inferenceConfig.maxTokens += thinkingBudget;
576
+ if (inferenceConfig.maxOutputTokens != null) {
577
+ inferenceConfig.maxOutputTokens += thinkingBudget;
574
578
  } else {
575
- inferenceConfig.maxTokens = thinkingBudget + 4096;
579
+ inferenceConfig.maxOutputTokens = thinkingBudget + 4096;
576
580
  }
577
- this.settings.additionalModelRequestFields = {
578
- ...this.settings.additionalModelRequestFields,
579
- reasoning_config: {
580
- type: (_f = reasoningConfigOptions.data) == null ? void 0 : _f.type,
581
+ bedrockOptions.additionalModelRequestFields = {
582
+ ...bedrockOptions.additionalModelRequestFields,
583
+ reasoningConfig: {
584
+ type: (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.type,
581
585
  budget_tokens: thinkingBudget
582
586
  }
583
587
  };
@@ -598,62 +602,24 @@ var BedrockChatLanguageModel = class {
598
602
  details: "topP is not supported when thinking is enabled"
599
603
  });
600
604
  }
601
- const baseArgs = {
602
- system,
603
- additionalModelRequestFields: this.settings.additionalModelRequestFields,
604
- ...Object.keys(inferenceConfig).length > 0 && {
605
- inferenceConfig
605
+ const { toolConfig, toolWarnings } = prepareTools({ tools, toolChoice });
606
+ return {
607
+ command: {
608
+ system,
609
+ messages,
610
+ additionalModelRequestFields: bedrockOptions.additionalModelRequestFields,
611
+ ...Object.keys(inferenceConfig).length > 0 && {
612
+ inferenceConfig
613
+ },
614
+ ...providerOptions == null ? void 0 : providerOptions.bedrock,
615
+ ...((_e = toolConfig.tools) == null ? void 0 : _e.length) ? { toolConfig } : {}
606
616
  },
607
- messages,
608
- ...providerMetadata == null ? void 0 : providerMetadata.bedrock
617
+ warnings: [...warnings, ...toolWarnings]
609
618
  };
610
- switch (type) {
611
- case "regular": {
612
- const { toolConfig, toolWarnings } = prepareTools(mode);
613
- return {
614
- command: {
615
- ...baseArgs,
616
- ...((_g = toolConfig.tools) == null ? void 0 : _g.length) ? { toolConfig } : {}
617
- },
618
- warnings: [...warnings, ...toolWarnings]
619
- };
620
- }
621
- case "object-json": {
622
- throw new UnsupportedFunctionalityError3({
623
- functionality: "json-mode object generation"
624
- });
625
- }
626
- case "object-tool": {
627
- return {
628
- command: {
629
- ...baseArgs,
630
- toolConfig: {
631
- tools: [
632
- {
633
- toolSpec: {
634
- name: mode.tool.name,
635
- description: mode.tool.description,
636
- inputSchema: {
637
- json: mode.tool.parameters
638
- }
639
- }
640
- }
641
- ],
642
- toolChoice: { tool: { name: mode.tool.name } }
643
- }
644
- },
645
- warnings
646
- };
647
- }
648
- default: {
649
- const _exhaustiveCheck = type;
650
- throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
651
- }
652
- }
653
619
  }
654
620
  async doGenerate(options) {
655
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
656
- const { command: args, warnings } = this.getArgs(options);
621
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
622
+ const { command: args, warnings } = await this.getArgs(options);
657
623
  const url = `${this.getUrl(this.modelId)}/converse`;
658
624
  const { value: response, responseHeaders } = await postJsonToApi({
659
625
  url,
@@ -675,67 +641,78 @@ var BedrockChatLanguageModel = class {
675
641
  abortSignal: options.abortSignal,
676
642
  fetch: this.config.fetch
677
643
  });
678
- const { messages: rawPrompt, ...rawSettings } = args;
644
+ const content = [];
645
+ for (const part of response.output.message.content) {
646
+ if (part.text) {
647
+ content.push({ type: "text", text: part.text });
648
+ }
649
+ if (part.reasoningContent) {
650
+ if ("reasoningText" in part.reasoningContent) {
651
+ const reasoning = {
652
+ type: "reasoning",
653
+ text: part.reasoningContent.reasoningText.text
654
+ };
655
+ if (part.reasoningContent.reasoningText.signature) {
656
+ reasoning.providerMetadata = {
657
+ bedrock: {
658
+ signature: part.reasoningContent.reasoningText.signature
659
+ }
660
+ };
661
+ }
662
+ content.push(reasoning);
663
+ } else if ("redactedReasoning" in part.reasoningContent) {
664
+ content.push({
665
+ type: "reasoning",
666
+ text: "",
667
+ providerMetadata: {
668
+ bedrock: {
669
+ redactedData: (_a = part.reasoningContent.redactedReasoning.data) != null ? _a : ""
670
+ }
671
+ }
672
+ });
673
+ }
674
+ }
675
+ if (part.toolUse) {
676
+ content.push({
677
+ type: "tool-call",
678
+ toolCallType: "function",
679
+ toolCallId: (_c = (_b = part.toolUse) == null ? void 0 : _b.toolUseId) != null ? _c : this.config.generateId(),
680
+ toolName: (_e = (_d = part.toolUse) == null ? void 0 : _d.name) != null ? _e : `tool-${this.config.generateId()}`,
681
+ args: JSON.stringify((_g = (_f = part.toolUse) == null ? void 0 : _f.input) != null ? _g : "")
682
+ });
683
+ }
684
+ }
679
685
  const providerMetadata = response.trace || response.usage ? {
680
686
  bedrock: {
681
687
  ...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
682
- ...response.usage && {
688
+ ...((_h = response.usage) == null ? void 0 : _h.cacheWriteInputTokens) != null && {
683
689
  usage: {
684
- cacheReadInputTokens: (_b = (_a = response.usage) == null ? void 0 : _a.cacheReadInputTokens) != null ? _b : Number.NaN,
685
- cacheWriteInputTokens: (_d = (_c = response.usage) == null ? void 0 : _c.cacheWriteInputTokens) != null ? _d : Number.NaN
690
+ cacheWriteInputTokens: response.usage.cacheWriteInputTokens
686
691
  }
687
692
  }
688
693
  }
689
694
  } : void 0;
690
- const reasoning = response.output.message.content.filter((content) => content.reasoningContent).map((content) => {
691
- var _a2;
692
- if (content.reasoningContent && "reasoningText" in content.reasoningContent) {
693
- return {
694
- type: "text",
695
- text: content.reasoningContent.reasoningText.text,
696
- ...content.reasoningContent.reasoningText.signature && {
697
- signature: content.reasoningContent.reasoningText.signature
698
- }
699
- };
700
- } else if (content.reasoningContent && "redactedReasoning" in content.reasoningContent) {
701
- return {
702
- type: "redacted",
703
- data: (_a2 = content.reasoningContent.redactedReasoning.data) != null ? _a2 : ""
704
- };
705
- } else {
706
- return void 0;
707
- }
708
- }).filter((item) => item !== void 0);
709
695
  return {
710
- text: (_h = (_g = (_f = (_e = response.output) == null ? void 0 : _e.message) == null ? void 0 : _f.content) == null ? void 0 : _g.map((part) => {
711
- var _a2;
712
- return (_a2 = part.text) != null ? _a2 : "";
713
- }).join("")) != null ? _h : void 0,
714
- toolCalls: (_l = (_k = (_j = (_i = response.output) == null ? void 0 : _i.message) == null ? void 0 : _j.content) == null ? void 0 : _k.filter((part) => !!part.toolUse)) == null ? void 0 : _l.map((part) => {
715
- var _a2, _b2, _c2, _d2, _e2, _f2;
716
- return {
717
- toolCallType: "function",
718
- toolCallId: (_b2 = (_a2 = part.toolUse) == null ? void 0 : _a2.toolUseId) != null ? _b2 : this.config.generateId(),
719
- toolName: (_d2 = (_c2 = part.toolUse) == null ? void 0 : _c2.name) != null ? _d2 : `tool-${this.config.generateId()}`,
720
- args: JSON.stringify((_f2 = (_e2 = part.toolUse) == null ? void 0 : _e2.input) != null ? _f2 : "")
721
- };
722
- }),
696
+ content,
723
697
  finishReason: mapBedrockFinishReason(
724
698
  response.stopReason
725
699
  ),
726
700
  usage: {
727
- promptTokens: (_n = (_m = response.usage) == null ? void 0 : _m.inputTokens) != null ? _n : Number.NaN,
728
- completionTokens: (_p = (_o = response.usage) == null ? void 0 : _o.outputTokens) != null ? _p : Number.NaN
701
+ inputTokens: (_i = response.usage) == null ? void 0 : _i.inputTokens,
702
+ outputTokens: (_j = response.usage) == null ? void 0 : _j.outputTokens,
703
+ totalTokens: ((_k = response.usage) == null ? void 0 : _k.inputTokens) + ((_l = response.usage) == null ? void 0 : _l.outputTokens),
704
+ cachedInputTokens: (_n = (_m = response.usage) == null ? void 0 : _m.cacheReadInputTokens) != null ? _n : void 0
705
+ },
706
+ response: {
707
+ // TODO add id, timestamp, etc
708
+ headers: responseHeaders
729
709
  },
730
- rawCall: { rawPrompt, rawSettings },
731
- rawResponse: { headers: responseHeaders },
732
710
  warnings,
733
- reasoning: reasoning.length > 0 ? reasoning : void 0,
734
711
  ...providerMetadata && { providerMetadata }
735
712
  };
736
713
  }
737
714
  async doStream(options) {
738
- const { command: args, warnings } = this.getArgs(options);
715
+ const { command: args, warnings } = await this.getArgs(options);
739
716
  const url = `${this.getUrl(this.modelId)}/converse-stream`;
740
717
  const { value: response, responseHeaders } = await postJsonToApi({
741
718
  url,
@@ -752,19 +729,22 @@ var BedrockChatLanguageModel = class {
752
729
  abortSignal: options.abortSignal,
753
730
  fetch: this.config.fetch
754
731
  });
755
- const { messages: rawPrompt, ...rawSettings } = args;
756
732
  let finishReason = "unknown";
757
- let usage = {
758
- promptTokens: Number.NaN,
759
- completionTokens: Number.NaN
733
+ const usage = {
734
+ inputTokens: void 0,
735
+ outputTokens: void 0,
736
+ totalTokens: void 0
760
737
  };
761
738
  let providerMetadata = void 0;
762
739
  const toolCallContentBlocks = {};
763
740
  return {
764
741
  stream: response.pipeThrough(
765
742
  new TransformStream({
743
+ start(controller) {
744
+ controller.enqueue({ type: "stream-start", warnings });
745
+ },
766
746
  transform(chunk, controller) {
767
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
747
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
768
748
  function enqueueError(bedrockError) {
769
749
  finishReason = "error";
770
750
  controller.enqueue({ type: "error", error: bedrockError });
@@ -796,14 +776,13 @@ var BedrockChatLanguageModel = class {
796
776
  );
797
777
  }
798
778
  if (value.metadata) {
799
- usage = {
800
- promptTokens: (_b = (_a = value.metadata.usage) == null ? void 0 : _a.inputTokens) != null ? _b : Number.NaN,
801
- completionTokens: (_d = (_c = value.metadata.usage) == null ? void 0 : _c.outputTokens) != null ? _d : Number.NaN
802
- };
803
- const cacheUsage = ((_e = value.metadata.usage) == null ? void 0 : _e.cacheReadInputTokens) != null || ((_f = value.metadata.usage) == null ? void 0 : _f.cacheWriteInputTokens) != null ? {
779
+ usage.inputTokens = (_b = (_a = value.metadata.usage) == null ? void 0 : _a.inputTokens) != null ? _b : usage.inputTokens;
780
+ usage.outputTokens = (_d = (_c = value.metadata.usage) == null ? void 0 : _c.outputTokens) != null ? _d : usage.outputTokens;
781
+ usage.totalTokens = ((_e = usage.inputTokens) != null ? _e : 0) + ((_f = usage.outputTokens) != null ? _f : 0);
782
+ usage.cachedInputTokens = (_h = (_g = value.metadata.usage) == null ? void 0 : _g.cacheReadInputTokens) != null ? _h : usage.cachedInputTokens;
783
+ const cacheUsage = ((_i = value.metadata.usage) == null ? void 0 : _i.cacheWriteInputTokens) != null ? {
804
784
  usage: {
805
- cacheReadInputTokens: (_h = (_g = value.metadata.usage) == null ? void 0 : _g.cacheReadInputTokens) != null ? _h : Number.NaN,
806
- cacheWriteInputTokens: (_j = (_i = value.metadata.usage) == null ? void 0 : _i.cacheWriteInputTokens) != null ? _j : Number.NaN
785
+ cacheWriteInputTokens: value.metadata.usage.cacheWriteInputTokens
807
786
  }
808
787
  } : void 0;
809
788
  const trace = value.metadata.trace ? {
@@ -818,33 +797,45 @@ var BedrockChatLanguageModel = class {
818
797
  };
819
798
  }
820
799
  }
821
- if (((_k = value.contentBlockDelta) == null ? void 0 : _k.delta) && "text" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.text) {
800
+ if (((_j = value.contentBlockDelta) == null ? void 0 : _j.delta) && "text" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.text) {
822
801
  controller.enqueue({
823
- type: "text-delta",
824
- textDelta: value.contentBlockDelta.delta.text
802
+ type: "text",
803
+ text: value.contentBlockDelta.delta.text
825
804
  });
826
805
  }
827
- if (((_l = value.contentBlockDelta) == null ? void 0 : _l.delta) && "reasoningContent" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.reasoningContent) {
806
+ if (((_k = value.contentBlockDelta) == null ? void 0 : _k.delta) && "reasoningContent" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.reasoningContent) {
828
807
  const reasoningContent = value.contentBlockDelta.delta.reasoningContent;
829
808
  if ("text" in reasoningContent && reasoningContent.text) {
830
809
  controller.enqueue({
831
810
  type: "reasoning",
832
- textDelta: reasoningContent.text
811
+ text: reasoningContent.text
833
812
  });
834
813
  } else if ("signature" in reasoningContent && reasoningContent.signature) {
835
814
  controller.enqueue({
836
- type: "reasoning-signature",
837
- signature: reasoningContent.signature
815
+ type: "reasoning",
816
+ text: "",
817
+ providerMetadata: {
818
+ bedrock: {
819
+ signature: reasoningContent.signature
820
+ }
821
+ }
838
822
  });
823
+ controller.enqueue({ type: "reasoning-part-finish" });
839
824
  } else if ("data" in reasoningContent && reasoningContent.data) {
840
825
  controller.enqueue({
841
- type: "redacted-reasoning",
842
- data: reasoningContent.data
826
+ type: "reasoning",
827
+ text: "",
828
+ providerMetadata: {
829
+ bedrock: {
830
+ redactedData: reasoningContent.data
831
+ }
832
+ }
843
833
  });
834
+ controller.enqueue({ type: "reasoning-part-finish" });
844
835
  }
845
836
  }
846
837
  const contentBlockStart = value.contentBlockStart;
847
- if (((_m = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _m.toolUse) != null) {
838
+ if (((_l = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _l.toolUse) != null) {
848
839
  const toolUse = contentBlockStart.start.toolUse;
849
840
  toolCallContentBlocks[contentBlockStart.contentBlockIndex] = {
850
841
  toolCallId: toolUse.toolUseId,
@@ -855,7 +846,7 @@ var BedrockChatLanguageModel = class {
855
846
  const contentBlockDelta = value.contentBlockDelta;
856
847
  if ((contentBlockDelta == null ? void 0 : contentBlockDelta.delta) && "toolUse" in contentBlockDelta.delta && contentBlockDelta.delta.toolUse) {
857
848
  const contentBlock = toolCallContentBlocks[contentBlockDelta.contentBlockIndex];
858
- const delta = (_n = contentBlockDelta.delta.toolUse.input) != null ? _n : "";
849
+ const delta = (_m = contentBlockDelta.delta.toolUse.input) != null ? _m : "";
859
850
  controller.enqueue({
860
851
  type: "tool-call-delta",
861
852
  toolCallType: "function",
@@ -891,9 +882,8 @@ var BedrockChatLanguageModel = class {
891
882
  }
892
883
  })
893
884
  ),
894
- rawCall: { rawPrompt, rawSettings },
895
- rawResponse: { headers: responseHeaders },
896
- warnings
885
+ // TODO request?
886
+ response: { headers: responseHeaders }
897
887
  };
898
888
  }
899
889
  getUrl(modelId) {
@@ -901,124 +891,143 @@ var BedrockChatLanguageModel = class {
901
891
  return `${this.config.baseUrl()}/model/${encodedModelId}`;
902
892
  }
903
893
  };
904
- var BedrockReasoningConfigOptionsSchema = z2.object({
905
- type: z2.union([z2.literal("enabled"), z2.literal("disabled")]).nullish(),
906
- budget_tokens: z2.number().nullish(),
907
- budgetTokens: z2.number().nullish()
908
- }).nullish();
909
- var BedrockStopReasonSchema = z2.union([
910
- z2.enum(BEDROCK_STOP_REASONS),
911
- z2.string()
894
+ var BedrockStopReasonSchema = z3.union([
895
+ z3.enum(BEDROCK_STOP_REASONS),
896
+ z3.string()
912
897
  ]);
913
- var BedrockToolUseSchema = z2.object({
914
- toolUseId: z2.string(),
915
- name: z2.string(),
916
- input: z2.unknown()
898
+ var BedrockToolUseSchema = z3.object({
899
+ toolUseId: z3.string(),
900
+ name: z3.string(),
901
+ input: z3.unknown()
917
902
  });
918
- var BedrockReasoningTextSchema = z2.object({
919
- signature: z2.string().nullish(),
920
- text: z2.string()
903
+ var BedrockReasoningTextSchema = z3.object({
904
+ signature: z3.string().nullish(),
905
+ text: z3.string()
921
906
  });
922
- var BedrockRedactedReasoningSchema = z2.object({
923
- data: z2.string()
907
+ var BedrockRedactedReasoningSchema = z3.object({
908
+ data: z3.string()
924
909
  });
925
- var BedrockResponseSchema = z2.object({
926
- metrics: z2.object({
927
- latencyMs: z2.number()
910
+ var BedrockResponseSchema = z3.object({
911
+ metrics: z3.object({
912
+ latencyMs: z3.number()
928
913
  }).nullish(),
929
- output: z2.object({
930
- message: z2.object({
931
- content: z2.array(
932
- z2.object({
933
- text: z2.string().nullish(),
914
+ output: z3.object({
915
+ message: z3.object({
916
+ content: z3.array(
917
+ z3.object({
918
+ text: z3.string().nullish(),
934
919
  toolUse: BedrockToolUseSchema.nullish(),
935
- reasoningContent: z2.union([
936
- z2.object({
920
+ reasoningContent: z3.union([
921
+ z3.object({
937
922
  reasoningText: BedrockReasoningTextSchema
938
923
  }),
939
- z2.object({
924
+ z3.object({
940
925
  redactedReasoning: BedrockRedactedReasoningSchema
941
926
  })
942
927
  ]).nullish()
943
928
  })
944
929
  ),
945
- role: z2.string()
930
+ role: z3.string()
946
931
  })
947
932
  }),
948
933
  stopReason: BedrockStopReasonSchema,
949
- trace: z2.unknown().nullish(),
950
- usage: z2.object({
951
- inputTokens: z2.number(),
952
- outputTokens: z2.number(),
953
- totalTokens: z2.number(),
954
- cacheReadInputTokens: z2.number().nullish(),
955
- cacheWriteInputTokens: z2.number().nullish()
934
+ trace: z3.unknown().nullish(),
935
+ usage: z3.object({
936
+ inputTokens: z3.number(),
937
+ outputTokens: z3.number(),
938
+ totalTokens: z3.number(),
939
+ cacheReadInputTokens: z3.number().nullish(),
940
+ cacheWriteInputTokens: z3.number().nullish()
956
941
  })
957
942
  });
958
- var BedrockStreamSchema = z2.object({
959
- contentBlockDelta: z2.object({
960
- contentBlockIndex: z2.number(),
961
- delta: z2.union([
962
- z2.object({ text: z2.string() }),
963
- z2.object({ toolUse: z2.object({ input: z2.string() }) }),
964
- z2.object({
965
- reasoningContent: z2.object({ text: z2.string() })
943
+ var BedrockStreamSchema = z3.object({
944
+ contentBlockDelta: z3.object({
945
+ contentBlockIndex: z3.number(),
946
+ delta: z3.union([
947
+ z3.object({ text: z3.string() }),
948
+ z3.object({ toolUse: z3.object({ input: z3.string() }) }),
949
+ z3.object({
950
+ reasoningContent: z3.object({ text: z3.string() })
966
951
  }),
967
- z2.object({
968
- reasoningContent: z2.object({
969
- signature: z2.string()
952
+ z3.object({
953
+ reasoningContent: z3.object({
954
+ signature: z3.string()
970
955
  })
971
956
  }),
972
- z2.object({
973
- reasoningContent: z2.object({ data: z2.string() })
957
+ z3.object({
958
+ reasoningContent: z3.object({ data: z3.string() })
974
959
  })
975
960
  ]).nullish()
976
961
  }).nullish(),
977
- contentBlockStart: z2.object({
978
- contentBlockIndex: z2.number(),
979
- start: z2.object({
962
+ contentBlockStart: z3.object({
963
+ contentBlockIndex: z3.number(),
964
+ start: z3.object({
980
965
  toolUse: BedrockToolUseSchema.nullish()
981
966
  }).nullish()
982
967
  }).nullish(),
983
- contentBlockStop: z2.object({
984
- contentBlockIndex: z2.number()
968
+ contentBlockStop: z3.object({
969
+ contentBlockIndex: z3.number()
985
970
  }).nullish(),
986
- internalServerException: z2.record(z2.unknown()).nullish(),
987
- messageStop: z2.object({
988
- additionalModelResponseFields: z2.record(z2.unknown()).nullish(),
971
+ internalServerException: z3.record(z3.unknown()).nullish(),
972
+ messageStop: z3.object({
973
+ additionalModelResponseFields: z3.record(z3.unknown()).nullish(),
989
974
  stopReason: BedrockStopReasonSchema
990
975
  }).nullish(),
991
- metadata: z2.object({
992
- trace: z2.unknown().nullish(),
993
- usage: z2.object({
994
- cacheReadInputTokens: z2.number().nullish(),
995
- cacheWriteInputTokens: z2.number().nullish(),
996
- inputTokens: z2.number(),
997
- outputTokens: z2.number()
976
+ metadata: z3.object({
977
+ trace: z3.unknown().nullish(),
978
+ usage: z3.object({
979
+ cacheReadInputTokens: z3.number().nullish(),
980
+ cacheWriteInputTokens: z3.number().nullish(),
981
+ inputTokens: z3.number(),
982
+ outputTokens: z3.number()
998
983
  }).nullish()
999
984
  }).nullish(),
1000
- modelStreamErrorException: z2.record(z2.unknown()).nullish(),
1001
- throttlingException: z2.record(z2.unknown()).nullish(),
1002
- validationException: z2.record(z2.unknown()).nullish()
985
+ modelStreamErrorException: z3.record(z3.unknown()).nullish(),
986
+ throttlingException: z3.record(z3.unknown()).nullish(),
987
+ validationException: z3.record(z3.unknown()).nullish()
988
+ });
989
+ var bedrockReasoningMetadataSchema = z3.object({
990
+ signature: z3.string().optional(),
991
+ redactedData: z3.string().optional()
1003
992
  });
1004
993
 
1005
994
  // src/bedrock-embedding-model.ts
995
+ import {
996
+ TooManyEmbeddingValuesForCallError
997
+ } from "@ai-sdk/provider";
1006
998
  import {
1007
999
  combineHeaders as combineHeaders2,
1008
1000
  createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
1009
1001
  createJsonResponseHandler as createJsonResponseHandler2,
1002
+ parseProviderOptions as parseProviderOptions3,
1010
1003
  postJsonToApi as postJsonToApi2,
1011
1004
  resolve as resolve2
1012
1005
  } from "@ai-sdk/provider-utils";
1013
- import { z as z3 } from "zod";
1006
+
1007
+ // src/bedrock-embedding-options.ts
1008
+ import { z as z4 } from "zod";
1009
+ var bedrockEmbeddingProviderOptions = z4.object({
1010
+ /**
1011
+ The number of dimensions the resulting output embeddings should have (defaults to 1024).
1012
+ Only supported in amazon.titan-embed-text-v2:0.
1013
+ */
1014
+ dimensions: z4.union([z4.literal(1024), z4.literal(512), z4.literal(256)]).optional(),
1015
+ /**
1016
+ Flag indicating whether or not to normalize the output embeddings. Defaults to true
1017
+ Only supported in amazon.titan-embed-text-v2:0.
1018
+ */
1019
+ normalize: z4.boolean().optional()
1020
+ });
1021
+
1022
+ // src/bedrock-embedding-model.ts
1023
+ import { z as z5 } from "zod";
1014
1024
  var BedrockEmbeddingModel = class {
1015
- constructor(modelId, settings, config) {
1025
+ constructor(modelId, config) {
1016
1026
  this.modelId = modelId;
1017
- this.settings = settings;
1018
1027
  this.config = config;
1019
- this.specificationVersion = "v1";
1028
+ this.specificationVersion = "v2";
1020
1029
  this.provider = "amazon-bedrock";
1021
- this.maxEmbeddingsPerCall = void 0;
1030
+ this.maxEmbeddingsPerCall = 1;
1022
1031
  this.supportsParallelCalls = true;
1023
1032
  }
1024
1033
  getUrl(modelId) {
@@ -1028,50 +1037,54 @@ var BedrockEmbeddingModel = class {
1028
1037
  async doEmbed({
1029
1038
  values,
1030
1039
  headers,
1031
- abortSignal
1040
+ abortSignal,
1041
+ providerOptions
1032
1042
  }) {
1033
- const embedSingleText = async (inputText) => {
1034
- const args = {
1035
- inputText,
1036
- dimensions: this.settings.dimensions,
1037
- normalize: this.settings.normalize
1038
- };
1039
- const url = this.getUrl(this.modelId);
1040
- const { value: response } = await postJsonToApi2({
1041
- url,
1042
- headers: await resolve2(
1043
- combineHeaders2(await resolve2(this.config.headers), headers)
1044
- ),
1045
- body: args,
1046
- failedResponseHandler: createJsonErrorResponseHandler2({
1047
- errorSchema: BedrockErrorSchema,
1048
- errorToMessage: (error) => `${error.type}: ${error.message}`
1049
- }),
1050
- successfulResponseHandler: createJsonResponseHandler2(
1051
- BedrockEmbeddingResponseSchema
1052
- ),
1053
- fetch: this.config.fetch,
1054
- abortSignal
1043
+ var _a;
1044
+ if (values.length > this.maxEmbeddingsPerCall) {
1045
+ throw new TooManyEmbeddingValuesForCallError({
1046
+ provider: this.provider,
1047
+ modelId: this.modelId,
1048
+ maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
1049
+ values
1055
1050
  });
1056
- return {
1057
- embedding: response.embedding,
1058
- inputTextTokenCount: response.inputTextTokenCount
1059
- };
1051
+ }
1052
+ const bedrockOptions = (_a = await parseProviderOptions3({
1053
+ provider: "bedrock",
1054
+ providerOptions,
1055
+ schema: bedrockEmbeddingProviderOptions
1056
+ })) != null ? _a : {};
1057
+ const args = {
1058
+ inputText: values[0],
1059
+ dimensions: bedrockOptions.dimensions,
1060
+ normalize: bedrockOptions.normalize
1061
+ };
1062
+ const url = this.getUrl(this.modelId);
1063
+ const { value: response } = await postJsonToApi2({
1064
+ url,
1065
+ headers: await resolve2(
1066
+ combineHeaders2(await resolve2(this.config.headers), headers)
1067
+ ),
1068
+ body: args,
1069
+ failedResponseHandler: createJsonErrorResponseHandler2({
1070
+ errorSchema: BedrockErrorSchema,
1071
+ errorToMessage: (error) => `${error.type}: ${error.message}`
1072
+ }),
1073
+ successfulResponseHandler: createJsonResponseHandler2(
1074
+ BedrockEmbeddingResponseSchema
1075
+ ),
1076
+ fetch: this.config.fetch,
1077
+ abortSignal
1078
+ });
1079
+ return {
1080
+ embeddings: [response.embedding],
1081
+ usage: { tokens: response.inputTextTokenCount }
1060
1082
  };
1061
- const responses = await Promise.all(values.map(embedSingleText));
1062
- return responses.reduce(
1063
- (accumulated, response) => {
1064
- accumulated.embeddings.push(response.embedding);
1065
- accumulated.usage.tokens += response.inputTextTokenCount;
1066
- return accumulated;
1067
- },
1068
- { embeddings: [], usage: { tokens: 0 } }
1069
- );
1070
1083
  }
1071
1084
  };
1072
- var BedrockEmbeddingResponseSchema = z3.object({
1073
- embedding: z3.array(z3.number()),
1074
- inputTextTokenCount: z3.number()
1085
+ var BedrockEmbeddingResponseSchema = z5.object({
1086
+ embedding: z5.array(z5.number()),
1087
+ inputTextTokenCount: z5.number()
1075
1088
  });
1076
1089
 
1077
1090
  // src/bedrock-image-model.ts
@@ -1089,18 +1102,17 @@ var modelMaxImagesPerCall = {
1089
1102
  };
1090
1103
 
1091
1104
  // src/bedrock-image-model.ts
1092
- import { z as z4 } from "zod";
1105
+ import { z as z6 } from "zod";
1093
1106
  var BedrockImageModel = class {
1094
- constructor(modelId, settings, config) {
1107
+ constructor(modelId, config) {
1095
1108
  this.modelId = modelId;
1096
- this.settings = settings;
1097
1109
  this.config = config;
1098
- this.specificationVersion = "v1";
1110
+ this.specificationVersion = "v2";
1099
1111
  this.provider = "amazon-bedrock";
1100
1112
  }
1101
1113
  get maxImagesPerCall() {
1102
- var _a, _b;
1103
- return (_b = (_a = this.settings.maxImagesPerCall) != null ? _a : modelMaxImagesPerCall[this.modelId]) != null ? _b : 1;
1114
+ var _a;
1115
+ return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
1104
1116
  }
1105
1117
  getUrl(modelId) {
1106
1118
  const encodedModelId = encodeURIComponent(modelId);
@@ -1171,8 +1183,8 @@ var BedrockImageModel = class {
1171
1183
  };
1172
1184
  }
1173
1185
  };
1174
- var bedrockImageResponseSchema = z4.object({
1175
- images: z4.array(z4.string())
1186
+ var bedrockImageResponseSchema = z6.object({
1187
+ images: z6.array(z6.string())
1176
1188
  });
1177
1189
 
1178
1190
  // src/headers-utils.ts
@@ -1194,11 +1206,7 @@ function extractHeaders(headers) {
1194
1206
  return originalHeaders;
1195
1207
  }
1196
1208
  function convertHeadersToRecord(headers) {
1197
- const record = {};
1198
- headers.forEach((value, key) => {
1199
- record[key.toLowerCase()] = value;
1200
- });
1201
- return record;
1209
+ return Object.fromEntries([...headers]);
1202
1210
  }
1203
1211
 
1204
1212
  // src/bedrock-sigv4-fetch.ts
@@ -1297,34 +1305,34 @@ function createAmazonBedrock(options = {}) {
1297
1305
  })}.amazonaws.com`
1298
1306
  )) != null ? _b : `https://bedrock-runtime.us-east-1.amazonaws.com`;
1299
1307
  };
1300
- const createChatModel = (modelId, settings = {}) => {
1308
+ const createChatModel = (modelId) => {
1301
1309
  var _a;
1302
- return new BedrockChatLanguageModel(modelId, settings, {
1310
+ return new BedrockChatLanguageModel(modelId, {
1303
1311
  baseUrl: getBaseUrl,
1304
1312
  headers: (_a = options.headers) != null ? _a : {},
1305
1313
  fetch: sigv4Fetch,
1306
1314
  generateId
1307
1315
  });
1308
1316
  };
1309
- const provider = function(modelId, settings) {
1317
+ const provider = function(modelId) {
1310
1318
  if (new.target) {
1311
1319
  throw new Error(
1312
1320
  "The Amazon Bedrock model function cannot be called with the new keyword."
1313
1321
  );
1314
1322
  }
1315
- return createChatModel(modelId, settings);
1323
+ return createChatModel(modelId);
1316
1324
  };
1317
- const createEmbeddingModel = (modelId, settings = {}) => {
1325
+ const createEmbeddingModel = (modelId) => {
1318
1326
  var _a;
1319
- return new BedrockEmbeddingModel(modelId, settings, {
1327
+ return new BedrockEmbeddingModel(modelId, {
1320
1328
  baseUrl: getBaseUrl,
1321
1329
  headers: (_a = options.headers) != null ? _a : {},
1322
1330
  fetch: sigv4Fetch
1323
1331
  });
1324
1332
  };
1325
- const createImageModel = (modelId, settings = {}) => {
1333
+ const createImageModel = (modelId) => {
1326
1334
  var _a;
1327
- return new BedrockImageModel(modelId, settings, {
1335
+ return new BedrockImageModel(modelId, {
1328
1336
  baseUrl: getBaseUrl,
1329
1337
  headers: (_a = options.headers) != null ? _a : {},
1330
1338
  fetch: sigv4Fetch