@langchain/anthropic 0.3.30 → 0.3.32

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.
@@ -615,8 +615,9 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
615
615
  this.modelName = fields?.model ?? fields?.modelName ?? this.model;
616
616
  this.model = this.modelName;
617
617
  this.invocationKwargs = fields?.invocationKwargs ?? {};
618
- // Default to `undefined` for `topP` for Opus 4.1 and Sonnet 4.5 models
619
- if (this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5")) {
618
+ if (this.model.includes("opus-4-1") ||
619
+ this.model.includes("sonnet-4-5") ||
620
+ this.model.includes("haiku-4-5")) {
620
621
  this.topP = fields?.topP === null ? undefined : fields?.topP;
621
622
  }
622
623
  else {
@@ -635,6 +636,8 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
635
636
  this.streaming = fields?.streaming ?? false;
636
637
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
637
638
  this.thinking = fields?.thinking ?? this.thinking;
639
+ this.contextManagement =
640
+ fields?.contextManagement ?? this.contextManagement;
638
641
  this.createClient =
639
642
  fields?.createClient ??
640
643
  ((options) => new sdk_1.Anthropic(options));
@@ -702,7 +705,9 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
702
705
  if (this.topK !== -1) {
703
706
  throw new Error("topK is not supported when thinking is enabled");
704
707
  }
705
- if (this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5")
708
+ if (this.model.includes("opus-4-1") ||
709
+ this.model.includes("sonnet-4-5") ||
710
+ this.model.includes("haiku-4-5")
706
711
  ? this.topP !== undefined
707
712
  : this.topP !== -1) {
708
713
  throw new Error("topP is not supported when thinking is enabled");
@@ -52,8 +52,6 @@ export interface AnthropicInput {
52
52
  *
53
53
  * To not set this field, pass `null`. If `undefined` is passed,
54
54
  * the default (-1) will be used.
55
- *
56
- * For Opus 4.1 and Sonnet 4.5, this defaults to `null`.
57
55
  */
58
56
  topP?: number | null;
59
57
  /** A maximum number of tokens to generate before stopping. */
@@ -612,8 +612,9 @@ export class ChatAnthropicMessages extends BaseChatModel {
612
612
  this.modelName = fields?.model ?? fields?.modelName ?? this.model;
613
613
  this.model = this.modelName;
614
614
  this.invocationKwargs = fields?.invocationKwargs ?? {};
615
- // Default to `undefined` for `topP` for Opus 4.1 and Sonnet 4.5 models
616
- if (this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5")) {
615
+ if (this.model.includes("opus-4-1") ||
616
+ this.model.includes("sonnet-4-5") ||
617
+ this.model.includes("haiku-4-5")) {
617
618
  this.topP = fields?.topP === null ? undefined : fields?.topP;
618
619
  }
619
620
  else {
@@ -632,6 +633,8 @@ export class ChatAnthropicMessages extends BaseChatModel {
632
633
  this.streaming = fields?.streaming ?? false;
633
634
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
634
635
  this.thinking = fields?.thinking ?? this.thinking;
636
+ this.contextManagement =
637
+ fields?.contextManagement ?? this.contextManagement;
635
638
  this.createClient =
636
639
  fields?.createClient ??
637
640
  ((options) => new Anthropic(options));
@@ -699,7 +702,9 @@ export class ChatAnthropicMessages extends BaseChatModel {
699
702
  if (this.topK !== -1) {
700
703
  throw new Error("topK is not supported when thinking is enabled");
701
704
  }
702
- if (this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5")
705
+ if (this.model.includes("opus-4-1") ||
706
+ this.model.includes("sonnet-4-5") ||
707
+ this.model.includes("haiku-4-5")
703
708
  ? this.topP !== undefined
704
709
  : this.topP !== -1) {
705
710
  throw new Error("topP is not supported when thinking is enabled");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.3.30",
3
+ "version": "0.3.32",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {