@ai-sdk/amazon-bedrock 5.0.127 → 5.0.128
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 +21 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/index.js +36 -27
- package/dist/index.js.map +1 -1
- package/dist/mantle/index.cjs +1 -1
- package/dist/mantle/index.js +1 -1
- package/docs/08-amazon-bedrock.mdx +1 -1
- package/package.json +4 -4
- package/src/amazon-bedrock-chat-language-model.ts +59 -37
package/dist/mantle/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let _ai_sdk_provider = require("@ai-sdk/provider");
|
|
|
4
4
|
let _ai_sdk_provider_utils = require("@ai-sdk/provider-utils");
|
|
5
5
|
let aws4fetch = require("aws4fetch");
|
|
6
6
|
//#region src/version.ts
|
|
7
|
-
const VERSION = "5.0.
|
|
7
|
+
const VERSION = "5.0.128";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/amazon-bedrock-sigv4-fetch.ts
|
|
10
10
|
/**
|
package/dist/mantle/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
|
|
|
3
3
|
import { combineHeaders, getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSetting, loadSetting, normalizeHeaders, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
|
|
4
4
|
import { AwsV4Signer } from "aws4fetch";
|
|
5
5
|
//#region src/version.ts
|
|
6
|
-
const VERSION = "5.0.
|
|
6
|
+
const VERSION = "5.0.128";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/amazon-bedrock-sigv4-fetch.ts
|
|
9
9
|
/**
|
|
@@ -683,7 +683,7 @@ Amazon Bedrock supports model creator-specific reasoning features:
|
|
|
683
683
|
- Anthropic (e.g. `claude-sonnet-4-5-20250929`): enable via the `reasoningConfig` provider option and specifying a thinking budget in tokens (minimum: `1024`, maximum: `64000`).
|
|
684
684
|
- Amazon (e.g. `us.amazon.nova-2-lite-v1:0`): enable via the `reasoningConfig` provider option and specifying a maximum reasoning effort level (`'low' | 'medium' | 'high'`).
|
|
685
685
|
|
|
686
|
-
You can also use the top-level `reasoning` parameter.
|
|
686
|
+
You can also use the top-level `reasoning` parameter.
|
|
687
687
|
|
|
688
688
|
Bedrock combines partial `providerOptions.amazonBedrock.reasoningConfig` with
|
|
689
689
|
portable reasoning, preserving explicit values and deriving missing fields for
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.128",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@ai-sdk/anthropic": "4.0.
|
|
45
|
-
"@ai-sdk/openai": "4.0.
|
|
44
|
+
"@ai-sdk/anthropic": "4.0.92",
|
|
45
|
+
"@ai-sdk/openai": "4.0.105",
|
|
46
46
|
"@ai-sdk/provider": "4.0.34",
|
|
47
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
47
|
+
"@ai-sdk/provider-utils": "5.0.71",
|
|
48
48
|
"@smithy/eventstream-codec": "^4.3.3",
|
|
49
49
|
"@smithy/util-utf8": "^4.3.3",
|
|
50
50
|
"aws4fetch": "^1.0.20"
|
|
@@ -335,17 +335,15 @@ export class AmazonBedrockChatLanguageModel implements LanguageModelV4 {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
});
|
|
348
|
-
}
|
|
338
|
+
warnings.push({
|
|
339
|
+
type: hasExplicitDisabledThinking ? 'unsupported' : 'compatibility',
|
|
340
|
+
feature: hasExplicitDisabledThinking
|
|
341
|
+
? 'providerOptions.amazonBedrock.reasoningConfig'
|
|
342
|
+
: 'reasoning',
|
|
343
|
+
details:
|
|
344
|
+
`thinking cannot be disabled for ${this.modelId}. ` +
|
|
345
|
+
`Using '${thinkingType}' thinking instead.`,
|
|
346
|
+
});
|
|
349
347
|
}
|
|
350
348
|
|
|
351
349
|
const effort =
|
|
@@ -1721,27 +1719,38 @@ export {
|
|
|
1721
1719
|
type AmazonBedrockReasoningMetadata,
|
|
1722
1720
|
} from './amazon-bedrock-reasoning-metadata';
|
|
1723
1721
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
minimal: 'low',
|
|
1722
|
+
// Effort maps only list the supported levels. Other levels are mapped to the
|
|
1723
|
+
// closest supported level by mapReasoningToProviderEffort.
|
|
1724
|
+
const amazonBedrockReasoningEffortMap = {
|
|
1728
1725
|
low: 'low',
|
|
1729
1726
|
medium: 'medium',
|
|
1730
1727
|
high: 'high',
|
|
1731
|
-
xhigh: 'max',
|
|
1732
1728
|
max: 'max',
|
|
1733
|
-
};
|
|
1729
|
+
} as const;
|
|
1734
1730
|
|
|
1735
|
-
const amazonNovaReasoningEffortMap
|
|
1736
|
-
Record<string, 'low' | 'medium' | 'high'>
|
|
1737
|
-
> = {
|
|
1738
|
-
minimal: 'low',
|
|
1731
|
+
const amazonNovaReasoningEffortMap = {
|
|
1739
1732
|
low: 'low',
|
|
1740
1733
|
medium: 'medium',
|
|
1741
1734
|
high: 'high',
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1735
|
+
} as const;
|
|
1736
|
+
|
|
1737
|
+
const openAIGptOssReasoningEffortMap = {
|
|
1738
|
+
low: 'low',
|
|
1739
|
+
medium: 'medium',
|
|
1740
|
+
high: 'high',
|
|
1741
|
+
} as const;
|
|
1742
|
+
|
|
1743
|
+
// The reasoning efforts of other OpenAI models are not known, so reasoning
|
|
1744
|
+
// values are sent directly.
|
|
1745
|
+
const openAIReasoningEffortMap = {
|
|
1746
|
+
none: 'none',
|
|
1747
|
+
minimal: 'minimal',
|
|
1748
|
+
low: 'low',
|
|
1749
|
+
medium: 'medium',
|
|
1750
|
+
high: 'high',
|
|
1751
|
+
xhigh: 'xhigh',
|
|
1752
|
+
max: 'max',
|
|
1753
|
+
} as const;
|
|
1745
1754
|
|
|
1746
1755
|
function isNova2ReasoningModel(modelId: string): boolean {
|
|
1747
1756
|
return modelId.includes('amazon.nova-2-lite-v1:0');
|
|
@@ -1779,7 +1788,6 @@ function resolveAmazonBedrockReasoningConfig({
|
|
|
1779
1788
|
return result;
|
|
1780
1789
|
}
|
|
1781
1790
|
|
|
1782
|
-
const hasPortableReasoning = reasoning !== 'none';
|
|
1783
1791
|
const isNovaReasoningModel = isNova2ReasoningModel(modelId);
|
|
1784
1792
|
const supportsPortableReasoning =
|
|
1785
1793
|
isOpenAIModel || isNovaReasoningModel || reasoningConfig != null;
|
|
@@ -1794,7 +1802,12 @@ function resolveAmazonBedrockReasoningConfig({
|
|
|
1794
1802
|
reasoningConfig?.maxReasoningEffort ??
|
|
1795
1803
|
mapReasoningToProviderEffort({
|
|
1796
1804
|
reasoning,
|
|
1797
|
-
effortMap:
|
|
1805
|
+
effortMap: {
|
|
1806
|
+
...amazonBedrockReasoningEffortMap,
|
|
1807
|
+
...(capabilities.supportsXhighEffort && {
|
|
1808
|
+
xhigh: 'xhigh' as const,
|
|
1809
|
+
}),
|
|
1810
|
+
},
|
|
1798
1811
|
warnings,
|
|
1799
1812
|
});
|
|
1800
1813
|
result.reasoningConfig = {
|
|
@@ -1811,25 +1824,34 @@ function resolveAmazonBedrockReasoningConfig({
|
|
|
1811
1824
|
maxReasoningBudget: capabilities.maxOutputTokens,
|
|
1812
1825
|
warnings,
|
|
1813
1826
|
});
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
};
|
|
1820
|
-
}
|
|
1827
|
+
result.reasoningConfig = {
|
|
1828
|
+
...reasoningConfig,
|
|
1829
|
+
type: reasoningConfig?.type ?? 'enabled',
|
|
1830
|
+
budgetTokens,
|
|
1831
|
+
};
|
|
1821
1832
|
}
|
|
1822
|
-
} else if (
|
|
1833
|
+
} else if (reasoning === 'none' && isNovaReasoningModel) {
|
|
1834
|
+
// Nova 2 reasoning is disabled unless a reasoning effort is sent, so
|
|
1835
|
+
// there is nothing to add.
|
|
1836
|
+
} else {
|
|
1823
1837
|
if (supportsPortableReasoning) {
|
|
1824
1838
|
const effort =
|
|
1825
1839
|
reasoningConfig?.maxReasoningEffort ??
|
|
1826
|
-
|
|
1840
|
+
// OpenAI efforts such as 'none' are sent as `reasoning_effort` even
|
|
1841
|
+
// though they are not accepted in the reasoningConfig provider option.
|
|
1842
|
+
(mapReasoningToProviderEffort({
|
|
1827
1843
|
reasoning,
|
|
1828
1844
|
effortMap: isNovaReasoningModel
|
|
1829
1845
|
? amazonNovaReasoningEffortMap
|
|
1830
|
-
:
|
|
1846
|
+
: isOpenAIModel
|
|
1847
|
+
? modelId.includes('openai.gpt-oss-')
|
|
1848
|
+
? openAIGptOssReasoningEffortMap
|
|
1849
|
+
: openAIReasoningEffortMap
|
|
1850
|
+
: amazonBedrockReasoningEffortMap,
|
|
1831
1851
|
warnings,
|
|
1832
|
-
})
|
|
1852
|
+
}) as NonNullable<
|
|
1853
|
+
AmazonBedrockLanguageModelChatOptions['reasoningConfig']
|
|
1854
|
+
>['maxReasoningEffort']);
|
|
1833
1855
|
result.reasoningConfig = {
|
|
1834
1856
|
...reasoningConfig,
|
|
1835
1857
|
...(isNovaReasoningModel && {
|