@langchain/anthropic 0.3.20 → 0.3.21

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.
@@ -81,9 +81,8 @@ function extractToken(chunk) {
81
81
  *
82
82
  * ```typescript
83
83
  * // When calling `.bind`, call options should be passed via the first argument
84
- * const llmWithArgsBound = llm.bind({
84
+ * const llmWithArgsBound = llm.bindTools([...]).withConfig({
85
85
  * stop: ["\n"],
86
- * tools: [...],
87
86
  * });
88
87
  *
89
88
  * // When calling `.bindTools`, call options should be passed via the second argument
@@ -651,7 +650,7 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
651
650
  });
652
651
  }
653
652
  bindTools(tools, kwargs) {
654
- return this.bind({
653
+ return this.withConfig({
655
654
  tools: this.formatStructuredToolToAnthropic(tools),
656
655
  ...kwargs,
657
656
  });
@@ -925,7 +924,7 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
925
924
  "generated. Consider disabling `thinking` or adjust your prompt to ensure " +
926
925
  "the tool is called.";
927
926
  console.warn(thinkingAdmonition);
928
- llm = this.bind({
927
+ llm = this.withConfig({
929
928
  tools,
930
929
  });
931
930
  const raiseIfNoToolCalls = (message) => {
@@ -937,7 +936,7 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
937
936
  llm = llm.pipe(raiseIfNoToolCalls);
938
937
  }
939
938
  else {
940
- llm = this.bind({
939
+ llm = this.withConfig({
941
940
  tools,
942
941
  tool_choice: {
943
942
  type: "tool",
@@ -117,9 +117,8 @@ type Kwargs = Record<string, any>;
117
117
  *
118
118
  * ```typescript
119
119
  * // When calling `.bind`, call options should be passed via the first argument
120
- * const llmWithArgsBound = llm.bind({
120
+ * const llmWithArgsBound = llm.bindTools([...]).withConfig({
121
121
  * stop: ["\n"],
122
- * tools: [...],
123
122
  * });
124
123
  *
125
124
  * // When calling `.bindTools`, call options should be passed via the second argument
@@ -78,9 +78,8 @@ function extractToken(chunk) {
78
78
  *
79
79
  * ```typescript
80
80
  * // When calling `.bind`, call options should be passed via the first argument
81
- * const llmWithArgsBound = llm.bind({
81
+ * const llmWithArgsBound = llm.bindTools([...]).withConfig({
82
82
  * stop: ["\n"],
83
- * tools: [...],
84
83
  * });
85
84
  *
86
85
  * // When calling `.bindTools`, call options should be passed via the second argument
@@ -648,7 +647,7 @@ export class ChatAnthropicMessages extends BaseChatModel {
648
647
  });
649
648
  }
650
649
  bindTools(tools, kwargs) {
651
- return this.bind({
650
+ return this.withConfig({
652
651
  tools: this.formatStructuredToolToAnthropic(tools),
653
652
  ...kwargs,
654
653
  });
@@ -922,7 +921,7 @@ export class ChatAnthropicMessages extends BaseChatModel {
922
921
  "generated. Consider disabling `thinking` or adjust your prompt to ensure " +
923
922
  "the tool is called.";
924
923
  console.warn(thinkingAdmonition);
925
- llm = this.bind({
924
+ llm = this.withConfig({
926
925
  tools,
927
926
  });
928
927
  const raiseIfNoToolCalls = (message) => {
@@ -934,7 +933,7 @@ export class ChatAnthropicMessages extends BaseChatModel {
934
933
  llm = llm.pipe(raiseIfNoToolCalls);
935
934
  }
936
935
  else {
937
- llm = this.bind({
936
+ llm = this.withConfig({
938
937
  tools,
939
938
  tool_choice: {
940
939
  type: "tool",
@@ -270,7 +270,7 @@ class ChatAnthropicTools extends chat_models_1.BaseChatModel {
270
270
  keyName: functionName,
271
271
  });
272
272
  }
273
- const llm = this.bind({
273
+ const llm = this.withConfig({
274
274
  tools,
275
275
  tool_choice: force
276
276
  ? {
@@ -267,7 +267,7 @@ export class ChatAnthropicTools extends BaseChatModel {
267
267
  keyName: functionName,
268
268
  });
269
269
  }
270
- const llm = this.bind({
270
+ const llm = this.withConfig({
271
271
  tools,
272
272
  tool_choice: force
273
273
  ? {
@@ -74,7 +74,10 @@ function _ensureMessageContents(messages) {
74
74
  content: [
75
75
  {
76
76
  type: "tool_result",
77
- content: _formatContent(message.content),
77
+ // rare case: message.content could be undefined
78
+ ...(message.content != null
79
+ ? { content: _formatContent(message.content) }
80
+ : {}),
78
81
  tool_use_id: message.tool_call_id,
79
82
  },
80
83
  ],
@@ -71,7 +71,10 @@ function _ensureMessageContents(messages) {
71
71
  content: [
72
72
  {
73
73
  type: "tool_result",
74
- content: _formatContent(message.content),
74
+ // rare case: message.content could be undefined
75
+ ...(message.content != null
76
+ ? { content: _formatContent(message.content) }
77
+ : {}),
75
78
  tool_use_id: message.tool_call_id,
76
79
  },
77
80
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {