Skip to content

The agent engineering platform.

anthropic[patch]: allow pop by field name (#16544)

Bagatur5c2538b9f7fb
diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py
index d30d2fd134..91cc511248 100644
--- a/libs/partners/anthropic/langchain_anthropic/chat_models.py
+++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py
@@ -88,6 +88,11 @@ class ChatAnthropicMessages(BaseChatModel):
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
+ class Config:
+ """Configuration for this pydantic object."""
+
+ allow_population_by_field_name = True
+
@property
def _llm_type(self) -> str:
"""Return type of chat model."""
diff --git a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py
index 4ad9b7c7b0..ebcf0386ae 100644
--- a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py
+++ b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py
@@ -7,3 +7,4 @@ from langchain_anthropic.chat_models import ChatAnthropicMessages
def test_initialization() -> None:
"""Test chat model initialization."""
ChatAnthropicMessages(model_name="claude-instant-1.2", anthropic_api_key="xyz")
+ ChatAnthropicMessages(model="claude-instant-1.2", anthropic_api_key="xyz")