From 11ac96c5da7b9c98e9ff4c9428f26f4ceddc449a Mon Sep 17 00:00:00 2001 From: keenborder786 <21110290@lums.edu.pk> Date: Fri, 11 Jul 2025 05:38:59 +0500 Subject: [PATCH] [fix]: Only Updating max_tokens if models is provided --- libs/partners/anthropic/langchain_anthropic/chat_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index b7f77aedbc3..92330a03ac0 100644 --- a/libs/partners/anthropic/langchain_anthropic/chat_models.py +++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py @@ -1304,7 +1304,7 @@ class ChatAnthropic(BaseChatModel): @classmethod def validate_max_tokens(cls, values: dict[str, Any]) -> Any: """Validate max_tokens.""" - if values.get("max_tokens") is None: + if values.get("max_tokens") is None and values.get("model"): if "claude-opus-4" in values.get("model"): values["max_tokens"] = 32000 elif values.get("model") in ["claude-sonnet-4", "claude-3-7-sonnet"]: