test_count_tokens_approximately_with_unknown_block_type() — langchain Function Reference
Architecture documentation for the test_count_tokens_approximately_with_unknown_block_type() function in test_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f3c1b89c_f11a_dbad_1fbf_57e27f09ef2b["test_count_tokens_approximately_with_unknown_block_type()"] 03f6a5ae_d57a_eb66_626a_b9e082b763ea["test_utils.py"] f3c1b89c_f11a_dbad_1fbf_57e27f09ef2b -->|defined in| 03f6a5ae_d57a_eb66_626a_b9e082b763ea style f3c1b89c_f11a_dbad_1fbf_57e27f09ef2b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/messages/test_utils.py lines 2848–2863
def test_count_tokens_approximately_with_unknown_block_type() -> None:
"""Test that unknown multimodal block types still contribute to token count."""
text_only = count_tokens_approximately([HumanMessage(content="hello")])
message_with_unknown_block = HumanMessage(
content=[
{"type": "text", "text": "hello"},
{"type": "foo", "bar": "baz"}, # unknown type, falls back to repr(block)
]
)
mixed = count_tokens_approximately([message_with_unknown_block])
# The message with an extra unknown block should be counted as more expensive
# than the text-only version.
assert mixed > text_only
Domain
Subdomains
Source
Frequently Asked Questions
What does test_count_tokens_approximately_with_unknown_block_type() do?
test_count_tokens_approximately_with_unknown_block_type() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/messages/test_utils.py.
Where is test_count_tokens_approximately_with_unknown_block_type() defined?
test_count_tokens_approximately_with_unknown_block_type() is defined in libs/core/tests/unit_tests/messages/test_utils.py at line 2848.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free