fix: update response_metadata to use correct model attribute

This commit is contained in:
Mason Daugherty 2025-07-16 11:03:32 -04:00
parent d28db771d4
commit 8b40258e72
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -837,8 +837,8 @@ class ChatModelUnitTests(ChatModelTests):
assert model is not None
def test_model_param_name(self) -> None:
"""Tests model initialization with a ``model=`` parameter. This should pass for all
integrations.
"""Tests model initialization with a ``model=`` parameter. This should pass for
all integrations.
.. dropdown:: Troubleshooting
@ -851,7 +851,7 @@ class ChatModelUnitTests(ChatModelTests):
``model_config`` class attribute to your model class:
.. code-block:: python
class MyChatModel(BaseChatModel):
model: str = Field(alias="model_name")
model_config = ConfigDict(populate_by_name=True)
@ -873,7 +873,7 @@ class ChatModelUnitTests(ChatModelTests):
model = self.chat_model_class(**params)
assert model is not None
assert model.model == params["model"]
assert model.model == params["model"] # type: ignore[attr-defined]
def test_init_from_env(self) -> None:
"""Test initialization from environment variables. Relies on the

View File

@ -81,7 +81,7 @@ class ChatParrotLink(BaseChatModel):
additional_kwargs={}, # Used to add additional payload to the message
response_metadata={ # Use for response metadata
"time_in_seconds": 3,
"model_name": self.model_name,
"model_name": self.model,
},
usage_metadata={
"input_tokens": ct_input_tokens,
@ -146,7 +146,7 @@ class ChatParrotLink(BaseChatModel):
chunk = ChatGenerationChunk(
message=AIMessageChunk(
content="",
response_metadata={"time_in_sec": 3, "model_name": self.model_name},
response_metadata={"time_in_sec": 3, "model_name": self.model},
)
)
if run_manager: