@ai-sdk/amazon-bedrock 4.0.0-beta.101 → 4.0.0-beta.102
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/index.js +165 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.102
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9ab6ebe: feat(provider/amazon-bedrock): expose stop_sequence in provider metadata
|
|
8
|
+
|
|
9
|
+
The Bedrock provider now exposes the specific stop sequence that triggered generation to halt via `providerMetadata.bedrock.stopSequence`. This is implemented by:
|
|
10
|
+
|
|
11
|
+
- Requesting `/stop_sequence` via `additionalModelResponseFieldPaths` in the API call
|
|
12
|
+
- Parsing the value from `additionalModelResponseFields.stop_sequence` in both generate and stream responses
|
|
13
|
+
- Exposing it as `stopSequence` in the provider metadata (returns `null` when no stop sequence was matched)
|
|
14
|
+
|
|
15
|
+
- 9ab6ebe: Add stop sequence support for amazon bedrock provider
|
|
16
|
+
|
|
3
17
|
## 4.0.0-beta.101
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -919,6 +919,7 @@ var BedrockChatLanguageModel = class {
|
|
|
919
919
|
system,
|
|
920
920
|
messages,
|
|
921
921
|
additionalModelRequestFields: bedrockOptions.additionalModelRequestFields,
|
|
922
|
+
additionalModelResponseFieldPaths: ["/stop_sequence"],
|
|
922
923
|
...Object.keys(inferenceConfig).length > 0 && {
|
|
923
924
|
inferenceConfig
|
|
924
925
|
},
|
|
@@ -936,7 +937,7 @@ var BedrockChatLanguageModel = class {
|
|
|
936
937
|
return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
|
|
937
938
|
}
|
|
938
939
|
async doGenerate(options) {
|
|
939
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
940
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
940
941
|
const {
|
|
941
942
|
command: args,
|
|
942
943
|
warnings,
|
|
@@ -1010,15 +1011,17 @@ var BedrockChatLanguageModel = class {
|
|
|
1010
1011
|
}
|
|
1011
1012
|
}
|
|
1012
1013
|
}
|
|
1013
|
-
const
|
|
1014
|
+
const stopSequence = (_i = (_h = response.additionalModelResponseFields) == null ? void 0 : _h.stop_sequence) != null ? _i : null;
|
|
1015
|
+
const providerMetadata = response.trace || response.usage || isJsonResponseFromTool || stopSequence ? {
|
|
1014
1016
|
bedrock: {
|
|
1015
1017
|
...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
|
|
1016
|
-
...((
|
|
1018
|
+
...((_j = response.usage) == null ? void 0 : _j.cacheWriteInputTokens) != null && {
|
|
1017
1019
|
usage: {
|
|
1018
1020
|
cacheWriteInputTokens: response.usage.cacheWriteInputTokens
|
|
1019
1021
|
}
|
|
1020
1022
|
},
|
|
1021
|
-
...isJsonResponseFromTool && { isJsonResponseFromTool: true }
|
|
1023
|
+
...isJsonResponseFromTool && { isJsonResponseFromTool: true },
|
|
1024
|
+
stopSequence
|
|
1022
1025
|
}
|
|
1023
1026
|
} : void 0;
|
|
1024
1027
|
return {
|
|
@@ -1059,6 +1062,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1059
1062
|
let usage = void 0;
|
|
1060
1063
|
let providerMetadata = void 0;
|
|
1061
1064
|
let isJsonResponseFromTool = false;
|
|
1065
|
+
let stopSequence = null;
|
|
1062
1066
|
const contentBlocks = {};
|
|
1063
1067
|
return {
|
|
1064
1068
|
stream: response.pipeThrough(
|
|
@@ -1067,7 +1071,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1067
1071
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1068
1072
|
},
|
|
1069
1073
|
transform(chunk, controller) {
|
|
1070
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1074
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1071
1075
|
function enqueueError(bedrockError) {
|
|
1072
1076
|
finishReason = "error";
|
|
1073
1077
|
controller.enqueue({ type: "error", error: bedrockError });
|
|
@@ -1101,12 +1105,13 @@ var BedrockChatLanguageModel = class {
|
|
|
1101
1105
|
value.messageStop.stopReason,
|
|
1102
1106
|
isJsonResponseFromTool
|
|
1103
1107
|
);
|
|
1108
|
+
stopSequence = (_b = (_a = value.messageStop.additionalModelResponseFields) == null ? void 0 : _a.stop_sequence) != null ? _b : null;
|
|
1104
1109
|
}
|
|
1105
1110
|
if (value.metadata) {
|
|
1106
1111
|
if (value.metadata.usage) {
|
|
1107
1112
|
usage = value.metadata.usage;
|
|
1108
1113
|
}
|
|
1109
|
-
const cacheUsage = ((
|
|
1114
|
+
const cacheUsage = ((_c = value.metadata.usage) == null ? void 0 : _c.cacheWriteInputTokens) != null ? {
|
|
1110
1115
|
usage: {
|
|
1111
1116
|
cacheWriteInputTokens: value.metadata.usage.cacheWriteInputTokens
|
|
1112
1117
|
}
|
|
@@ -1123,7 +1128,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1123
1128
|
};
|
|
1124
1129
|
}
|
|
1125
1130
|
}
|
|
1126
|
-
if (((
|
|
1131
|
+
if (((_d = value.contentBlockStart) == null ? void 0 : _d.contentBlockIndex) != null && !((_f = (_e = value.contentBlockStart) == null ? void 0 : _e.start) == null ? void 0 : _f.toolUse)) {
|
|
1127
1132
|
const blockIndex = value.contentBlockStart.contentBlockIndex;
|
|
1128
1133
|
contentBlocks[blockIndex] = { type: "text" };
|
|
1129
1134
|
controller.enqueue({
|
|
@@ -1131,7 +1136,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1131
1136
|
id: String(blockIndex)
|
|
1132
1137
|
});
|
|
1133
1138
|
}
|
|
1134
|
-
if (((
|
|
1139
|
+
if (((_g = value.contentBlockDelta) == null ? void 0 : _g.delta) && "text" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.text) {
|
|
1135
1140
|
const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
|
|
1136
1141
|
if (contentBlocks[blockIndex] == null) {
|
|
1137
1142
|
contentBlocks[blockIndex] = { type: "text" };
|
|
@@ -1146,7 +1151,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1146
1151
|
delta: value.contentBlockDelta.delta.text
|
|
1147
1152
|
});
|
|
1148
1153
|
}
|
|
1149
|
-
if (((
|
|
1154
|
+
if (((_h = value.contentBlockStop) == null ? void 0 : _h.contentBlockIndex) != null) {
|
|
1150
1155
|
const blockIndex = value.contentBlockStop.contentBlockIndex;
|
|
1151
1156
|
const contentBlock = contentBlocks[blockIndex];
|
|
1152
1157
|
if (contentBlock != null) {
|
|
@@ -1192,7 +1197,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1192
1197
|
delete contentBlocks[blockIndex];
|
|
1193
1198
|
}
|
|
1194
1199
|
}
|
|
1195
|
-
if (((
|
|
1200
|
+
if (((_i = value.contentBlockDelta) == null ? void 0 : _i.delta) && "reasoningContent" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.reasoningContent) {
|
|
1196
1201
|
const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
|
|
1197
1202
|
const reasoningContent = value.contentBlockDelta.delta.reasoningContent;
|
|
1198
1203
|
if ("text" in reasoningContent && reasoningContent.text) {
|
|
@@ -1233,7 +1238,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1233
1238
|
}
|
|
1234
1239
|
}
|
|
1235
1240
|
const contentBlockStart = value.contentBlockStart;
|
|
1236
|
-
if (((
|
|
1241
|
+
if (((_j = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _j.toolUse) != null) {
|
|
1237
1242
|
const toolUse = contentBlockStart.start.toolUse;
|
|
1238
1243
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
1239
1244
|
const isJsonResponseTool = usesJsonResponseTool && toolUse.name === "json";
|
|
@@ -1257,7 +1262,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1257
1262
|
const blockIndex = contentBlockDelta.contentBlockIndex;
|
|
1258
1263
|
const contentBlock = contentBlocks[blockIndex];
|
|
1259
1264
|
if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
|
|
1260
|
-
const delta = (
|
|
1265
|
+
const delta = (_k = contentBlockDelta.delta.toolUse.input) != null ? _k : "";
|
|
1261
1266
|
if (!contentBlock.isJsonResponseTool) {
|
|
1262
1267
|
controller.enqueue({
|
|
1263
1268
|
type: "tool-input-delta",
|
|
@@ -1270,16 +1275,22 @@ var BedrockChatLanguageModel = class {
|
|
|
1270
1275
|
}
|
|
1271
1276
|
},
|
|
1272
1277
|
flush(controller) {
|
|
1273
|
-
if (isJsonResponseFromTool) {
|
|
1278
|
+
if (isJsonResponseFromTool || stopSequence != null) {
|
|
1274
1279
|
if (providerMetadata) {
|
|
1275
1280
|
providerMetadata.bedrock = {
|
|
1276
1281
|
...providerMetadata.bedrock,
|
|
1277
|
-
isJsonResponseFromTool
|
|
1282
|
+
...isJsonResponseFromTool && {
|
|
1283
|
+
isJsonResponseFromTool: true
|
|
1284
|
+
},
|
|
1285
|
+
stopSequence
|
|
1278
1286
|
};
|
|
1279
1287
|
} else {
|
|
1280
1288
|
providerMetadata = {
|
|
1281
1289
|
bedrock: {
|
|
1282
|
-
isJsonResponseFromTool
|
|
1290
|
+
...isJsonResponseFromTool && {
|
|
1291
|
+
isJsonResponseFromTool: true
|
|
1292
|
+
},
|
|
1293
|
+
stopSequence
|
|
1283
1294
|
}
|
|
1284
1295
|
};
|
|
1285
1296
|
}
|
|
@@ -1306,6 +1317,9 @@ var BedrockStopReasonSchema = import_v43.z.union([
|
|
|
1306
1317
|
import_v43.z.enum(BEDROCK_STOP_REASONS),
|
|
1307
1318
|
import_v43.z.string()
|
|
1308
1319
|
]);
|
|
1320
|
+
var BedrockAdditionalModelResponseFieldsSchema = import_v43.z.object({
|
|
1321
|
+
stop_sequence: import_v43.z.string().optional()
|
|
1322
|
+
}).catchall(import_v43.z.unknown());
|
|
1309
1323
|
var BedrockToolUseSchema = import_v43.z.object({
|
|
1310
1324
|
toolUseId: import_v43.z.string(),
|
|
1311
1325
|
name: import_v43.z.string(),
|
|
@@ -1342,6 +1356,7 @@ var BedrockResponseSchema = import_v43.z.object({
|
|
|
1342
1356
|
})
|
|
1343
1357
|
}),
|
|
1344
1358
|
stopReason: BedrockStopReasonSchema,
|
|
1359
|
+
additionalModelResponseFields: BedrockAdditionalModelResponseFieldsSchema.nullish(),
|
|
1345
1360
|
trace: import_v43.z.unknown().nullish(),
|
|
1346
1361
|
usage: import_v43.z.object({
|
|
1347
1362
|
inputTokens: import_v43.z.number(),
|
|
@@ -1381,7 +1396,7 @@ var BedrockStreamSchema = import_v43.z.object({
|
|
|
1381
1396
|
}).nullish(),
|
|
1382
1397
|
internalServerException: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish(),
|
|
1383
1398
|
messageStop: import_v43.z.object({
|
|
1384
|
-
additionalModelResponseFields:
|
|
1399
|
+
additionalModelResponseFields: BedrockAdditionalModelResponseFieldsSchema.nullish(),
|
|
1385
1400
|
stopReason: BedrockStopReasonSchema
|
|
1386
1401
|
}).nullish(),
|
|
1387
1402
|
metadata: import_v43.z.object({
|
|
@@ -1523,31 +1538,110 @@ var BedrockImageModel = class {
|
|
|
1523
1538
|
seed,
|
|
1524
1539
|
providerOptions,
|
|
1525
1540
|
headers,
|
|
1526
|
-
abortSignal
|
|
1541
|
+
abortSignal,
|
|
1542
|
+
files,
|
|
1543
|
+
mask
|
|
1527
1544
|
}) {
|
|
1528
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1545
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1529
1546
|
const warnings = [];
|
|
1530
1547
|
const [width, height] = size ? size.split("x").map(Number) : [];
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
style: providerOptions.bedrock.style
|
|
1540
|
-
} : {}
|
|
1541
|
-
},
|
|
1542
|
-
imageGenerationConfig: {
|
|
1543
|
-
...width ? { width } : {},
|
|
1544
|
-
...height ? { height } : {},
|
|
1545
|
-
...seed ? { seed } : {},
|
|
1546
|
-
...n ? { numberOfImages: n } : {},
|
|
1547
|
-
...((_c = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _c.quality) ? { quality: providerOptions.bedrock.quality } : {},
|
|
1548
|
-
...((_d = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _d.cfgScale) ? { cfgScale: providerOptions.bedrock.cfgScale } : {}
|
|
1549
|
-
}
|
|
1548
|
+
const hasFiles = files != null && files.length > 0;
|
|
1549
|
+
const imageGenerationConfig = {
|
|
1550
|
+
...width ? { width } : {},
|
|
1551
|
+
...height ? { height } : {},
|
|
1552
|
+
...seed ? { seed } : {},
|
|
1553
|
+
...n ? { numberOfImages: n } : {},
|
|
1554
|
+
...((_a = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _a.quality) ? { quality: providerOptions.bedrock.quality } : {},
|
|
1555
|
+
...((_b = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _b.cfgScale) ? { cfgScale: providerOptions.bedrock.cfgScale } : {}
|
|
1550
1556
|
};
|
|
1557
|
+
let args;
|
|
1558
|
+
if (hasFiles) {
|
|
1559
|
+
const hasMask = (mask == null ? void 0 : mask.type) != null;
|
|
1560
|
+
const hasMaskPrompt = ((_c = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _c.maskPrompt) != null;
|
|
1561
|
+
const taskType = (_e = (_d = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _d.taskType) != null ? _e : hasMask || hasMaskPrompt ? "INPAINTING" : "IMAGE_VARIATION";
|
|
1562
|
+
const sourceImageBase64 = getBase64Data(files[0]);
|
|
1563
|
+
switch (taskType) {
|
|
1564
|
+
case "INPAINTING": {
|
|
1565
|
+
const inPaintingParams = {
|
|
1566
|
+
image: sourceImageBase64,
|
|
1567
|
+
...prompt ? { text: prompt } : {},
|
|
1568
|
+
...((_f = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _f.negativeText) ? { negativeText: providerOptions.bedrock.negativeText } : {}
|
|
1569
|
+
};
|
|
1570
|
+
if (hasMask) {
|
|
1571
|
+
inPaintingParams.maskImage = getBase64Data(mask);
|
|
1572
|
+
} else if (hasMaskPrompt) {
|
|
1573
|
+
inPaintingParams.maskPrompt = providerOptions.bedrock.maskPrompt;
|
|
1574
|
+
}
|
|
1575
|
+
args = {
|
|
1576
|
+
taskType: "INPAINTING",
|
|
1577
|
+
inPaintingParams,
|
|
1578
|
+
imageGenerationConfig
|
|
1579
|
+
};
|
|
1580
|
+
break;
|
|
1581
|
+
}
|
|
1582
|
+
case "OUTPAINTING": {
|
|
1583
|
+
const outPaintingParams = {
|
|
1584
|
+
image: sourceImageBase64,
|
|
1585
|
+
...prompt ? { text: prompt } : {},
|
|
1586
|
+
...((_g = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _g.negativeText) ? { negativeText: providerOptions.bedrock.negativeText } : {},
|
|
1587
|
+
...((_h = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _h.outPaintingMode) ? { outPaintingMode: providerOptions.bedrock.outPaintingMode } : {}
|
|
1588
|
+
};
|
|
1589
|
+
if (hasMask) {
|
|
1590
|
+
outPaintingParams.maskImage = getBase64Data(mask);
|
|
1591
|
+
} else if (hasMaskPrompt) {
|
|
1592
|
+
outPaintingParams.maskPrompt = providerOptions.bedrock.maskPrompt;
|
|
1593
|
+
}
|
|
1594
|
+
args = {
|
|
1595
|
+
taskType: "OUTPAINTING",
|
|
1596
|
+
outPaintingParams,
|
|
1597
|
+
imageGenerationConfig
|
|
1598
|
+
};
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
case "BACKGROUND_REMOVAL": {
|
|
1602
|
+
args = {
|
|
1603
|
+
taskType: "BACKGROUND_REMOVAL",
|
|
1604
|
+
backgroundRemovalParams: {
|
|
1605
|
+
image: sourceImageBase64
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
case "IMAGE_VARIATION": {
|
|
1611
|
+
const images = files.map((file) => getBase64Data(file));
|
|
1612
|
+
const imageVariationParams = {
|
|
1613
|
+
images,
|
|
1614
|
+
...prompt ? { text: prompt } : {},
|
|
1615
|
+
...((_i = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _i.negativeText) ? { negativeText: providerOptions.bedrock.negativeText } : {},
|
|
1616
|
+
...((_j = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _j.similarityStrength) != null ? {
|
|
1617
|
+
similarityStrength: providerOptions.bedrock.similarityStrength
|
|
1618
|
+
} : {}
|
|
1619
|
+
};
|
|
1620
|
+
args = {
|
|
1621
|
+
taskType: "IMAGE_VARIATION",
|
|
1622
|
+
imageVariationParams,
|
|
1623
|
+
imageGenerationConfig
|
|
1624
|
+
};
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
default:
|
|
1628
|
+
throw new Error(`Unsupported task type: ${taskType}`);
|
|
1629
|
+
}
|
|
1630
|
+
} else {
|
|
1631
|
+
args = {
|
|
1632
|
+
taskType: "TEXT_IMAGE",
|
|
1633
|
+
textToImageParams: {
|
|
1634
|
+
text: prompt,
|
|
1635
|
+
...((_k = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _k.negativeText) ? {
|
|
1636
|
+
negativeText: providerOptions.bedrock.negativeText
|
|
1637
|
+
} : {},
|
|
1638
|
+
...((_l = providerOptions == null ? void 0 : providerOptions.bedrock) == null ? void 0 : _l.style) ? {
|
|
1639
|
+
style: providerOptions.bedrock.style
|
|
1640
|
+
} : {}
|
|
1641
|
+
},
|
|
1642
|
+
imageGenerationConfig
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1551
1645
|
if (aspectRatio != void 0) {
|
|
1552
1646
|
warnings.push({
|
|
1553
1647
|
type: "unsupported",
|
|
@@ -1555,7 +1649,7 @@ var BedrockImageModel = class {
|
|
|
1555
1649
|
details: "This model does not support aspect ratio. Use `size` instead."
|
|
1556
1650
|
});
|
|
1557
1651
|
}
|
|
1558
|
-
const currentDate = (
|
|
1652
|
+
const currentDate = (_o = (_n = (_m = this.config._internal) == null ? void 0 : _m.currentDate) == null ? void 0 : _n.call(_m)) != null ? _o : /* @__PURE__ */ new Date();
|
|
1559
1653
|
const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
|
|
1560
1654
|
url: this.getUrl(this.modelId),
|
|
1561
1655
|
headers: await (0, import_provider_utils6.resolve)(
|
|
@@ -1572,6 +1666,18 @@ var BedrockImageModel = class {
|
|
|
1572
1666
|
abortSignal,
|
|
1573
1667
|
fetch: this.config.fetch
|
|
1574
1668
|
});
|
|
1669
|
+
if (response.status === "Request Moderated") {
|
|
1670
|
+
const moderationReasons = (_p = response.details) == null ? void 0 : _p["Moderation Reasons"];
|
|
1671
|
+
const reasons = Array.isArray(moderationReasons) ? moderationReasons : ["Unknown"];
|
|
1672
|
+
throw new Error(
|
|
1673
|
+
`Amazon Bedrock request was moderated: ${reasons.join(", ")}`
|
|
1674
|
+
);
|
|
1675
|
+
}
|
|
1676
|
+
if (!response.images || response.images.length === 0) {
|
|
1677
|
+
throw new Error(
|
|
1678
|
+
"Amazon Bedrock returned no images. " + (response.status ? `Status: ${response.status}` : "")
|
|
1679
|
+
);
|
|
1680
|
+
}
|
|
1575
1681
|
return {
|
|
1576
1682
|
images: response.images,
|
|
1577
1683
|
warnings,
|
|
@@ -1583,8 +1689,27 @@ var BedrockImageModel = class {
|
|
|
1583
1689
|
};
|
|
1584
1690
|
}
|
|
1585
1691
|
};
|
|
1692
|
+
function getBase64Data(file) {
|
|
1693
|
+
if (file.type === "url") {
|
|
1694
|
+
throw new Error(
|
|
1695
|
+
"URL-based images are not supported for Amazon Bedrock image editing. Please provide the image data directly."
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
if (file.data instanceof Uint8Array) {
|
|
1699
|
+
return (0, import_provider_utils6.convertUint8ArrayToBase64)(file.data);
|
|
1700
|
+
}
|
|
1701
|
+
return file.data;
|
|
1702
|
+
}
|
|
1586
1703
|
var bedrockImageResponseSchema = import_v46.z.object({
|
|
1587
|
-
|
|
1704
|
+
// Normal successful response
|
|
1705
|
+
images: import_v46.z.array(import_v46.z.string()).optional(),
|
|
1706
|
+
// Moderation response fields
|
|
1707
|
+
id: import_v46.z.string().optional(),
|
|
1708
|
+
status: import_v46.z.string().optional(),
|
|
1709
|
+
result: import_v46.z.unknown().optional(),
|
|
1710
|
+
progress: import_v46.z.unknown().optional(),
|
|
1711
|
+
details: import_v46.z.record(import_v46.z.string(), import_v46.z.unknown()).optional(),
|
|
1712
|
+
preview: import_v46.z.unknown().optional()
|
|
1588
1713
|
});
|
|
1589
1714
|
|
|
1590
1715
|
// src/bedrock-sigv4-fetch.ts
|
|
@@ -1592,7 +1717,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1592
1717
|
var import_aws4fetch = require("aws4fetch");
|
|
1593
1718
|
|
|
1594
1719
|
// src/version.ts
|
|
1595
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1720
|
+
var VERSION = true ? "4.0.0-beta.102" : "0.0.0-test";
|
|
1596
1721
|
|
|
1597
1722
|
// src/bedrock-sigv4-fetch.ts
|
|
1598
1723
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|