@ai-sdk/langchain 2.0.318 → 2.0.320

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,22 @@
1
1
  # @ai-sdk/langchain
2
2
 
3
+ ## 2.0.320
4
+
5
+ ### Patch Changes
6
+
7
+ - 26f647b: fix(langchain): avoid `RangeError: Maximum call stack size exceeded` when converting large binary image and file parts
8
+ - Updated dependencies [1183cc4]
9
+ - Updated dependencies [d726591]
10
+ - @ai-sdk/provider-utils@4.0.62
11
+ - ai@6.0.312
12
+
13
+ ## 2.0.319
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [af9972b]
18
+ - ai@6.0.311
19
+
3
20
  ## 2.0.318
4
21
 
5
22
  ### Patch Changes
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ var import_ai = require("ai");
33
33
 
34
34
  // src/utils.ts
35
35
  var import_messages = require("@langchain/core/messages");
36
+ var import_provider_utils = require("@ai-sdk/provider-utils");
36
37
  function parseLangGraphEvent(event) {
37
38
  return event.length === 3 ? [event[0], event[1], event[2]] : [void 0, event[0], event[1]];
38
39
  }
@@ -182,7 +183,7 @@ function convertImageToContentBlock(data, mediaType = "image/png") {
182
183
  const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
183
184
  return {
184
185
  type: "image",
185
- data: btoa(String.fromCharCode(...bytes)),
186
+ data: (0, import_provider_utils.convertUint8ArrayToBase64)(bytes),
186
187
  mimeType: mediaType
187
188
  };
188
189
  }
@@ -253,7 +254,7 @@ function convertUserContent(content) {
253
254
  }
254
255
  } else if (filePart.data instanceof Uint8Array || filePart.data instanceof ArrayBuffer) {
255
256
  const bytes = filePart.data instanceof ArrayBuffer ? new Uint8Array(filePart.data) : filePart.data;
256
- const base64 = btoa(String.fromCharCode(...bytes));
257
+ const base64 = (0, import_provider_utils.convertUint8ArrayToBase64)(bytes);
257
258
  contentBlocks.push({
258
259
  type: "file",
259
260
  data: base64,