@langchain/anthropic 0.2.6 → 0.2.8

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.
@@ -406,9 +406,17 @@ function extractToolCallChunk(chunk) {
406
406
  return newToolCallChunk;
407
407
  }
408
408
  function extractToken(chunk) {
409
- return typeof chunk.content === "string" && chunk.content !== ""
410
- ? chunk.content
411
- : undefined;
409
+ if (typeof chunk.content === "string") {
410
+ return chunk.content;
411
+ }
412
+ else if (Array.isArray(chunk.content) &&
413
+ chunk.content.length >= 1 &&
414
+ "input" in chunk.content[0]) {
415
+ return typeof chunk.content[0].input === "string"
416
+ ? chunk.content[0].input
417
+ : JSON.stringify(chunk.content[0].input);
418
+ }
419
+ return undefined;
412
420
  }
413
421
  function extractToolUseContent(chunk, concatenatedChunks) {
414
422
  let newConcatenatedChunks = concatenatedChunks;
@@ -402,9 +402,17 @@ function extractToolCallChunk(chunk) {
402
402
  return newToolCallChunk;
403
403
  }
404
404
  function extractToken(chunk) {
405
- return typeof chunk.content === "string" && chunk.content !== ""
406
- ? chunk.content
407
- : undefined;
405
+ if (typeof chunk.content === "string") {
406
+ return chunk.content;
407
+ }
408
+ else if (Array.isArray(chunk.content) &&
409
+ chunk.content.length >= 1 &&
410
+ "input" in chunk.content[0]) {
411
+ return typeof chunk.content[0].input === "string"
412
+ ? chunk.content[0].input
413
+ : JSON.stringify(chunk.content[0].input);
414
+ }
415
+ return undefined;
408
416
  }
409
417
  function extractToolUseContent(chunk, concatenatedChunks) {
410
418
  let newConcatenatedChunks = concatenatedChunks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {