@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.
- package/dist/chat_models.cjs +4 -5
- package/dist/chat_models.d.ts +1 -2
- package/dist/chat_models.js +4 -5
- package/dist/experimental/tool_calling.cjs +1 -1
- package/dist/experimental/tool_calling.js +1 -1
- package/dist/utils/message_inputs.cjs +4 -1
- package/dist/utils/message_inputs.js +4 -1
- package/package.json +1 -1
package/dist/chat_models.cjs
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
939
|
+
llm = this.withConfig({
|
|
941
940
|
tools,
|
|
942
941
|
tool_choice: {
|
|
943
942
|
type: "tool",
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -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.
|
|
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
|
package/dist/chat_models.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
936
|
+
llm = this.withConfig({
|
|
938
937
|
tools,
|
|
939
938
|
tool_choice: {
|
|
940
939
|
type: "tool",
|
|
@@ -74,7 +74,10 @@ function _ensureMessageContents(messages) {
|
|
|
74
74
|
content: [
|
|
75
75
|
{
|
|
76
76
|
type: "tool_result",
|
|
77
|
-
|
|
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
|
-
|
|
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
|
],
|