@langchain/anthropic 0.3.26 → 0.3.28

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.
@@ -695,7 +695,9 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
695
695
  if (this.topK !== -1) {
696
696
  throw new Error("topK is not supported when thinking is enabled");
697
697
  }
698
- if (this.topP !== -1) {
698
+ if (this.model.includes("opus-4-1")
699
+ ? this.topP !== undefined
700
+ : this.topP !== -1) {
699
701
  throw new Error("topP is not supported when thinking is enabled");
700
702
  }
701
703
  if (this.temperature !== 1) {
@@ -692,7 +692,9 @@ export class ChatAnthropicMessages extends BaseChatModel {
692
692
  if (this.topK !== -1) {
693
693
  throw new Error("topK is not supported when thinking is enabled");
694
694
  }
695
- if (this.topP !== -1) {
695
+ if (this.model.includes("opus-4-1")
696
+ ? this.topP !== undefined
697
+ : this.topP !== -1) {
696
698
  throw new Error("topP is not supported when thinking is enabled");
697
699
  }
698
700
  if (this.temperature !== 1) {
@@ -141,7 +141,6 @@ const standardContentBlockConverter = {
141
141
  source: {
142
142
  type: "url",
143
143
  url: block.url,
144
- media_type: block.mime_type ?? "",
145
144
  },
146
145
  ...("cache_control" in (block.metadata ?? {})
147
146
  ? { cache_control: block.metadata.cache_control }
@@ -137,7 +137,6 @@ const standardContentBlockConverter = {
137
137
  source: {
138
138
  type: "url",
139
139
  url: block.url,
140
- media_type: block.mime_type ?? "",
141
140
  },
142
141
  ...("cache_control" in (block.metadata ?? {})
143
142
  ? { cache_control: block.metadata.cache_control }
@@ -15,6 +15,11 @@ function handleToolChoice(toolChoice) {
15
15
  type: "auto",
16
16
  };
17
17
  }
18
+ else if (toolChoice === "none") {
19
+ return {
20
+ type: "none",
21
+ };
22
+ }
18
23
  else if (typeof toolChoice === "string") {
19
24
  return {
20
25
  type: "tool",
@@ -1,3 +1,3 @@
1
1
  import type { Anthropic } from "@anthropic-ai/sdk";
2
2
  import { AnthropicToolChoice } from "../types.js";
3
- export declare function handleToolChoice(toolChoice?: AnthropicToolChoice): Anthropic.Messages.ToolChoiceAuto | Anthropic.Messages.ToolChoiceAny | Anthropic.Messages.ToolChoiceTool | undefined;
3
+ export declare function handleToolChoice(toolChoice?: AnthropicToolChoice): Anthropic.Messages.ToolChoiceAuto | Anthropic.Messages.ToolChoiceAny | Anthropic.Messages.ToolChoiceTool | Anthropic.Messages.ToolChoiceNone | undefined;
@@ -12,6 +12,11 @@ export function handleToolChoice(toolChoice) {
12
12
  type: "auto",
13
13
  };
14
14
  }
15
+ else if (toolChoice === "none") {
16
+ return {
17
+ type: "none",
18
+ };
19
+ }
15
20
  else if (typeof toolChoice === "string") {
16
21
  return {
17
22
  type: "tool",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.3.26",
3
+ "version": "0.3.28",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {