@langchain/anthropic 0.3.14 → 0.3.16
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
CHANGED
|
@@ -915,13 +915,34 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
|
|
|
915
915
|
keyName: functionName,
|
|
916
916
|
});
|
|
917
917
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
918
|
+
let llm;
|
|
919
|
+
if (this.thinking?.type === "enabled") {
|
|
920
|
+
const thinkingAdmonition = "Anthropic structured output relies on forced tool calling, " +
|
|
921
|
+
"which is not supported when `thinking` is enabled. This method will raise " +
|
|
922
|
+
"OutputParserException if tool calls are not " +
|
|
923
|
+
"generated. Consider disabling `thinking` or adjust your prompt to ensure " +
|
|
924
|
+
"the tool is called.";
|
|
925
|
+
console.warn(thinkingAdmonition);
|
|
926
|
+
llm = this.bind({
|
|
927
|
+
tools,
|
|
928
|
+
});
|
|
929
|
+
const raiseIfNoToolCalls = (message) => {
|
|
930
|
+
if (!message.tool_calls || message.tool_calls.length === 0) {
|
|
931
|
+
throw new Error(thinkingAdmonition);
|
|
932
|
+
}
|
|
933
|
+
return message;
|
|
934
|
+
};
|
|
935
|
+
llm = llm.pipe(raiseIfNoToolCalls);
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
llm = this.bind({
|
|
939
|
+
tools,
|
|
940
|
+
tool_choice: {
|
|
941
|
+
type: "tool",
|
|
942
|
+
name: functionName,
|
|
943
|
+
},
|
|
944
|
+
});
|
|
945
|
+
}
|
|
925
946
|
if (!includeRaw) {
|
|
926
947
|
return llm.pipe(outputParser).withConfig({
|
|
927
948
|
runName: "ChatAnthropicStructuredOutput",
|
package/dist/chat_models.js
CHANGED
|
@@ -912,13 +912,34 @@ export class ChatAnthropicMessages extends BaseChatModel {
|
|
|
912
912
|
keyName: functionName,
|
|
913
913
|
});
|
|
914
914
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
915
|
+
let llm;
|
|
916
|
+
if (this.thinking?.type === "enabled") {
|
|
917
|
+
const thinkingAdmonition = "Anthropic structured output relies on forced tool calling, " +
|
|
918
|
+
"which is not supported when `thinking` is enabled. This method will raise " +
|
|
919
|
+
"OutputParserException if tool calls are not " +
|
|
920
|
+
"generated. Consider disabling `thinking` or adjust your prompt to ensure " +
|
|
921
|
+
"the tool is called.";
|
|
922
|
+
console.warn(thinkingAdmonition);
|
|
923
|
+
llm = this.bind({
|
|
924
|
+
tools,
|
|
925
|
+
});
|
|
926
|
+
const raiseIfNoToolCalls = (message) => {
|
|
927
|
+
if (!message.tool_calls || message.tool_calls.length === 0) {
|
|
928
|
+
throw new Error(thinkingAdmonition);
|
|
929
|
+
}
|
|
930
|
+
return message;
|
|
931
|
+
};
|
|
932
|
+
llm = llm.pipe(raiseIfNoToolCalls);
|
|
933
|
+
}
|
|
934
|
+
else {
|
|
935
|
+
llm = this.bind({
|
|
936
|
+
tools,
|
|
937
|
+
tool_choice: {
|
|
938
|
+
type: "tool",
|
|
939
|
+
name: functionName,
|
|
940
|
+
},
|
|
941
|
+
});
|
|
942
|
+
}
|
|
922
943
|
if (!includeRaw) {
|
|
923
944
|
return llm.pipe(outputParser).withConfig({
|
|
924
945
|
runName: "ChatAnthropicStructuredOutput",
|