@ai-sdk/amazon-bedrock 3.0.128 → 3.0.129

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.0.129
4
+
5
+ ### Patch Changes
6
+
7
+ - 1a80de8: fix(amazon-bedrock): return text from non-streaming citation responses
8
+
3
9
  ## 3.0.128
4
10
 
5
11
  ### Patch Changes
@@ -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 ? "3.0.128" : "0.0.0-test";
38
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "3.0.128" : "0.0.0-test";
27
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
28
28
 
29
29
  // src/bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.128" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
34
34
 
35
35
  // src/bedrock-provider.ts
36
36
  var import_internal3 = require("@ai-sdk/anthropic/internal");
@@ -1083,7 +1083,7 @@ var BedrockChatLanguageModel = class {
1083
1083
  return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
1084
1084
  }
1085
1085
  async doGenerate(options) {
1086
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1086
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1087
1087
  const {
1088
1088
  command: args,
1089
1089
  warnings,
@@ -1112,6 +1112,12 @@ var BedrockChatLanguageModel = class {
1112
1112
  for (const part of response.output.message.content) {
1113
1113
  if (part.text) {
1114
1114
  content.push({ type: "text", text: part.text });
1115
+ } else if (part.text == null && part.citationsContent) {
1116
+ for (const generatedContent of (_a = part.citationsContent.content) != null ? _a : []) {
1117
+ if (generatedContent.text != null) {
1118
+ content.push({ type: "text", text: generatedContent.text });
1119
+ }
1120
+ }
1115
1121
  }
1116
1122
  if (part.reasoningContent) {
1117
1123
  if ("reasoningText" in part.reasoningContent) {
@@ -1133,7 +1139,7 @@ var BedrockChatLanguageModel = class {
1133
1139
  text: "",
1134
1140
  providerMetadata: {
1135
1141
  bedrock: {
1136
- redactedData: (_a = part.reasoningContent.redactedReasoning.data) != null ? _a : ""
1142
+ redactedData: (_b = part.reasoningContent.redactedReasoning.data) != null ? _b : ""
1137
1143
  }
1138
1144
  }
1139
1145
  });
@@ -1160,18 +1166,18 @@ var BedrockChatLanguageModel = class {
1160
1166
  } else {
1161
1167
  content.push({
1162
1168
  type: "tool-call",
1163
- toolCallId: (_c = (_b = part.toolUse) == null ? void 0 : _b.toolUseId) != null ? _c : this.config.generateId(),
1164
- toolName: (_e = (_d = part.toolUse) == null ? void 0 : _d.name) != null ? _e : `tool-${this.config.generateId()}`,
1165
- input: JSON.stringify((_g = (_f = part.toolUse) == null ? void 0 : _f.input) != null ? _g : {})
1169
+ toolCallId: (_d = (_c = part.toolUse) == null ? void 0 : _c.toolUseId) != null ? _d : this.config.generateId(),
1170
+ toolName: (_f = (_e = part.toolUse) == null ? void 0 : _e.name) != null ? _f : `tool-${this.config.generateId()}`,
1171
+ input: JSON.stringify((_h = (_g = part.toolUse) == null ? void 0 : _g.input) != null ? _h : {})
1166
1172
  });
1167
1173
  }
1168
1174
  }
1169
1175
  }
1170
- const stopSequence = (_j = (_i = (_h = response.additionalModelResponseFields) == null ? void 0 : _h.delta) == null ? void 0 : _i.stop_sequence) != null ? _j : null;
1176
+ const stopSequence = (_k = (_j = (_i = response.additionalModelResponseFields) == null ? void 0 : _i.delta) == null ? void 0 : _j.stop_sequence) != null ? _k : null;
1171
1177
  const providerMetadata = response.trace || response.usage || isJsonResponseFromTool || stopSequence ? {
1172
1178
  bedrock: {
1173
1179
  ...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
1174
- ...((_k = response.usage) == null ? void 0 : _k.cacheWriteInputTokens) != null && {
1180
+ ...((_l = response.usage) == null ? void 0 : _l.cacheWriteInputTokens) != null && {
1175
1181
  usage: {
1176
1182
  cacheWriteInputTokens: response.usage.cacheWriteInputTokens
1177
1183
  }
@@ -1187,10 +1193,10 @@ var BedrockChatLanguageModel = class {
1187
1193
  isJsonResponseFromTool
1188
1194
  ),
1189
1195
  usage: {
1190
- inputTokens: (_l = response.usage) == null ? void 0 : _l.inputTokens,
1191
- outputTokens: (_m = response.usage) == null ? void 0 : _m.outputTokens,
1192
- totalTokens: ((_n = response.usage) == null ? void 0 : _n.inputTokens) + ((_o = response.usage) == null ? void 0 : _o.outputTokens),
1193
- cachedInputTokens: (_q = (_p = response.usage) == null ? void 0 : _p.cacheReadInputTokens) != null ? _q : void 0
1196
+ inputTokens: (_m = response.usage) == null ? void 0 : _m.inputTokens,
1197
+ outputTokens: (_n = response.usage) == null ? void 0 : _n.outputTokens,
1198
+ totalTokens: ((_o = response.usage) == null ? void 0 : _o.inputTokens) + ((_p = response.usage) == null ? void 0 : _p.outputTokens),
1199
+ cachedInputTokens: (_r = (_q = response.usage) == null ? void 0 : _q.cacheReadInputTokens) != null ? _r : void 0
1194
1200
  },
1195
1201
  response: {
1196
1202
  // TODO add id, timestamp, etc
@@ -1542,6 +1548,13 @@ var BedrockToolUseSchema = import_v44.z.object({
1542
1548
  name: import_v44.z.string(),
1543
1549
  input: import_v44.z.unknown()
1544
1550
  });
1551
+ var BedrockCitationsContentSchema = import_v44.z.object({
1552
+ content: import_v44.z.array(
1553
+ import_v44.z.object({
1554
+ text: import_v44.z.string().nullish()
1555
+ })
1556
+ ).nullish()
1557
+ });
1545
1558
  var BedrockReasoningTextSchema = import_v44.z.object({
1546
1559
  signature: import_v44.z.string().nullish(),
1547
1560
  text: import_v44.z.string()
@@ -1558,6 +1571,7 @@ var BedrockResponseSchema = import_v44.z.object({
1558
1571
  content: import_v44.z.array(
1559
1572
  import_v44.z.object({
1560
1573
  text: import_v44.z.string().nullish(),
1574
+ citationsContent: BedrockCitationsContentSchema.nullish(),
1561
1575
  toolUse: BedrockToolUseSchema.nullish(),
1562
1576
  reasoningContent: import_v44.z.union([
1563
1577
  import_v44.z.object({