@ai-sdk/amazon-bedrock 4.0.205 → 4.0.206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -12
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/docs/08-amazon-bedrock.mdx +13 -0
- package/package.json +1 -1
- package/src/bedrock-chat-language-model.ts +71 -9
package/dist/mantle/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
35
35
|
var import_aws4fetch = require("aws4fetch");
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = true ? "4.0.
|
|
38
|
+
var VERSION = true ? "4.0.206" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/mantle/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { AwsV4Signer } from "aws4fetch";
|
|
24
24
|
|
|
25
25
|
// src/version.ts
|
|
26
|
-
var VERSION = true ? "4.0.
|
|
26
|
+
var VERSION = true ? "4.0.206" : "0.0.0-test";
|
|
27
27
|
|
|
28
28
|
// src/bedrock-sigv4-fetch.ts
|
|
29
29
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
|
@@ -626,6 +626,19 @@ final text. The provider therefore adds `budgetTokens` to `maxOutputTokens`
|
|
|
626
626
|
when setting `maxTokens`. When `maxOutputTokens` is omitted, the provider adds
|
|
627
627
|
`budgetTokens` to the default of `4096`.
|
|
628
628
|
|
|
629
|
+
To disable Anthropic thinking, set
|
|
630
|
+
`providerOptions.bedrock.reasoningConfig: { type: 'disabled' }`. The provider
|
|
631
|
+
sends `thinking: { type: 'disabled' }` for models that support it, and omits the
|
|
632
|
+
field for Claude 3.5 and earlier. Disabled thinking does not add a thinking
|
|
633
|
+
budget or display setting.
|
|
634
|
+
|
|
635
|
+
For models that require thinking, the provider uses `between_tools` when
|
|
636
|
+
supported, or adaptive thinking otherwise, and returns an unsupported-setting
|
|
637
|
+
warning. Explicit `maxReasoningEffort` takes precedence over raw
|
|
638
|
+
`additionalModelRequestFields.output_config.effort`. When a model rejects
|
|
639
|
+
disabled or `between_tools` thinking at `xhigh` or `max` effort, the provider
|
|
640
|
+
lowers the effort to `high` with a warning.
|
|
641
|
+
|
|
629
642
|
See [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details
|
|
630
643
|
on how to integrate reasoning into your chatbot.
|
|
631
644
|
|
package/package.json
CHANGED
|
@@ -188,16 +188,74 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
188
188
|
const isOpenAIModel = openAIModelId != null;
|
|
189
189
|
const isOpenAIGptOssModel =
|
|
190
190
|
openAIModelId?.startsWith('openai.gpt-oss-') ?? false;
|
|
191
|
-
const isThinkingEnabled =
|
|
192
|
-
bedrockOptions.reasoningConfig?.type === 'enabled' ||
|
|
193
|
-
bedrockOptions.reasoningConfig?.type === 'adaptive';
|
|
194
191
|
|
|
195
192
|
const {
|
|
196
193
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
197
194
|
rejectsForcedToolUse,
|
|
195
|
+
rejectsThinkingDisabled,
|
|
196
|
+
rejectsThinkingDisabledAboveHighEffort,
|
|
197
|
+
supportsBetweenToolsThinking,
|
|
198
198
|
isKnownModel,
|
|
199
199
|
} = getModelCapabilities(this.modelId);
|
|
200
200
|
|
|
201
|
+
let thinkingType:
|
|
202
|
+
| 'enabled'
|
|
203
|
+
| 'disabled'
|
|
204
|
+
| 'adaptive'
|
|
205
|
+
| 'between_tools'
|
|
206
|
+
| undefined = bedrockOptions.reasoningConfig?.type;
|
|
207
|
+
let maxReasoningEffort = bedrockOptions.reasoningConfig?.maxReasoningEffort;
|
|
208
|
+
|
|
209
|
+
if (isAnthropicModel && thinkingType === 'disabled') {
|
|
210
|
+
if (
|
|
211
|
+
/claude-(?:instant|v?2|3-(?:5-)?(?:haiku|sonnet|opus))(?=[-.:]|$)/.test(
|
|
212
|
+
this.modelId,
|
|
213
|
+
)
|
|
214
|
+
) {
|
|
215
|
+
// Claude 3.5 and earlier do not accept a thinking field, even disabled.
|
|
216
|
+
thinkingType = undefined;
|
|
217
|
+
} else if (rejectsThinkingDisabled) {
|
|
218
|
+
thinkingType = supportsBetweenToolsThinking
|
|
219
|
+
? 'between_tools'
|
|
220
|
+
: 'adaptive';
|
|
221
|
+
warnings.push({
|
|
222
|
+
type: 'unsupported',
|
|
223
|
+
feature: 'providerOptions.bedrock.reasoningConfig',
|
|
224
|
+
details:
|
|
225
|
+
`thinking cannot be disabled for ${this.modelId}. ` +
|
|
226
|
+
`Using '${thinkingType}' thinking instead.`,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const effort =
|
|
231
|
+
maxReasoningEffort ??
|
|
232
|
+
bedrockOptions.additionalModelRequestFields?.output_config?.effort;
|
|
233
|
+
|
|
234
|
+
if (
|
|
235
|
+
((thinkingType === 'disabled' &&
|
|
236
|
+
rejectsThinkingDisabledAboveHighEffort) ||
|
|
237
|
+
thinkingType === 'between_tools') &&
|
|
238
|
+
(effort === 'xhigh' || effort === 'max')
|
|
239
|
+
) {
|
|
240
|
+
warnings.push({
|
|
241
|
+
type: 'unsupported',
|
|
242
|
+
feature:
|
|
243
|
+
maxReasoningEffort != null
|
|
244
|
+
? 'providerOptions.bedrock.reasoningConfig.maxReasoningEffort'
|
|
245
|
+
: 'providerOptions.bedrock.additionalModelRequestFields.output_config.effort',
|
|
246
|
+
details:
|
|
247
|
+
`effort '${effort}' is not supported by ${this.modelId} with '${thinkingType}' thinking. ` +
|
|
248
|
+
`The effort has been lowered to 'high'.`,
|
|
249
|
+
});
|
|
250
|
+
maxReasoningEffort = 'high';
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const isThinkingEnabled =
|
|
255
|
+
thinkingType === 'enabled' ||
|
|
256
|
+
thinkingType === 'adaptive' ||
|
|
257
|
+
thinkingType === 'between_tools';
|
|
258
|
+
|
|
201
259
|
const structuredOutputMode =
|
|
202
260
|
bedrockOptions.structuredOutputMode ??
|
|
203
261
|
anthropicOptions?.structuredOutputMode ??
|
|
@@ -304,7 +362,6 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
304
362
|
};
|
|
305
363
|
}
|
|
306
364
|
|
|
307
|
-
const thinkingType = bedrockOptions.reasoningConfig?.type;
|
|
308
365
|
const thinkingBudget =
|
|
309
366
|
thinkingType === 'enabled'
|
|
310
367
|
? bedrockOptions.reasoningConfig?.budgetTokens
|
|
@@ -323,7 +380,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
323
380
|
...(stopSequences != null && { stopSequences }),
|
|
324
381
|
};
|
|
325
382
|
|
|
326
|
-
if (
|
|
383
|
+
if (isAnthropicModel) {
|
|
327
384
|
if (thinkingBudget != null) {
|
|
328
385
|
if (inferenceConfig.maxTokens != null) {
|
|
329
386
|
inferenceConfig.maxTokens += thinkingBudget;
|
|
@@ -345,8 +402,16 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
345
402
|
...(thinkingDisplay != null && { display: thinkingDisplay }),
|
|
346
403
|
},
|
|
347
404
|
};
|
|
405
|
+
} else if (
|
|
406
|
+
thinkingType === 'disabled' ||
|
|
407
|
+
thinkingType === 'between_tools'
|
|
408
|
+
) {
|
|
409
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
410
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
411
|
+
thinking: { type: thinkingType },
|
|
412
|
+
};
|
|
348
413
|
}
|
|
349
|
-
} else
|
|
414
|
+
} else {
|
|
350
415
|
if (bedrockOptions.reasoningConfig?.budgetTokens != null) {
|
|
351
416
|
warnings.push({
|
|
352
417
|
type: 'unsupported',
|
|
@@ -365,9 +430,6 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
365
430
|
}
|
|
366
431
|
}
|
|
367
432
|
|
|
368
|
-
const maxReasoningEffort =
|
|
369
|
-
bedrockOptions.reasoningConfig?.maxReasoningEffort;
|
|
370
|
-
|
|
371
433
|
if (maxReasoningEffort != null) {
|
|
372
434
|
if (isAnthropicModel) {
|
|
373
435
|
bedrockOptions.additionalModelRequestFields = {
|