Skip to content

Commit 6d71b6b

Browse files
authored
standard-tests: refactoring and fixes (#31703)
- `libs/core/langchain_core/messages/base.py`: add model name to examples [per docs](https://python.langchain.com/api_reference/standard_tests/integration_tests/langchain_tests.integration_tests.chat_models.ChatModelIntegrationTests.html#langchain_tests.integration_tests.chat_models.ChatModelIntegrationTests.test_usage_metadata) ("0.3.17: Additionally check for the presence of model_name in the response metadata, which is needed for usage tracking in callback handlers") - `libs/core/langchain_core/utils/function_calling.py`: correct typo - `libs/standard-tests/langchain_tests/integration_tests/chat_models.py`: - `magic_function(input)` -> `magic_function(_input)` to prevent warning about redefining built in `input` - relocate a few tests for better grouping and narrative flow - suppress some type hint warnings following suit from similar tests - fix a few more typos - validate not only that `model_name` is defined, but that it is not empty (test_usage_metadata)
1 parent b6f74bf commit 6d71b6b

File tree

3 files changed

+631
-611
lines changed

3 files changed

+631
-611
lines changed

libs/core/langchain_core/messages/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class BaseMessage(Serializable):
3434
"""
3535

3636
response_metadata: dict = Field(default_factory=dict)
37-
"""Response metadata. For example: response headers, logprobs, token counts."""
37+
"""Response metadata. For example: response headers, logprobs, token counts, model
38+
name."""
3839

3940
type: str
4041
"""The type of the message. Must be a string that is unique to the message type.

libs/core/langchain_core/utils/function_calling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def tool_example_to_messages(
634634
1) HumanMessage: contains the content from which content should be extracted.
635635
2) AIMessage: contains the extracted information from the model
636636
3) ToolMessage: contains confirmation to the model that the model requested a tool
637-
correctly.
637+
correctly.
638638
639639
If `ai_response` is specified, there will be a final AIMessage with that response.
640640
@@ -668,7 +668,7 @@ class Person(BaseModel):
668668
..., description="The color of the person's hair if known"
669669
)
670670
height_in_meters: Optional[str] = Field(
671-
..., description="Height in METERs"
671+
..., description="Height in METERS"
672672
)
673673
674674
examples = [

0 commit comments

Comments
 (0)