@langchain/anthropic 0.2.5 → 0.2.7

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.
@@ -99,7 +99,6 @@ function _makeMessageChunkFromAnthropicEvent(data, fields) {
99
99
  total_tokens: usage.input_tokens + usage.output_tokens,
100
100
  };
101
101
  }
102
- console.log("data.message", data.message);
103
102
  return {
104
103
  chunk: new messages_1.AIMessageChunk({
105
104
  content: fields.coerceContentToString ? "" : [],
@@ -407,9 +406,15 @@ function extractToolCallChunk(chunk) {
407
406
  return newToolCallChunk;
408
407
  }
409
408
  function extractToken(chunk) {
410
- return typeof chunk.content === "string" && chunk.content !== ""
411
- ? chunk.content
412
- : undefined;
409
+ if (typeof chunk.content === "string") {
410
+ return chunk.content;
411
+ }
412
+ else if (Array.isArray(chunk.content) && "input" in chunk.content[0]) {
413
+ return typeof chunk.content[0].input === "string"
414
+ ? chunk.content[0].input
415
+ : JSON.stringify(chunk.content[0].input);
416
+ }
417
+ return undefined;
413
418
  }
414
419
  function extractToolUseContent(chunk, concatenatedChunks) {
415
420
  let newConcatenatedChunks = concatenatedChunks;
@@ -96,7 +96,6 @@ function _makeMessageChunkFromAnthropicEvent(data, fields) {
96
96
  total_tokens: usage.input_tokens + usage.output_tokens,
97
97
  };
98
98
  }
99
- console.log("data.message", data.message);
100
99
  return {
101
100
  chunk: new AIMessageChunk({
102
101
  content: fields.coerceContentToString ? "" : [],
@@ -403,9 +402,15 @@ function extractToolCallChunk(chunk) {
403
402
  return newToolCallChunk;
404
403
  }
405
404
  function extractToken(chunk) {
406
- return typeof chunk.content === "string" && chunk.content !== ""
407
- ? chunk.content
408
- : undefined;
405
+ if (typeof chunk.content === "string") {
406
+ return chunk.content;
407
+ }
408
+ else if (Array.isArray(chunk.content) && "input" in chunk.content[0]) {
409
+ return typeof chunk.content[0].input === "string"
410
+ ? chunk.content[0].input
411
+ : JSON.stringify(chunk.content[0].input);
412
+ }
413
+ return undefined;
409
414
  }
410
415
  function extractToolUseContent(chunk, concatenatedChunks) {
411
416
  let newConcatenatedChunks = concatenatedChunks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {