@ai-sdk/amazon-bedrock 3.1.0-beta.9 → 4.0.0-beta.18
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 +81 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +133 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@ai-sdk/provider-utils";
|
|
9
9
|
|
|
10
10
|
// src/version.ts
|
|
11
|
-
var VERSION = true ? "
|
|
11
|
+
var VERSION = true ? "4.0.0-beta.18" : "0.0.0-test";
|
|
12
12
|
|
|
13
13
|
// src/bedrock-provider.ts
|
|
14
14
|
import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
postJsonToApi,
|
|
23
23
|
resolve
|
|
24
24
|
} from "@ai-sdk/provider-utils";
|
|
25
|
-
import
|
|
25
|
+
import * as z3 from "zod/v4";
|
|
26
26
|
|
|
27
27
|
// src/bedrock-api-types.ts
|
|
28
28
|
var BEDROCK_CACHE_POINT = {
|
|
@@ -59,7 +59,19 @@ var BEDROCK_DOCUMENT_MIME_TYPES = {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
// src/bedrock-chat-options.ts
|
|
62
|
-
import
|
|
62
|
+
import * as z from "zod/v4";
|
|
63
|
+
var bedrockFilePartProviderOptions = z.object({
|
|
64
|
+
/**
|
|
65
|
+
* Citation configuration for this document.
|
|
66
|
+
* When enabled, this document will generate citations in the response.
|
|
67
|
+
*/
|
|
68
|
+
citations: z.object({
|
|
69
|
+
/**
|
|
70
|
+
* Enable citations for this document
|
|
71
|
+
*/
|
|
72
|
+
enabled: z.boolean()
|
|
73
|
+
}).optional()
|
|
74
|
+
});
|
|
63
75
|
var bedrockProviderOptions = z.object({
|
|
64
76
|
/**
|
|
65
77
|
* Additional inference parameters that the model supports,
|
|
@@ -74,7 +86,7 @@ var bedrockProviderOptions = z.object({
|
|
|
74
86
|
});
|
|
75
87
|
|
|
76
88
|
// src/bedrock-error.ts
|
|
77
|
-
import
|
|
89
|
+
import * as z2 from "zod/v4";
|
|
78
90
|
var BedrockErrorSchema = z2.object({
|
|
79
91
|
message: z2.string(),
|
|
80
92
|
type: z2.string().nullish()
|
|
@@ -307,7 +319,17 @@ function getCachePoint(providerMetadata) {
|
|
|
307
319
|
var _a;
|
|
308
320
|
return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
|
|
309
321
|
}
|
|
322
|
+
async function shouldEnableCitations(providerMetadata) {
|
|
323
|
+
var _a, _b;
|
|
324
|
+
const bedrockOptions = await parseProviderOptions({
|
|
325
|
+
provider: "bedrock",
|
|
326
|
+
providerOptions: providerMetadata,
|
|
327
|
+
schema: bedrockFilePartProviderOptions
|
|
328
|
+
});
|
|
329
|
+
return (_b = (_a = bedrockOptions == null ? void 0 : bedrockOptions.citations) == null ? void 0 : _a.enabled) != null ? _b : false;
|
|
330
|
+
}
|
|
310
331
|
async function convertToBedrockChatMessages(prompt) {
|
|
332
|
+
var _a, _b;
|
|
311
333
|
const blocks = groupIntoBlocks(prompt);
|
|
312
334
|
let system = [];
|
|
313
335
|
const messages = [];
|
|
@@ -367,11 +389,17 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
367
389
|
message: "File mime type is required in user message part content"
|
|
368
390
|
});
|
|
369
391
|
}
|
|
392
|
+
const enableCitations = await shouldEnableCitations(
|
|
393
|
+
part.providerOptions
|
|
394
|
+
);
|
|
370
395
|
bedrockContent.push({
|
|
371
396
|
document: {
|
|
372
397
|
format: getBedrockDocumentFormat(part.mediaType),
|
|
373
|
-
name: generateDocumentName(),
|
|
374
|
-
source: { bytes: convertToBase64(part.data) }
|
|
398
|
+
name: (_a = part.filename) != null ? _a : generateDocumentName(),
|
|
399
|
+
source: { bytes: convertToBase64(part.data) },
|
|
400
|
+
...enableCitations && {
|
|
401
|
+
citations: { enabled: true }
|
|
402
|
+
}
|
|
375
403
|
}
|
|
376
404
|
});
|
|
377
405
|
}
|
|
@@ -414,6 +442,11 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
414
442
|
case "error-text":
|
|
415
443
|
toolResultContent = [{ text: output.value }];
|
|
416
444
|
break;
|
|
445
|
+
case "execution-denied":
|
|
446
|
+
toolResultContent = [
|
|
447
|
+
{ text: (_b = output.reason) != null ? _b : "Tool execution denied." }
|
|
448
|
+
];
|
|
449
|
+
break;
|
|
417
450
|
case "json":
|
|
418
451
|
case "error-json":
|
|
419
452
|
default:
|
|
@@ -1294,7 +1327,7 @@ import {
|
|
|
1294
1327
|
} from "@ai-sdk/provider-utils";
|
|
1295
1328
|
|
|
1296
1329
|
// src/bedrock-embedding-options.ts
|
|
1297
|
-
import
|
|
1330
|
+
import * as z4 from "zod/v4";
|
|
1298
1331
|
var bedrockEmbeddingProviderOptions = z4.object({
|
|
1299
1332
|
/**
|
|
1300
1333
|
The number of dimensions the resulting output embeddings should have (defaults to 1024).
|
|
@@ -1309,7 +1342,7 @@ var bedrockEmbeddingProviderOptions = z4.object({
|
|
|
1309
1342
|
});
|
|
1310
1343
|
|
|
1311
1344
|
// src/bedrock-embedding-model.ts
|
|
1312
|
-
import
|
|
1345
|
+
import * as z5 from "zod/v4";
|
|
1313
1346
|
var BedrockEmbeddingModel = class {
|
|
1314
1347
|
constructor(modelId, config) {
|
|
1315
1348
|
this.modelId = modelId;
|
|
@@ -1391,7 +1424,7 @@ var modelMaxImagesPerCall = {
|
|
|
1391
1424
|
};
|
|
1392
1425
|
|
|
1393
1426
|
// src/bedrock-image-model.ts
|
|
1394
|
-
import
|
|
1427
|
+
import * as z6 from "zod/v4";
|
|
1395
1428
|
var BedrockImageModel = class {
|
|
1396
1429
|
constructor(modelId, config) {
|
|
1397
1430
|
this.modelId = modelId;
|