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

allow `ChatAnthropicMessages(model=...)`
This commit is contained in:
Bagatur 2024-01-24 14:48:31 -08:00 committed by GitHub
parent a91181fe6d
commit 5c2538b9f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -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."""

View File

@ -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")