@ai-sdk/amazon-bedrock 4.0.56 → 4.0.58
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 +13 -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 +61 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -23
- package/dist/index.mjs.map +1 -1
- package/docs/08-amazon-bedrock.mdx +21 -3
- package/package.json +3 -3
- package/src/bedrock-chat-language-model.ts +70 -10
- package/src/bedrock-embedding-model.ts +2 -2
- package/src/bedrock-embedding-options.ts +5 -1
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 4.0.58
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 242696c: feat: normalize and export provider specific model options type names for existing schemas
|
|
8
|
+
|
|
9
|
+
## 4.0.57
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 61d25a9: fix(provider/amazon-bedrock): extract response metadata from api headers
|
|
14
|
+
- 08f54fc: feat(provider/amazon-bedrock): add performanceConfig, serviceTier, and cacheDetails to provider metadata
|
|
15
|
+
|
|
3
16
|
## 4.0.56
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/anthropic/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.58" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "4.0.
|
|
27
|
+
var VERSION = true ? "4.0.58" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,37 @@ import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
|
4
4
|
import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, RerankingModelV3 } from '@ai-sdk/provider';
|
|
5
5
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
6
6
|
|
|
7
|
+
type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
|
|
8
|
+
declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
|
|
9
|
+
dimensions: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1024>, z.ZodLiteral<512>, z.ZodLiteral<256>]>>;
|
|
10
|
+
normalize: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
embeddingDimension: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<256>, z.ZodLiteral<384>, z.ZodLiteral<1024>, z.ZodLiteral<3072>]>>;
|
|
12
|
+
embeddingPurpose: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
GENERIC_INDEX: "GENERIC_INDEX";
|
|
14
|
+
TEXT_RETRIEVAL: "TEXT_RETRIEVAL";
|
|
15
|
+
IMAGE_RETRIEVAL: "IMAGE_RETRIEVAL";
|
|
16
|
+
VIDEO_RETRIEVAL: "VIDEO_RETRIEVAL";
|
|
17
|
+
DOCUMENT_RETRIEVAL: "DOCUMENT_RETRIEVAL";
|
|
18
|
+
AUDIO_RETRIEVAL: "AUDIO_RETRIEVAL";
|
|
19
|
+
GENERIC_RETRIEVAL: "GENERIC_RETRIEVAL";
|
|
20
|
+
CLASSIFICATION: "CLASSIFICATION";
|
|
21
|
+
CLUSTERING: "CLUSTERING";
|
|
22
|
+
}>>;
|
|
23
|
+
inputType: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
search_document: "search_document";
|
|
25
|
+
search_query: "search_query";
|
|
26
|
+
classification: "classification";
|
|
27
|
+
clustering: "clustering";
|
|
28
|
+
}>>;
|
|
29
|
+
truncate: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
NONE: "NONE";
|
|
31
|
+
START: "START";
|
|
32
|
+
END: "END";
|
|
33
|
+
}>>;
|
|
34
|
+
outputDimension: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<256>, z.ZodLiteral<512>, z.ZodLiteral<1024>, z.ZodLiteral<1536>]>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
type AmazonBedrockEmbeddingModelOptions = z.infer<typeof amazonBedrockEmbeddingModelOptionsSchema>;
|
|
37
|
+
|
|
7
38
|
type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | '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 & {});
|
|
8
39
|
declare const amazonBedrockLanguageModelOptions: z.ZodObject<{
|
|
9
40
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -21,8 +52,6 @@ declare const amazonBedrockLanguageModelOptions: z.ZodObject<{
|
|
|
21
52
|
}, z.core.$strip>;
|
|
22
53
|
type AmazonBedrockLanguageModelOptions = z.infer<typeof amazonBedrockLanguageModelOptions>;
|
|
23
54
|
|
|
24
|
-
type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
|
|
25
|
-
|
|
26
55
|
type BedrockImageModelId = 'amazon.nova-canvas-v1:0' | (string & {});
|
|
27
56
|
|
|
28
57
|
interface BedrockCredentials {
|
|
@@ -162,4 +191,4 @@ declare const bedrock: AmazonBedrockProvider;
|
|
|
162
191
|
|
|
163
192
|
declare const VERSION: string;
|
|
164
193
|
|
|
165
|
-
export { type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
|
|
194
|
+
export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,37 @@ import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
|
4
4
|
import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, RerankingModelV3 } from '@ai-sdk/provider';
|
|
5
5
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
6
6
|
|
|
7
|
+
type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
|
|
8
|
+
declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
|
|
9
|
+
dimensions: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1024>, z.ZodLiteral<512>, z.ZodLiteral<256>]>>;
|
|
10
|
+
normalize: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
embeddingDimension: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<256>, z.ZodLiteral<384>, z.ZodLiteral<1024>, z.ZodLiteral<3072>]>>;
|
|
12
|
+
embeddingPurpose: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
GENERIC_INDEX: "GENERIC_INDEX";
|
|
14
|
+
TEXT_RETRIEVAL: "TEXT_RETRIEVAL";
|
|
15
|
+
IMAGE_RETRIEVAL: "IMAGE_RETRIEVAL";
|
|
16
|
+
VIDEO_RETRIEVAL: "VIDEO_RETRIEVAL";
|
|
17
|
+
DOCUMENT_RETRIEVAL: "DOCUMENT_RETRIEVAL";
|
|
18
|
+
AUDIO_RETRIEVAL: "AUDIO_RETRIEVAL";
|
|
19
|
+
GENERIC_RETRIEVAL: "GENERIC_RETRIEVAL";
|
|
20
|
+
CLASSIFICATION: "CLASSIFICATION";
|
|
21
|
+
CLUSTERING: "CLUSTERING";
|
|
22
|
+
}>>;
|
|
23
|
+
inputType: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
search_document: "search_document";
|
|
25
|
+
search_query: "search_query";
|
|
26
|
+
classification: "classification";
|
|
27
|
+
clustering: "clustering";
|
|
28
|
+
}>>;
|
|
29
|
+
truncate: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
NONE: "NONE";
|
|
31
|
+
START: "START";
|
|
32
|
+
END: "END";
|
|
33
|
+
}>>;
|
|
34
|
+
outputDimension: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<256>, z.ZodLiteral<512>, z.ZodLiteral<1024>, z.ZodLiteral<1536>]>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
type AmazonBedrockEmbeddingModelOptions = z.infer<typeof amazonBedrockEmbeddingModelOptionsSchema>;
|
|
37
|
+
|
|
7
38
|
type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | '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 & {});
|
|
8
39
|
declare const amazonBedrockLanguageModelOptions: z.ZodObject<{
|
|
9
40
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -21,8 +52,6 @@ declare const amazonBedrockLanguageModelOptions: z.ZodObject<{
|
|
|
21
52
|
}, z.core.$strip>;
|
|
22
53
|
type AmazonBedrockLanguageModelOptions = z.infer<typeof amazonBedrockLanguageModelOptions>;
|
|
23
54
|
|
|
24
|
-
type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
|
|
25
|
-
|
|
26
55
|
type BedrockImageModelId = 'amazon.nova-canvas-v1:0' | (string & {});
|
|
27
56
|
|
|
28
57
|
interface BedrockCredentials {
|
|
@@ -162,4 +191,4 @@ declare const bedrock: AmazonBedrockProvider;
|
|
|
162
191
|
|
|
163
192
|
declare const VERSION: string;
|
|
164
193
|
|
|
165
|
-
export { type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
|
|
194
|
+
export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
|
package/dist/index.js
CHANGED
|
@@ -1003,7 +1003,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1003
1003
|
return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
|
|
1004
1004
|
}
|
|
1005
1005
|
async doGenerate(options) {
|
|
1006
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1006
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1007
1007
|
const {
|
|
1008
1008
|
command: args,
|
|
1009
1009
|
warnings,
|
|
@@ -1080,12 +1080,23 @@ var BedrockChatLanguageModel = class {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
1082
|
const stopSequence = (_j = (_i = (_h = response.additionalModelResponseFields) == null ? void 0 : _h.delta) == null ? void 0 : _i.stop_sequence) != null ? _j : null;
|
|
1083
|
-
const providerMetadata = response.trace || response.usage || isJsonResponseFromTool || stopSequence ? {
|
|
1083
|
+
const providerMetadata = response.trace || response.usage || response.performanceConfig || response.serviceTier || isJsonResponseFromTool || stopSequence ? {
|
|
1084
1084
|
bedrock: {
|
|
1085
1085
|
...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
|
|
1086
|
-
...
|
|
1086
|
+
...response.performanceConfig && {
|
|
1087
|
+
performanceConfig: response.performanceConfig
|
|
1088
|
+
},
|
|
1089
|
+
...response.serviceTier && {
|
|
1090
|
+
serviceTier: response.serviceTier
|
|
1091
|
+
},
|
|
1092
|
+
...(((_k = response.usage) == null ? void 0 : _k.cacheWriteInputTokens) != null || ((_l = response.usage) == null ? void 0 : _l.cacheDetails) != null) && {
|
|
1087
1093
|
usage: {
|
|
1088
|
-
|
|
1094
|
+
...response.usage.cacheWriteInputTokens != null && {
|
|
1095
|
+
cacheWriteInputTokens: response.usage.cacheWriteInputTokens
|
|
1096
|
+
},
|
|
1097
|
+
...response.usage.cacheDetails != null && {
|
|
1098
|
+
cacheDetails: response.usage.cacheDetails
|
|
1099
|
+
}
|
|
1089
1100
|
}
|
|
1090
1101
|
},
|
|
1091
1102
|
...isJsonResponseFromTool && { isJsonResponseFromTool: true },
|
|
@@ -1099,11 +1110,13 @@ var BedrockChatLanguageModel = class {
|
|
|
1099
1110
|
response.stopReason,
|
|
1100
1111
|
isJsonResponseFromTool
|
|
1101
1112
|
),
|
|
1102
|
-
raw: (
|
|
1113
|
+
raw: (_m = response.stopReason) != null ? _m : void 0
|
|
1103
1114
|
},
|
|
1104
1115
|
usage: convertBedrockUsage(response.usage),
|
|
1105
1116
|
response: {
|
|
1106
|
-
|
|
1117
|
+
id: (_n = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _n : void 0,
|
|
1118
|
+
timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
|
|
1119
|
+
modelId: this.modelId,
|
|
1107
1120
|
headers: responseHeaders
|
|
1108
1121
|
},
|
|
1109
1122
|
warnings,
|
|
@@ -1116,8 +1129,9 @@ var BedrockChatLanguageModel = class {
|
|
|
1116
1129
|
warnings,
|
|
1117
1130
|
usesJsonResponseTool
|
|
1118
1131
|
} = await this.getArgs(options);
|
|
1119
|
-
const
|
|
1120
|
-
const
|
|
1132
|
+
const modelId = this.modelId;
|
|
1133
|
+
const isMistral = isMistralModel(modelId);
|
|
1134
|
+
const url = `${this.getUrl(modelId)}/converse-stream`;
|
|
1121
1135
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
1122
1136
|
url,
|
|
1123
1137
|
headers: await this.getHeaders({ headers: options.headers }),
|
|
@@ -1143,10 +1157,17 @@ var BedrockChatLanguageModel = class {
|
|
|
1143
1157
|
stream: response.pipeThrough(
|
|
1144
1158
|
new TransformStream({
|
|
1145
1159
|
start(controller) {
|
|
1160
|
+
var _a;
|
|
1146
1161
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1162
|
+
controller.enqueue({
|
|
1163
|
+
type: "response-metadata",
|
|
1164
|
+
id: (_a = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _a : void 0,
|
|
1165
|
+
timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
|
|
1166
|
+
modelId
|
|
1167
|
+
});
|
|
1147
1168
|
},
|
|
1148
1169
|
transform(chunk, controller) {
|
|
1149
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1170
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1150
1171
|
function enqueueError(bedrockError) {
|
|
1151
1172
|
finishReason = { unified: "error", raw: void 0 };
|
|
1152
1173
|
controller.enqueue({ type: "error", error: bedrockError });
|
|
@@ -1189,24 +1210,35 @@ var BedrockChatLanguageModel = class {
|
|
|
1189
1210
|
if (value.metadata.usage) {
|
|
1190
1211
|
usage = value.metadata.usage;
|
|
1191
1212
|
}
|
|
1192
|
-
const cacheUsage = ((_e = value.metadata.usage) == null ? void 0 : _e.cacheWriteInputTokens) != null ? {
|
|
1213
|
+
const cacheUsage = ((_e = value.metadata.usage) == null ? void 0 : _e.cacheWriteInputTokens) != null || ((_f = value.metadata.usage) == null ? void 0 : _f.cacheDetails) != null ? {
|
|
1193
1214
|
usage: {
|
|
1194
|
-
|
|
1215
|
+
...((_g = value.metadata.usage) == null ? void 0 : _g.cacheWriteInputTokens) != null && {
|
|
1216
|
+
cacheWriteInputTokens: value.metadata.usage.cacheWriteInputTokens
|
|
1217
|
+
},
|
|
1218
|
+
...((_h = value.metadata.usage) == null ? void 0 : _h.cacheDetails) != null && {
|
|
1219
|
+
cacheDetails: value.metadata.usage.cacheDetails
|
|
1220
|
+
}
|
|
1195
1221
|
}
|
|
1196
1222
|
} : void 0;
|
|
1197
1223
|
const trace = value.metadata.trace ? {
|
|
1198
1224
|
trace: value.metadata.trace
|
|
1199
1225
|
} : void 0;
|
|
1200
|
-
if (cacheUsage || trace) {
|
|
1226
|
+
if (cacheUsage || trace || value.metadata.performanceConfig || value.metadata.serviceTier) {
|
|
1201
1227
|
providerMetadata = {
|
|
1202
1228
|
bedrock: {
|
|
1203
1229
|
...cacheUsage,
|
|
1204
|
-
...trace
|
|
1230
|
+
...trace,
|
|
1231
|
+
...value.metadata.performanceConfig && {
|
|
1232
|
+
performanceConfig: value.metadata.performanceConfig
|
|
1233
|
+
},
|
|
1234
|
+
...value.metadata.serviceTier && {
|
|
1235
|
+
serviceTier: value.metadata.serviceTier
|
|
1236
|
+
}
|
|
1205
1237
|
}
|
|
1206
1238
|
};
|
|
1207
1239
|
}
|
|
1208
1240
|
}
|
|
1209
|
-
if (((
|
|
1241
|
+
if (((_i = value.contentBlockStart) == null ? void 0 : _i.contentBlockIndex) != null && !((_k = (_j = value.contentBlockStart) == null ? void 0 : _j.start) == null ? void 0 : _k.toolUse)) {
|
|
1210
1242
|
const blockIndex = value.contentBlockStart.contentBlockIndex;
|
|
1211
1243
|
contentBlocks[blockIndex] = { type: "text" };
|
|
1212
1244
|
controller.enqueue({
|
|
@@ -1214,7 +1246,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1214
1246
|
id: String(blockIndex)
|
|
1215
1247
|
});
|
|
1216
1248
|
}
|
|
1217
|
-
if (((
|
|
1249
|
+
if (((_l = value.contentBlockDelta) == null ? void 0 : _l.delta) && "text" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.text) {
|
|
1218
1250
|
const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
|
|
1219
1251
|
if (contentBlocks[blockIndex] == null) {
|
|
1220
1252
|
contentBlocks[blockIndex] = { type: "text" };
|
|
@@ -1229,7 +1261,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1229
1261
|
delta: value.contentBlockDelta.delta.text
|
|
1230
1262
|
});
|
|
1231
1263
|
}
|
|
1232
|
-
if (((
|
|
1264
|
+
if (((_m = value.contentBlockStop) == null ? void 0 : _m.contentBlockIndex) != null) {
|
|
1233
1265
|
const blockIndex = value.contentBlockStop.contentBlockIndex;
|
|
1234
1266
|
const contentBlock = contentBlocks[blockIndex];
|
|
1235
1267
|
if (contentBlock != null) {
|
|
@@ -1275,7 +1307,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1275
1307
|
delete contentBlocks[blockIndex];
|
|
1276
1308
|
}
|
|
1277
1309
|
}
|
|
1278
|
-
if (((
|
|
1310
|
+
if (((_n = value.contentBlockDelta) == null ? void 0 : _n.delta) && "reasoningContent" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.reasoningContent) {
|
|
1279
1311
|
const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
|
|
1280
1312
|
const reasoningContent = value.contentBlockDelta.delta.reasoningContent;
|
|
1281
1313
|
if ("text" in reasoningContent && reasoningContent.text) {
|
|
@@ -1316,7 +1348,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1316
1348
|
}
|
|
1317
1349
|
}
|
|
1318
1350
|
const contentBlockStart = value.contentBlockStart;
|
|
1319
|
-
if (((
|
|
1351
|
+
if (((_o = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _o.toolUse) != null) {
|
|
1320
1352
|
const toolUse = contentBlockStart.start.toolUse;
|
|
1321
1353
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
1322
1354
|
const isJsonResponseTool = usesJsonResponseTool && toolUse.name === "json";
|
|
@@ -1344,7 +1376,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1344
1376
|
const blockIndex = contentBlockDelta.contentBlockIndex;
|
|
1345
1377
|
const contentBlock = contentBlocks[blockIndex];
|
|
1346
1378
|
if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
|
|
1347
|
-
const delta = (
|
|
1379
|
+
const delta = (_p = contentBlockDelta.delta.toolUse.input) != null ? _p : "";
|
|
1348
1380
|
if (!contentBlock.isJsonResponseTool) {
|
|
1349
1381
|
controller.enqueue({
|
|
1350
1382
|
type: "tool-input-delta",
|
|
@@ -1442,12 +1474,15 @@ var BedrockResponseSchema = import_v43.z.object({
|
|
|
1442
1474
|
stopReason: BedrockStopReasonSchema,
|
|
1443
1475
|
additionalModelResponseFields: BedrockAdditionalModelResponseFieldsSchema.nullish(),
|
|
1444
1476
|
trace: import_v43.z.unknown().nullish(),
|
|
1477
|
+
performanceConfig: import_v43.z.object({ latency: import_v43.z.string() }).nullish(),
|
|
1478
|
+
serviceTier: import_v43.z.object({ type: import_v43.z.string() }).nullish(),
|
|
1445
1479
|
usage: import_v43.z.object({
|
|
1446
1480
|
inputTokens: import_v43.z.number(),
|
|
1447
1481
|
outputTokens: import_v43.z.number(),
|
|
1448
1482
|
totalTokens: import_v43.z.number(),
|
|
1449
1483
|
cacheReadInputTokens: import_v43.z.number().nullish(),
|
|
1450
|
-
cacheWriteInputTokens: import_v43.z.number().nullish()
|
|
1484
|
+
cacheWriteInputTokens: import_v43.z.number().nullish(),
|
|
1485
|
+
cacheDetails: import_v43.z.array(import_v43.z.object({ inputTokens: import_v43.z.number(), ttl: import_v43.z.string() })).nullish()
|
|
1451
1486
|
})
|
|
1452
1487
|
});
|
|
1453
1488
|
var BedrockStreamSchema = import_v43.z.object({
|
|
@@ -1485,9 +1520,12 @@ var BedrockStreamSchema = import_v43.z.object({
|
|
|
1485
1520
|
}).nullish(),
|
|
1486
1521
|
metadata: import_v43.z.object({
|
|
1487
1522
|
trace: import_v43.z.unknown().nullish(),
|
|
1523
|
+
performanceConfig: import_v43.z.object({ latency: import_v43.z.string() }).nullish(),
|
|
1524
|
+
serviceTier: import_v43.z.object({ type: import_v43.z.string() }).nullish(),
|
|
1488
1525
|
usage: import_v43.z.object({
|
|
1489
1526
|
cacheReadInputTokens: import_v43.z.number().nullish(),
|
|
1490
1527
|
cacheWriteInputTokens: import_v43.z.number().nullish(),
|
|
1528
|
+
cacheDetails: import_v43.z.array(import_v43.z.object({ inputTokens: import_v43.z.number(), ttl: import_v43.z.string() })).nullish(),
|
|
1491
1529
|
inputTokens: import_v43.z.number(),
|
|
1492
1530
|
outputTokens: import_v43.z.number()
|
|
1493
1531
|
}).nullish()
|
|
@@ -1507,7 +1545,7 @@ var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
|
1507
1545
|
|
|
1508
1546
|
// src/bedrock-embedding-options.ts
|
|
1509
1547
|
var import_v44 = require("zod/v4");
|
|
1510
|
-
var
|
|
1548
|
+
var amazonBedrockEmbeddingModelOptionsSchema = import_v44.z.object({
|
|
1511
1549
|
/**
|
|
1512
1550
|
* The number of dimensions the resulting output embeddings should have (defaults to 1024).
|
|
1513
1551
|
* Only supported in amazon.titan-embed-text-v2:0.
|
|
@@ -1590,7 +1628,7 @@ var BedrockEmbeddingModel = class {
|
|
|
1590
1628
|
const bedrockOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
1591
1629
|
provider: "bedrock",
|
|
1592
1630
|
providerOptions,
|
|
1593
|
-
schema:
|
|
1631
|
+
schema: amazonBedrockEmbeddingModelOptionsSchema
|
|
1594
1632
|
})) != null ? _a : {};
|
|
1595
1633
|
const isNovaModel = this.modelId.startsWith("amazon.nova-") && this.modelId.includes("embed");
|
|
1596
1634
|
const isCohereModel = this.modelId.startsWith("cohere.embed-");
|
|
@@ -1894,7 +1932,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1894
1932
|
var import_aws4fetch = require("aws4fetch");
|
|
1895
1933
|
|
|
1896
1934
|
// src/version.ts
|
|
1897
|
-
var VERSION = true ? "4.0.
|
|
1935
|
+
var VERSION = true ? "4.0.58" : "0.0.0-test";
|
|
1898
1936
|
|
|
1899
1937
|
// src/bedrock-sigv4-fetch.ts
|
|
1900
1938
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|