@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/dist/index.mjs CHANGED
@@ -1263,7 +1263,7 @@ var BedrockChatLanguageModel = class {
1263
1263
  return combineHeaders(await resolve(this.config.headers), headers);
1264
1264
  }
1265
1265
  async doGenerate(options) {
1266
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1266
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1267
1267
  const {
1268
1268
  command: args,
1269
1269
  warnings,
@@ -1292,10 +1292,12 @@ var BedrockChatLanguageModel = class {
1292
1292
  let isJsonResponseFromTool = false;
1293
1293
  const jsonObjectTextExtractor = usesJsonInstruction ? new JsonObjectTextExtractor() : void 0;
1294
1294
  for (const part of response.output.message.content) {
1295
- if (part.text != null) {
1295
+ const citationText = (_b = (_a = part.citationsContent) == null ? void 0 : _a.content) == null ? void 0 : _b.map((generatedContent) => generatedContent.text).filter((text2) => text2 != null).join("");
1296
+ const text = (_c = part.text) != null ? _c : citationText ? citationText : void 0;
1297
+ if (text != null) {
1296
1298
  content.push({
1297
1299
  type: "text",
1298
- text: (_a = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(part.text)) != null ? _a : part.text
1300
+ text: (_d = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(text)) != null ? _d : text
1299
1301
  });
1300
1302
  }
1301
1303
  if (part.reasoningContent) {
@@ -1318,7 +1320,7 @@ var BedrockChatLanguageModel = class {
1318
1320
  text: "",
1319
1321
  providerMetadata: {
1320
1322
  bedrock: {
1321
- redactedData: (_b = part.reasoningContent.redactedReasoning.data) != null ? _b : ""
1323
+ redactedData: (_e = part.reasoningContent.redactedReasoning.data) != null ? _e : ""
1322
1324
  }
1323
1325
  }
1324
1326
  });
@@ -1344,17 +1346,17 @@ var BedrockChatLanguageModel = class {
1344
1346
  });
1345
1347
  } else {
1346
1348
  const isMistral = isMistralModel(this.modelId);
1347
- const rawToolCallId = (_d = (_c = part.toolUse) == null ? void 0 : _c.toolUseId) != null ? _d : this.config.generateId();
1349
+ const rawToolCallId = (_g = (_f = part.toolUse) == null ? void 0 : _f.toolUseId) != null ? _g : this.config.generateId();
1348
1350
  content.push({
1349
1351
  type: "tool-call",
1350
1352
  toolCallId: normalizeToolCallId(rawToolCallId, isMistral),
1351
- toolName: (_f = (_e = part.toolUse) == null ? void 0 : _e.name) != null ? _f : `tool-${this.config.generateId()}`,
1352
- input: JSON.stringify((_h = (_g = part.toolUse) == null ? void 0 : _g.input) != null ? _h : {})
1353
+ toolName: (_i = (_h = part.toolUse) == null ? void 0 : _h.name) != null ? _i : `tool-${this.config.generateId()}`,
1354
+ input: JSON.stringify((_k = (_j = part.toolUse) == null ? void 0 : _j.input) != null ? _k : {})
1353
1355
  });
1354
1356
  }
1355
1357
  }
1356
1358
  }
1357
- const stopSequence = (_k = (_j = (_i = response.additionalModelResponseFields) == null ? void 0 : _i.delta) == null ? void 0 : _j.stop_sequence) != null ? _k : null;
1359
+ const stopSequence = (_n = (_m = (_l = response.additionalModelResponseFields) == null ? void 0 : _l.delta) == null ? void 0 : _m.stop_sequence) != null ? _n : null;
1358
1360
  const providerMetadata = response.trace || response.usage || response.performanceConfig || response.serviceTier || isJsonResponseFromTool || stopSequence ? {
1359
1361
  bedrock: {
1360
1362
  ...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
@@ -1364,7 +1366,7 @@ var BedrockChatLanguageModel = class {
1364
1366
  ...response.serviceTier && {
1365
1367
  serviceTier: response.serviceTier
1366
1368
  },
1367
- ...(((_l = response.usage) == null ? void 0 : _l.cacheWriteInputTokens) != null || ((_m = response.usage) == null ? void 0 : _m.cacheDetails) != null) && {
1369
+ ...(((_o = response.usage) == null ? void 0 : _o.cacheWriteInputTokens) != null || ((_p = response.usage) == null ? void 0 : _p.cacheDetails) != null) && {
1368
1370
  usage: {
1369
1371
  ...response.usage.cacheWriteInputTokens != null && {
1370
1372
  cacheWriteInputTokens: response.usage.cacheWriteInputTokens
@@ -1385,11 +1387,11 @@ var BedrockChatLanguageModel = class {
1385
1387
  response.stopReason,
1386
1388
  isJsonResponseFromTool
1387
1389
  ),
1388
- raw: (_n = response.stopReason) != null ? _n : void 0
1390
+ raw: (_q = response.stopReason) != null ? _q : void 0
1389
1391
  },
1390
1392
  usage: convertBedrockUsage(response.usage),
1391
1393
  response: {
1392
- id: (_o = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _o : void 0,
1394
+ id: (_r = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _r : void 0,
1393
1395
  timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
1394
1396
  modelId: this.modelId,
1395
1397
  headers: responseHeaders
@@ -1830,6 +1832,13 @@ var BedrockResponseSchema = z4.object({
1830
1832
  content: z4.array(
1831
1833
  z4.object({
1832
1834
  text: z4.string().nullish(),
1835
+ citationsContent: z4.object({
1836
+ content: z4.array(
1837
+ z4.object({
1838
+ text: z4.string().nullish()
1839
+ })
1840
+ ).nullish()
1841
+ }).nullish(),
1833
1842
  toolUse: BedrockToolUseSchema.nullish(),
1834
1843
  reasoningContent: z4.union([
1835
1844
  z4.object({
@@ -2357,7 +2366,7 @@ import {
2357
2366
  import { AwsV4Signer } from "aws4fetch";
2358
2367
 
2359
2368
  // src/version.ts
2360
- var VERSION = true ? "4.0.170" : "0.0.0-test";
2369
+ var VERSION = true ? "4.0.171" : "0.0.0-test";
2361
2370
 
2362
2371
  // src/bedrock-sigv4-fetch.ts
2363
2372
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {