test_get_num_tokens_from_messages_passes_kwargs() — langchain Function Reference
Architecture documentation for the test_get_num_tokens_from_messages_passes_kwargs() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD db9da962_d31c_6716_2463_40c8e4e69924["test_get_num_tokens_from_messages_passes_kwargs()"] 18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"] db9da962_d31c_6716_2463_40c8e4e69924 -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311 style db9da962_d31c_6716_2463_40c8e4e69924 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 1363–1384
def test_get_num_tokens_from_messages_passes_kwargs() -> None:
"""Test that get_num_tokens_from_messages passes kwargs to the model."""
llm = ChatAnthropic(model=MODEL_NAME)
with patch.object(anthropic, "Client") as _client:
llm.get_num_tokens_from_messages([HumanMessage("foo")], foo="bar")
assert _client.return_value.messages.count_tokens.call_args.kwargs["foo"] == "bar"
llm = ChatAnthropic(
model=MODEL_NAME,
betas=["context-management-2025-06-27"],
context_management={"edits": [{"type": "clear_tool_uses_20250919"}]},
)
with patch.object(anthropic, "Client") as _client:
llm.get_num_tokens_from_messages([HumanMessage("foo")])
call_args = _client.return_value.beta.messages.count_tokens.call_args.kwargs
assert call_args["betas"] == ["context-management-2025-06-27"]
assert call_args["context_management"] == {
"edits": [{"type": "clear_tool_uses_20250919"}]
}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_get_num_tokens_from_messages_passes_kwargs() do?
test_get_num_tokens_from_messages_passes_kwargs() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_get_num_tokens_from_messages_passes_kwargs() defined?
test_get_num_tokens_from_messages_passes_kwargs() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 1363.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free