@ai-sdk/amazon-bedrock 4.0.57 → 4.0.59
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 +14 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.d.mts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/docs/08-amazon-bedrock.mdx +6 -3
- package/package.json +5 -5
- package/src/bedrock-embedding-model.ts +2 -2
- package/src/bedrock-embedding-options.ts +5 -1
- package/src/index.ts +1 -0
|
@@ -784,6 +784,7 @@ You can pass them as an options argument:
|
|
|
784
784
|
|
|
785
785
|
```ts
|
|
786
786
|
import { bedrock } from '@ai-sdk/amazon-bedrock';
|
|
787
|
+
import { type AmazonBedrockEmbeddingModelOptions } from '@ai-sdk/amazon-bedrock';
|
|
787
788
|
import { embed } from 'ai';
|
|
788
789
|
|
|
789
790
|
const model = bedrock.embedding('amazon.titan-embed-text-v2:0');
|
|
@@ -795,7 +796,7 @@ const { embedding } = await embed({
|
|
|
795
796
|
bedrock: {
|
|
796
797
|
dimensions: 512, // optional, number of dimensions for the embedding
|
|
797
798
|
normalize: true, // optional, normalize the output embeddings
|
|
798
|
-
},
|
|
799
|
+
} satisfies AmazonBedrockEmbeddingModelOptions,
|
|
799
800
|
},
|
|
800
801
|
});
|
|
801
802
|
```
|
|
@@ -816,6 +817,7 @@ Amazon Nova embedding models support additional provider options:
|
|
|
816
817
|
|
|
817
818
|
```ts
|
|
818
819
|
import { bedrock } from '@ai-sdk/amazon-bedrock';
|
|
820
|
+
import { type AmazonBedrockEmbeddingModelOptions } from '@ai-sdk/amazon-bedrock';
|
|
819
821
|
import { embed } from 'ai';
|
|
820
822
|
|
|
821
823
|
const { embedding } = await embed({
|
|
@@ -826,7 +828,7 @@ const { embedding } = await embed({
|
|
|
826
828
|
embeddingDimension: 1024, // optional, number of dimensions
|
|
827
829
|
embeddingPurpose: 'TEXT_RETRIEVAL', // optional, purpose of embedding
|
|
828
830
|
truncate: 'END', // optional, truncation behavior
|
|
829
|
-
},
|
|
831
|
+
} satisfies AmazonBedrockEmbeddingModelOptions,
|
|
830
832
|
},
|
|
831
833
|
});
|
|
832
834
|
```
|
|
@@ -851,6 +853,7 @@ Cohere embedding models on Bedrock require an `inputType` and support truncation
|
|
|
851
853
|
|
|
852
854
|
```ts
|
|
853
855
|
import { bedrock } from '@ai-sdk/amazon-bedrock';
|
|
856
|
+
import { type AmazonBedrockEmbeddingModelOptions } from '@ai-sdk/amazon-bedrock';
|
|
854
857
|
import { embed } from 'ai';
|
|
855
858
|
|
|
856
859
|
const { embedding } = await embed({
|
|
@@ -860,7 +863,7 @@ const { embedding } = await embed({
|
|
|
860
863
|
bedrock: {
|
|
861
864
|
inputType: 'search_document', // required for Cohere
|
|
862
865
|
truncate: 'END', // optional, truncation behavior
|
|
863
|
-
},
|
|
866
|
+
} satisfies AmazonBedrockEmbeddingModelOptions,
|
|
864
867
|
},
|
|
865
868
|
});
|
|
866
869
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.59",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"@smithy/eventstream-codec": "^4.0.1",
|
|
39
39
|
"@smithy/util-utf8": "^4.0.0",
|
|
40
40
|
"aws4fetch": "^1.0.20",
|
|
41
|
-
"@ai-sdk/anthropic": "3.0.
|
|
41
|
+
"@ai-sdk/anthropic": "3.0.43",
|
|
42
42
|
"@ai-sdk/provider": "3.0.8",
|
|
43
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
43
|
+
"@ai-sdk/provider-utils": "4.0.15"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "20.17.24",
|
|
47
47
|
"tsup": "^8.3.0",
|
|
48
48
|
"typescript": "5.8.3",
|
|
49
49
|
"zod": "3.25.76",
|
|
50
|
-
"@
|
|
51
|
-
"@ai-
|
|
50
|
+
"@ai-sdk/test-server": "1.0.3",
|
|
51
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from '@ai-sdk/provider-utils';
|
|
15
15
|
import {
|
|
16
16
|
BedrockEmbeddingModelId,
|
|
17
|
-
|
|
17
|
+
amazonBedrockEmbeddingModelOptionsSchema,
|
|
18
18
|
} from './bedrock-embedding-options';
|
|
19
19
|
import { BedrockErrorSchema } from './bedrock-error';
|
|
20
20
|
import { z } from 'zod/v4';
|
|
@@ -63,7 +63,7 @@ export class BedrockEmbeddingModel implements EmbeddingModelV3 {
|
|
|
63
63
|
(await parseProviderOptions({
|
|
64
64
|
provider: 'bedrock',
|
|
65
65
|
providerOptions,
|
|
66
|
-
schema:
|
|
66
|
+
schema: amazonBedrockEmbeddingModelOptionsSchema,
|
|
67
67
|
})) ?? {};
|
|
68
68
|
|
|
69
69
|
// https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html
|
|
@@ -7,7 +7,7 @@ export type BedrockEmbeddingModelId =
|
|
|
7
7
|
| 'cohere.embed-multilingual-v3'
|
|
8
8
|
| (string & {});
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const amazonBedrockEmbeddingModelOptionsSchema = z.object({
|
|
11
11
|
/**
|
|
12
12
|
* The number of dimensions the resulting output embeddings should have (defaults to 1024).
|
|
13
13
|
* Only supported in amazon.titan-embed-text-v2:0.
|
|
@@ -72,3 +72,7 @@ export const bedrockEmbeddingProviderOptions = z.object({
|
|
|
72
72
|
.union([z.literal(256), z.literal(512), z.literal(1024), z.literal(1536)])
|
|
73
73
|
.optional(),
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
export type AmazonBedrockEmbeddingModelOptions = z.infer<
|
|
77
|
+
typeof amazonBedrockEmbeddingModelOptionsSchema
|
|
78
|
+
>;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { AnthropicProviderOptions } from '@ai-sdk/anthropic';
|
|
2
2
|
|
|
3
|
+
export type { AmazonBedrockEmbeddingModelOptions } from './bedrock-embedding-options';
|
|
3
4
|
export type {
|
|
4
5
|
AmazonBedrockLanguageModelOptions,
|
|
5
6
|
/** @deprecated Use `AmazonBedrockLanguageModelOptions` instead. */
|