@langchain/anthropic 0.3.3 → 0.3.4

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.
@@ -690,7 +690,7 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
690
690
  const newToolCallChunk = (0, tools_js_1.extractToolCallChunk)(chunk);
691
691
  // Extract the text content token for text field and runManager.
692
692
  const token = extractToken(chunk);
693
- yield new outputs_1.ChatGenerationChunk({
693
+ const generationChunk = new outputs_1.ChatGenerationChunk({
694
694
  message: new messages_1.AIMessageChunk({
695
695
  // Just yield chunk as it is and tool_use will be concat by BaseChatModel._generateUncached().
696
696
  content: chunk.content,
@@ -702,9 +702,8 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
702
702
  }),
703
703
  text: token ?? "",
704
704
  });
705
- if (token) {
706
- await runManager?.handleLLMNewToken(token);
707
- }
705
+ yield generationChunk;
706
+ await runManager?.handleLLMNewToken(token ?? "", undefined, undefined, undefined, undefined, { chunk: generationChunk });
708
707
  }
709
708
  }
710
709
  /** @ignore */
@@ -687,7 +687,7 @@ export class ChatAnthropicMessages extends BaseChatModel {
687
687
  const newToolCallChunk = extractToolCallChunk(chunk);
688
688
  // Extract the text content token for text field and runManager.
689
689
  const token = extractToken(chunk);
690
- yield new ChatGenerationChunk({
690
+ const generationChunk = new ChatGenerationChunk({
691
691
  message: new AIMessageChunk({
692
692
  // Just yield chunk as it is and tool_use will be concat by BaseChatModel._generateUncached().
693
693
  content: chunk.content,
@@ -699,9 +699,8 @@ export class ChatAnthropicMessages extends BaseChatModel {
699
699
  }),
700
700
  text: token ?? "",
701
701
  });
702
- if (token) {
703
- await runManager?.handleLLMNewToken(token);
704
- }
702
+ yield generationChunk;
703
+ await runManager?.handleLLMNewToken(token ?? "", undefined, undefined, undefined, undefined, { chunk: generationChunk });
705
704
  }
706
705
  }
707
706
  /** @ignore */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {