@ai-sdk/amazon-bedrock 4.0.170 → 4.0.171
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 +8 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -12
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/package.json +2 -2
- package/src/bedrock-chat-language-model.ts +19 -2
package/CHANGELOG.md
CHANGED
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.171" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
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.171" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/index.js
CHANGED
|
@@ -1259,7 +1259,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1259
1259
|
return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
|
|
1260
1260
|
}
|
|
1261
1261
|
async doGenerate(options) {
|
|
1262
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1262
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1263
1263
|
const {
|
|
1264
1264
|
command: args,
|
|
1265
1265
|
warnings,
|
|
@@ -1288,10 +1288,12 @@ var BedrockChatLanguageModel = class {
|
|
|
1288
1288
|
let isJsonResponseFromTool = false;
|
|
1289
1289
|
const jsonObjectTextExtractor = usesJsonInstruction ? new JsonObjectTextExtractor() : void 0;
|
|
1290
1290
|
for (const part of response.output.message.content) {
|
|
1291
|
-
|
|
1291
|
+
const citationText = (_b = (_a = part.citationsContent) == null ? void 0 : _a.content) == null ? void 0 : _b.map((generatedContent) => generatedContent.text).filter((text2) => text2 != null).join("");
|
|
1292
|
+
const text = (_c = part.text) != null ? _c : citationText ? citationText : void 0;
|
|
1293
|
+
if (text != null) {
|
|
1292
1294
|
content.push({
|
|
1293
1295
|
type: "text",
|
|
1294
|
-
text: (
|
|
1296
|
+
text: (_d = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(text)) != null ? _d : text
|
|
1295
1297
|
});
|
|
1296
1298
|
}
|
|
1297
1299
|
if (part.reasoningContent) {
|
|
@@ -1314,7 +1316,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1314
1316
|
text: "",
|
|
1315
1317
|
providerMetadata: {
|
|
1316
1318
|
bedrock: {
|
|
1317
|
-
redactedData: (
|
|
1319
|
+
redactedData: (_e = part.reasoningContent.redactedReasoning.data) != null ? _e : ""
|
|
1318
1320
|
}
|
|
1319
1321
|
}
|
|
1320
1322
|
});
|
|
@@ -1340,17 +1342,17 @@ var BedrockChatLanguageModel = class {
|
|
|
1340
1342
|
});
|
|
1341
1343
|
} else {
|
|
1342
1344
|
const isMistral = isMistralModel(this.modelId);
|
|
1343
|
-
const rawToolCallId = (
|
|
1345
|
+
const rawToolCallId = (_g = (_f = part.toolUse) == null ? void 0 : _f.toolUseId) != null ? _g : this.config.generateId();
|
|
1344
1346
|
content.push({
|
|
1345
1347
|
type: "tool-call",
|
|
1346
1348
|
toolCallId: normalizeToolCallId(rawToolCallId, isMistral),
|
|
1347
|
-
toolName: (
|
|
1348
|
-
input: JSON.stringify((
|
|
1349
|
+
toolName: (_i = (_h = part.toolUse) == null ? void 0 : _h.name) != null ? _i : `tool-${this.config.generateId()}`,
|
|
1350
|
+
input: JSON.stringify((_k = (_j = part.toolUse) == null ? void 0 : _j.input) != null ? _k : {})
|
|
1349
1351
|
});
|
|
1350
1352
|
}
|
|
1351
1353
|
}
|
|
1352
1354
|
}
|
|
1353
|
-
const stopSequence = (
|
|
1355
|
+
const stopSequence = (_n = (_m = (_l = response.additionalModelResponseFields) == null ? void 0 : _l.delta) == null ? void 0 : _m.stop_sequence) != null ? _n : null;
|
|
1354
1356
|
const providerMetadata = response.trace || response.usage || response.performanceConfig || response.serviceTier || isJsonResponseFromTool || stopSequence ? {
|
|
1355
1357
|
bedrock: {
|
|
1356
1358
|
...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
|
|
@@ -1360,7 +1362,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1360
1362
|
...response.serviceTier && {
|
|
1361
1363
|
serviceTier: response.serviceTier
|
|
1362
1364
|
},
|
|
1363
|
-
...(((
|
|
1365
|
+
...(((_o = response.usage) == null ? void 0 : _o.cacheWriteInputTokens) != null || ((_p = response.usage) == null ? void 0 : _p.cacheDetails) != null) && {
|
|
1364
1366
|
usage: {
|
|
1365
1367
|
...response.usage.cacheWriteInputTokens != null && {
|
|
1366
1368
|
cacheWriteInputTokens: response.usage.cacheWriteInputTokens
|
|
@@ -1381,11 +1383,11 @@ var BedrockChatLanguageModel = class {
|
|
|
1381
1383
|
response.stopReason,
|
|
1382
1384
|
isJsonResponseFromTool
|
|
1383
1385
|
),
|
|
1384
|
-
raw: (
|
|
1386
|
+
raw: (_q = response.stopReason) != null ? _q : void 0
|
|
1385
1387
|
},
|
|
1386
1388
|
usage: convertBedrockUsage(response.usage),
|
|
1387
1389
|
response: {
|
|
1388
|
-
id: (
|
|
1390
|
+
id: (_r = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _r : void 0,
|
|
1389
1391
|
timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
|
|
1390
1392
|
modelId: this.modelId,
|
|
1391
1393
|
headers: responseHeaders
|
|
@@ -1826,6 +1828,13 @@ var BedrockResponseSchema = import_v44.z.object({
|
|
|
1826
1828
|
content: import_v44.z.array(
|
|
1827
1829
|
import_v44.z.object({
|
|
1828
1830
|
text: import_v44.z.string().nullish(),
|
|
1831
|
+
citationsContent: import_v44.z.object({
|
|
1832
|
+
content: import_v44.z.array(
|
|
1833
|
+
import_v44.z.object({
|
|
1834
|
+
text: import_v44.z.string().nullish()
|
|
1835
|
+
})
|
|
1836
|
+
).nullish()
|
|
1837
|
+
}).nullish(),
|
|
1829
1838
|
toolUse: BedrockToolUseSchema.nullish(),
|
|
1830
1839
|
reasoningContent: import_v44.z.union([
|
|
1831
1840
|
import_v44.z.object({
|
|
@@ -2332,7 +2341,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
2332
2341
|
var import_aws4fetch = require("aws4fetch");
|
|
2333
2342
|
|
|
2334
2343
|
// src/version.ts
|
|
2335
|
-
var VERSION = true ? "4.0.
|
|
2344
|
+
var VERSION = true ? "4.0.171" : "0.0.0-test";
|
|
2336
2345
|
|
|
2337
2346
|
// src/bedrock-sigv4-fetch.ts
|
|
2338
2347
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|