@ai-sdk/amazon-bedrock 3.1.0-beta.0 → 3.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +71 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 3.1.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c5e2a7c: Support citations in amazon-bedrock-provider
|
|
8
|
+
- 3aeb791: Add Claude Sonnet 4.5 (claude-sonnet-4-5-20250929-v1:0) model support
|
|
9
|
+
|
|
10
|
+
## 3.1.0-beta.9
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- d4b2964: fix(provider/amazon-bedrock): normalise headers and body if input is of instance Request
|
|
15
|
+
|
|
16
|
+
## 3.1.0-beta.8
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [a5a8db4]
|
|
21
|
+
- @ai-sdk/anthropic@2.1.0-beta.8
|
|
22
|
+
|
|
23
|
+
## 3.1.0-beta.7
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [e1e2821]
|
|
28
|
+
- @ai-sdk/anthropic@2.1.0-beta.7
|
|
29
|
+
|
|
30
|
+
## 3.1.0-beta.6
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 8dac895: feat: `LanguageModelV3`
|
|
35
|
+
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
|
36
|
+
- Updated dependencies [8dac895]
|
|
37
|
+
- Updated dependencies [10c1322]
|
|
38
|
+
- @ai-sdk/provider-utils@3.1.0-beta.5
|
|
39
|
+
- @ai-sdk/anthropic@2.1.0-beta.6
|
|
40
|
+
- @ai-sdk/provider@2.1.0-beta.3
|
|
41
|
+
|
|
42
|
+
## 3.1.0-beta.5
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [11e4abe]
|
|
47
|
+
- Updated dependencies [afb00e3]
|
|
48
|
+
- Updated dependencies [f6603b7]
|
|
49
|
+
- Updated dependencies [fa35e95]
|
|
50
|
+
- Updated dependencies [c5440c5]
|
|
51
|
+
- @ai-sdk/anthropic@2.1.0-beta.5
|
|
52
|
+
|
|
53
|
+
## 3.1.0-beta.4
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- 4616b86: chore: update zod peer depenedency version
|
|
58
|
+
- Updated dependencies [4616b86]
|
|
59
|
+
- @ai-sdk/provider-utils@3.1.0-beta.4
|
|
60
|
+
- @ai-sdk/anthropic@2.1.0-beta.4
|
|
61
|
+
|
|
62
|
+
## 3.1.0-beta.3
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- ed329cb: feat: `Provider-V3`
|
|
67
|
+
- 522f6b8: feat: `ImageModelV3`
|
|
68
|
+
- Updated dependencies [ed329cb]
|
|
69
|
+
- Updated dependencies [522f6b8]
|
|
70
|
+
- @ai-sdk/anthropic@2.1.0-beta.3
|
|
71
|
+
- @ai-sdk/provider@2.1.0-beta.2
|
|
72
|
+
- @ai-sdk/provider-utils@3.1.0-beta.3
|
|
73
|
+
|
|
74
|
+
## 3.1.0-beta.2
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- 0c4822d: feat: `EmbeddingModelV3`
|
|
79
|
+
- 1cad0ab: feat: add provider version to user-agent header
|
|
80
|
+
- Updated dependencies [0c4822d]
|
|
81
|
+
- Updated dependencies [1cad0ab]
|
|
82
|
+
- @ai-sdk/provider@2.1.0-beta.1
|
|
83
|
+
- @ai-sdk/anthropic@2.1.0-beta.2
|
|
84
|
+
- @ai-sdk/provider-utils@3.1.0-beta.2
|
|
85
|
+
|
|
86
|
+
## 3.1.0-beta.1
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- Updated dependencies [953d0f2]
|
|
91
|
+
- Updated dependencies [cbb1d35]
|
|
92
|
+
- @ai-sdk/test-server@1.0.0-beta.0
|
|
93
|
+
- @ai-sdk/provider-utils@3.1.0-beta.1
|
|
94
|
+
- @ai-sdk/anthropic@2.1.0-beta.1
|
|
95
|
+
|
|
3
96
|
## 3.1.0-beta.0
|
|
4
97
|
|
|
5
98
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'openai.gpt-oss-120b-1:0' | 'openai.gpt-oss-20b-1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'us.amazon.nova-premier-v1:0' | 'us.amazon.nova-pro-v1:0' | 'us.amazon.nova-micro-v1:0' | 'us.amazon.nova-lite-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.meta.llama3-2-11b-instruct-v1:0' | 'us.meta.llama3-2-3b-instruct-v1:0' | 'us.meta.llama3-2-90b-instruct-v1:0' | 'us.meta.llama3-2-1b-instruct-v1:0' | 'us.meta.llama3-1-8b-instruct-v1:0' | 'us.meta.llama3-1-70b-instruct-v1:0' | 'us.meta.llama3-3-70b-instruct-v1:0' | 'us.deepseek.r1-v1:0' | 'us.mistral.pixtral-large-2502-v1:0' | 'us.meta.llama4-scout-17b-instruct-v1:0' | 'us.meta.llama4-maverick-17b-instruct-v1:0' | (string & {});
|
|
6
|
+
type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'openai.gpt-oss-120b-1:0' | 'openai.gpt-oss-20b-1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'us.amazon.nova-premier-v1:0' | 'us.amazon.nova-pro-v1:0' | 'us.amazon.nova-micro-v1:0' | 'us.amazon.nova-lite-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.meta.llama3-2-11b-instruct-v1:0' | 'us.meta.llama3-2-3b-instruct-v1:0' | 'us.meta.llama3-2-90b-instruct-v1:0' | 'us.meta.llama3-2-1b-instruct-v1:0' | 'us.meta.llama3-1-8b-instruct-v1:0' | 'us.meta.llama3-1-70b-instruct-v1:0' | 'us.meta.llama3-3-70b-instruct-v1:0' | 'us.deepseek.r1-v1:0' | 'us.mistral.pixtral-large-2502-v1:0' | 'us.meta.llama4-scout-17b-instruct-v1:0' | 'us.meta.llama4-maverick-17b-instruct-v1:0' | (string & {});
|
|
7
7
|
declare const bedrockProviderOptions: z.ZodObject<{
|
|
8
8
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
9
9
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
@@ -91,18 +91,18 @@ interface AmazonBedrockProviderSettings {
|
|
|
91
91
|
credentialProvider?: () => PromiseLike<Omit<BedrockCredentials, 'region'>>;
|
|
92
92
|
generateId?: () => string;
|
|
93
93
|
}
|
|
94
|
-
interface AmazonBedrockProvider extends
|
|
95
|
-
(modelId: BedrockChatModelId):
|
|
96
|
-
languageModel(modelId: BedrockChatModelId):
|
|
97
|
-
embedding(modelId: BedrockEmbeddingModelId):
|
|
94
|
+
interface AmazonBedrockProvider extends ProviderV3 {
|
|
95
|
+
(modelId: BedrockChatModelId): LanguageModelV3;
|
|
96
|
+
languageModel(modelId: BedrockChatModelId): LanguageModelV3;
|
|
97
|
+
embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV3<string>;
|
|
98
98
|
/**
|
|
99
99
|
Creates a model for image generation.
|
|
100
100
|
*/
|
|
101
|
-
image(modelId: BedrockImageModelId):
|
|
101
|
+
image(modelId: BedrockImageModelId): ImageModelV3;
|
|
102
102
|
/**
|
|
103
103
|
Creates a model for image generation.
|
|
104
104
|
*/
|
|
105
|
-
imageModel(modelId: BedrockImageModelId):
|
|
105
|
+
imageModel(modelId: BedrockImageModelId): ImageModelV3;
|
|
106
106
|
/**
|
|
107
107
|
Anthropic-specific tools that can be used with Anthropic models on Bedrock.
|
|
108
108
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'openai.gpt-oss-120b-1:0' | 'openai.gpt-oss-20b-1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'us.amazon.nova-premier-v1:0' | 'us.amazon.nova-pro-v1:0' | 'us.amazon.nova-micro-v1:0' | 'us.amazon.nova-lite-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.meta.llama3-2-11b-instruct-v1:0' | 'us.meta.llama3-2-3b-instruct-v1:0' | 'us.meta.llama3-2-90b-instruct-v1:0' | 'us.meta.llama3-2-1b-instruct-v1:0' | 'us.meta.llama3-1-8b-instruct-v1:0' | 'us.meta.llama3-1-70b-instruct-v1:0' | 'us.meta.llama3-3-70b-instruct-v1:0' | 'us.deepseek.r1-v1:0' | 'us.mistral.pixtral-large-2502-v1:0' | 'us.meta.llama4-scout-17b-instruct-v1:0' | 'us.meta.llama4-maverick-17b-instruct-v1:0' | (string & {});
|
|
6
|
+
type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'openai.gpt-oss-120b-1:0' | 'openai.gpt-oss-20b-1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'us.amazon.nova-premier-v1:0' | 'us.amazon.nova-pro-v1:0' | 'us.amazon.nova-micro-v1:0' | 'us.amazon.nova-lite-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.meta.llama3-2-11b-instruct-v1:0' | 'us.meta.llama3-2-3b-instruct-v1:0' | 'us.meta.llama3-2-90b-instruct-v1:0' | 'us.meta.llama3-2-1b-instruct-v1:0' | 'us.meta.llama3-1-8b-instruct-v1:0' | 'us.meta.llama3-1-70b-instruct-v1:0' | 'us.meta.llama3-3-70b-instruct-v1:0' | 'us.deepseek.r1-v1:0' | 'us.mistral.pixtral-large-2502-v1:0' | 'us.meta.llama4-scout-17b-instruct-v1:0' | 'us.meta.llama4-maverick-17b-instruct-v1:0' | (string & {});
|
|
7
7
|
declare const bedrockProviderOptions: z.ZodObject<{
|
|
8
8
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
9
9
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
@@ -91,18 +91,18 @@ interface AmazonBedrockProviderSettings {
|
|
|
91
91
|
credentialProvider?: () => PromiseLike<Omit<BedrockCredentials, 'region'>>;
|
|
92
92
|
generateId?: () => string;
|
|
93
93
|
}
|
|
94
|
-
interface AmazonBedrockProvider extends
|
|
95
|
-
(modelId: BedrockChatModelId):
|
|
96
|
-
languageModel(modelId: BedrockChatModelId):
|
|
97
|
-
embedding(modelId: BedrockEmbeddingModelId):
|
|
94
|
+
interface AmazonBedrockProvider extends ProviderV3 {
|
|
95
|
+
(modelId: BedrockChatModelId): LanguageModelV3;
|
|
96
|
+
languageModel(modelId: BedrockChatModelId): LanguageModelV3;
|
|
97
|
+
embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV3<string>;
|
|
98
98
|
/**
|
|
99
99
|
Creates a model for image generation.
|
|
100
100
|
*/
|
|
101
|
-
image(modelId: BedrockImageModelId):
|
|
101
|
+
image(modelId: BedrockImageModelId): ImageModelV3;
|
|
102
102
|
/**
|
|
103
103
|
Creates a model for image generation.
|
|
104
104
|
*/
|
|
105
|
-
imageModel(modelId: BedrockImageModelId):
|
|
105
|
+
imageModel(modelId: BedrockImageModelId): ImageModelV3;
|
|
106
106
|
/**
|
|
107
107
|
Anthropic-specific tools that can be used with Anthropic models on Bedrock.
|
|
108
108
|
*/
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/bedrock-provider.ts
|
|
30
30
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
31
|
+
|
|
32
|
+
// src/version.ts
|
|
33
|
+
var VERSION = true ? "3.1.0-beta.10" : "0.0.0-test";
|
|
34
|
+
|
|
35
|
+
// src/bedrock-provider.ts
|
|
31
36
|
var import_internal2 = require("@ai-sdk/anthropic/internal");
|
|
32
37
|
|
|
33
38
|
// src/bedrock-chat-language-model.ts
|
|
@@ -70,6 +75,18 @@ var BEDROCK_DOCUMENT_MIME_TYPES = {
|
|
|
70
75
|
|
|
71
76
|
// src/bedrock-chat-options.ts
|
|
72
77
|
var import_v4 = require("zod/v4");
|
|
78
|
+
var bedrockFilePartProviderOptions = import_v4.z.object({
|
|
79
|
+
/**
|
|
80
|
+
* Citation configuration for this document.
|
|
81
|
+
* When enabled, this document will generate citations in the response.
|
|
82
|
+
*/
|
|
83
|
+
citations: import_v4.z.object({
|
|
84
|
+
/**
|
|
85
|
+
* Enable citations for this document
|
|
86
|
+
*/
|
|
87
|
+
enabled: import_v4.z.boolean()
|
|
88
|
+
}).optional()
|
|
89
|
+
});
|
|
73
90
|
var bedrockProviderOptions = import_v4.z.object({
|
|
74
91
|
/**
|
|
75
92
|
* Additional inference parameters that the model supports,
|
|
@@ -306,6 +323,15 @@ function getCachePoint(providerMetadata) {
|
|
|
306
323
|
var _a;
|
|
307
324
|
return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
|
|
308
325
|
}
|
|
326
|
+
async function shouldEnableCitations(providerMetadata) {
|
|
327
|
+
var _a, _b;
|
|
328
|
+
const bedrockOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
329
|
+
provider: "bedrock",
|
|
330
|
+
providerOptions: providerMetadata,
|
|
331
|
+
schema: bedrockFilePartProviderOptions
|
|
332
|
+
});
|
|
333
|
+
return (_b = (_a = bedrockOptions == null ? void 0 : bedrockOptions.citations) == null ? void 0 : _a.enabled) != null ? _b : false;
|
|
334
|
+
}
|
|
309
335
|
async function convertToBedrockChatMessages(prompt) {
|
|
310
336
|
const blocks = groupIntoBlocks(prompt);
|
|
311
337
|
let system = [];
|
|
@@ -366,11 +392,17 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
366
392
|
message: "File mime type is required in user message part content"
|
|
367
393
|
});
|
|
368
394
|
}
|
|
395
|
+
const enableCitations = await shouldEnableCitations(
|
|
396
|
+
part.providerOptions
|
|
397
|
+
);
|
|
369
398
|
bedrockContent.push({
|
|
370
399
|
document: {
|
|
371
400
|
format: getBedrockDocumentFormat(part.mediaType),
|
|
372
401
|
name: generateDocumentName(),
|
|
373
|
-
source: { bytes: (0, import_provider_utils3.convertToBase64)(part.data) }
|
|
402
|
+
source: { bytes: (0, import_provider_utils3.convertToBase64)(part.data) },
|
|
403
|
+
...enableCitations && {
|
|
404
|
+
citations: { enabled: true }
|
|
405
|
+
}
|
|
374
406
|
}
|
|
375
407
|
});
|
|
376
408
|
}
|
|
@@ -633,7 +665,7 @@ var BedrockChatLanguageModel = class {
|
|
|
633
665
|
constructor(modelId, config) {
|
|
634
666
|
this.modelId = modelId;
|
|
635
667
|
this.config = config;
|
|
636
|
-
this.specificationVersion = "
|
|
668
|
+
this.specificationVersion = "v3";
|
|
637
669
|
this.provider = "amazon-bedrock";
|
|
638
670
|
this.supportedUrls = {
|
|
639
671
|
// no supported urls for bedrock
|
|
@@ -1304,7 +1336,7 @@ var BedrockEmbeddingModel = class {
|
|
|
1304
1336
|
constructor(modelId, config) {
|
|
1305
1337
|
this.modelId = modelId;
|
|
1306
1338
|
this.config = config;
|
|
1307
|
-
this.specificationVersion = "
|
|
1339
|
+
this.specificationVersion = "v3";
|
|
1308
1340
|
this.provider = "amazon-bedrock";
|
|
1309
1341
|
this.maxEmbeddingsPerCall = 1;
|
|
1310
1342
|
this.supportsParallelCalls = true;
|
|
@@ -1380,7 +1412,7 @@ var BedrockImageModel = class {
|
|
|
1380
1412
|
constructor(modelId, config) {
|
|
1381
1413
|
this.modelId = modelId;
|
|
1382
1414
|
this.config = config;
|
|
1383
|
-
this.specificationVersion = "
|
|
1415
|
+
this.specificationVersion = "v3";
|
|
1384
1416
|
this.provider = "amazon-bedrock";
|
|
1385
1417
|
}
|
|
1386
1418
|
get maxImagesPerCall() {
|
|
@@ -1488,28 +1520,35 @@ function convertHeadersToRecord(headers) {
|
|
|
1488
1520
|
// src/bedrock-sigv4-fetch.ts
|
|
1489
1521
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1490
1522
|
var import_aws4fetch = require("aws4fetch");
|
|
1491
|
-
|
|
1492
|
-
// src/version.ts
|
|
1493
|
-
var VERSION = true ? "3.1.0-beta.0" : "0.0.0-test";
|
|
1494
|
-
|
|
1495
|
-
// src/bedrock-sigv4-fetch.ts
|
|
1496
1523
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
|
1497
1524
|
return async (input, init) => {
|
|
1498
|
-
var _a;
|
|
1499
|
-
const
|
|
1525
|
+
var _a, _b;
|
|
1526
|
+
const request = input instanceof Request ? input : void 0;
|
|
1527
|
+
const originalHeaders = (0, import_provider_utils7.combineHeaders)(
|
|
1528
|
+
extractHeaders(request == null ? void 0 : request.headers),
|
|
1529
|
+
extractHeaders(init == null ? void 0 : init.headers)
|
|
1530
|
+
);
|
|
1500
1531
|
const headersWithUserAgent = (0, import_provider_utils7.withUserAgentSuffix)(
|
|
1501
1532
|
originalHeaders,
|
|
1502
1533
|
`ai-sdk/amazon-bedrock/${VERSION}`,
|
|
1503
1534
|
(0, import_provider_utils7.getRuntimeEnvironmentUserAgent)()
|
|
1504
1535
|
);
|
|
1505
|
-
|
|
1536
|
+
let effectiveBody = (_a = init == null ? void 0 : init.body) != null ? _a : void 0;
|
|
1537
|
+
if (effectiveBody === void 0 && request && request.body !== null) {
|
|
1538
|
+
try {
|
|
1539
|
+
effectiveBody = await request.clone().text();
|
|
1540
|
+
} catch (e) {
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
const effectiveMethod = (_b = init == null ? void 0 : init.method) != null ? _b : request == null ? void 0 : request.method;
|
|
1544
|
+
if ((effectiveMethod == null ? void 0 : effectiveMethod.toUpperCase()) !== "POST" || !effectiveBody) {
|
|
1506
1545
|
return fetch(input, {
|
|
1507
1546
|
...init,
|
|
1508
1547
|
headers: headersWithUserAgent
|
|
1509
1548
|
});
|
|
1510
1549
|
}
|
|
1511
1550
|
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
1512
|
-
const body = prepareBodyString(
|
|
1551
|
+
const body = prepareBodyString(effectiveBody);
|
|
1513
1552
|
const credentials = await getCredentials();
|
|
1514
1553
|
const signer = new import_aws4fetch.AwsV4Signer({
|
|
1515
1554
|
url,
|
|
@@ -1640,15 +1679,17 @@ Original error: ${errorMessage}`
|
|
|
1640
1679
|
})}.amazonaws.com`
|
|
1641
1680
|
)) != null ? _b : `https://bedrock-runtime.us-east-1.amazonaws.com`;
|
|
1642
1681
|
};
|
|
1643
|
-
const
|
|
1682
|
+
const getHeaders = () => {
|
|
1644
1683
|
var _a;
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
headers: (_a = options.headers) != null ? _a : {},
|
|
1648
|
-
fetch: fetchFunction,
|
|
1649
|
-
generateId: import_provider_utils8.generateId
|
|
1650
|
-
});
|
|
1684
|
+
const baseHeaders = (_a = options.headers) != null ? _a : {};
|
|
1685
|
+
return (0, import_provider_utils8.withUserAgentSuffix)(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION}`);
|
|
1651
1686
|
};
|
|
1687
|
+
const createChatModel = (modelId) => new BedrockChatLanguageModel(modelId, {
|
|
1688
|
+
baseUrl: getBaseUrl,
|
|
1689
|
+
headers: getHeaders,
|
|
1690
|
+
fetch: fetchFunction,
|
|
1691
|
+
generateId: import_provider_utils8.generateId
|
|
1692
|
+
});
|
|
1652
1693
|
const provider = function(modelId) {
|
|
1653
1694
|
if (new.target) {
|
|
1654
1695
|
throw new Error(
|
|
@@ -1657,22 +1698,16 @@ Original error: ${errorMessage}`
|
|
|
1657
1698
|
}
|
|
1658
1699
|
return createChatModel(modelId);
|
|
1659
1700
|
};
|
|
1660
|
-
const createEmbeddingModel = (modelId) => {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
return new BedrockImageModel(modelId, {
|
|
1671
|
-
baseUrl: getBaseUrl,
|
|
1672
|
-
headers: (_a = options.headers) != null ? _a : {},
|
|
1673
|
-
fetch: fetchFunction
|
|
1674
|
-
});
|
|
1675
|
-
};
|
|
1701
|
+
const createEmbeddingModel = (modelId) => new BedrockEmbeddingModel(modelId, {
|
|
1702
|
+
baseUrl: getBaseUrl,
|
|
1703
|
+
headers: getHeaders,
|
|
1704
|
+
fetch: fetchFunction
|
|
1705
|
+
});
|
|
1706
|
+
const createImageModel = (modelId) => new BedrockImageModel(modelId, {
|
|
1707
|
+
baseUrl: getBaseUrl,
|
|
1708
|
+
headers: getHeaders,
|
|
1709
|
+
fetch: fetchFunction
|
|
1710
|
+
});
|
|
1676
1711
|
provider.languageModel = createChatModel;
|
|
1677
1712
|
provider.embedding = createEmbeddingModel;
|
|
1678
1713
|
provider.textEmbedding = createEmbeddingModel;
|