@ai-sdk/amazon-bedrock 5.0.119 → 5.0.121
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 +29 -0
- package/dist/anthropic/index.js +3 -3
- package/dist/anthropic/index.js.map +1 -1
- package/dist/index.d.ts +10 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -24
- 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 +52 -4
- package/package.json +6 -5
- package/src/amazon-bedrock-chat-language-model-options.ts +41 -24
- package/src/amazon-bedrock-chat-language-model.ts +82 -68
- package/src/amazon-bedrock-embedding-model-options.ts +84 -60
- package/src/amazon-bedrock-embedding-model.ts +30 -24
- package/src/amazon-bedrock-error.ts +13 -5
- package/src/amazon-bedrock-image-model.ts +18 -12
- package/src/amazon-bedrock-reasoning-metadata.ts +15 -6
- package/src/anthropic/amazon-bedrock-anthropic-fetch.ts +9 -3
|
@@ -4,6 +4,8 @@ import type {
|
|
|
4
4
|
SharedV4Warning,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import {
|
|
7
|
+
lazySchema,
|
|
8
|
+
zodSchema,
|
|
7
9
|
combineHeaders,
|
|
8
10
|
convertUint8ArrayToBase64,
|
|
9
11
|
createJsonResponseHandler,
|
|
@@ -323,15 +325,19 @@ function getBase64Data(file: ImageModelV4File): string {
|
|
|
323
325
|
|
|
324
326
|
// minimal version of the schema, focussed on what is needed for the implementation
|
|
325
327
|
// this approach limits breakages when the API changes and increases efficiency
|
|
326
|
-
const amazonBedrockImageResponseSchema =
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
328
|
+
const amazonBedrockImageResponseSchema = lazySchema(() =>
|
|
329
|
+
zodSchema(
|
|
330
|
+
z.object({
|
|
331
|
+
// Normal successful response
|
|
332
|
+
images: z.array(z.string()).optional(),
|
|
333
|
+
|
|
334
|
+
// Moderation response fields
|
|
335
|
+
id: z.string().optional(),
|
|
336
|
+
status: z.string().optional(),
|
|
337
|
+
result: z.unknown().optional(),
|
|
338
|
+
progress: z.unknown().optional(),
|
|
339
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
340
|
+
preview: z.unknown().optional(),
|
|
341
|
+
}),
|
|
342
|
+
),
|
|
343
|
+
);
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
|
-
export const amazonBedrockReasoningMetadataSchema =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
export const amazonBedrockReasoningMetadataSchema = lazySchema(() =>
|
|
9
|
+
zodSchema(
|
|
10
|
+
z.object({
|
|
11
|
+
signature: z.string().optional(),
|
|
12
|
+
redactedData: z.string().optional(),
|
|
13
|
+
redactedContent: z.string().optional(),
|
|
14
|
+
}),
|
|
15
|
+
),
|
|
16
|
+
);
|
|
8
17
|
|
|
9
|
-
export type AmazonBedrockReasoningMetadata =
|
|
18
|
+
export type AmazonBedrockReasoningMetadata = InferSchema<
|
|
10
19
|
typeof amazonBedrockReasoningMetadataSchema
|
|
11
20
|
>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
2
4
|
convertBase64ToUint8Array,
|
|
3
5
|
safeParseJSON,
|
|
4
6
|
type FetchFunction,
|
|
@@ -7,9 +9,13 @@ import { z } from 'zod/v4';
|
|
|
7
9
|
import { createAmazonBedrockEventStreamDecoder } from '../amazon-bedrock-event-stream-decoder';
|
|
8
10
|
import { getAmazonBedrockStreamErrorMetadata } from '../amazon-bedrock-stream-error';
|
|
9
11
|
|
|
10
|
-
const amazonBedrockErrorSchema =
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const amazonBedrockErrorSchema = lazySchema(() =>
|
|
13
|
+
zodSchema(
|
|
14
|
+
z.looseObject({
|
|
15
|
+
message: z.string().optional(),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
);
|
|
13
19
|
|
|
14
20
|
export function createAmazonBedrockAnthropicFetch(
|
|
15
21
|
baseFetch: FetchFunction,
|