diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index d30d2fd1342..91cc511248a 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 4ad9b7c7b0c..ebcf0386aee 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")