test_count_tokens_approximately_text_only_backward_compatible() — langchain Function Reference
Architecture documentation for the test_count_tokens_approximately_text_only_backward_compatible() function in test_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 64296862_d983_a9b4_e4da_1a350243cddf["test_count_tokens_approximately_text_only_backward_compatible()"] ea3f8d89_f44b_6738_3cb9_a740a73cfca4["test_utils.py"] 64296862_d983_a9b4_e4da_1a350243cddf -->|defined in| ea3f8d89_f44b_6738_3cb9_a740a73cfca4 style 64296862_d983_a9b4_e4da_1a350243cddf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/messages/test_utils.py lines 2799–2810
def test_count_tokens_approximately_text_only_backward_compatible() -> None:
"""Test that text-only messages still work correctly."""
messages = [
HumanMessage(content="Hello world"),
AIMessage(content="Hi there!"),
]
token_count = count_tokens_approximately(messages)
# Should be ~15 tokens
# (11 chars + 9 chars + roles + 2*3 extra)
assert 13 <= token_count <= 17
Domain
Subdomains
Source
Frequently Asked Questions
What does test_count_tokens_approximately_text_only_backward_compatible() do?
test_count_tokens_approximately_text_only_backward_compatible() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/messages/test_utils.py.
Where is test_count_tokens_approximately_text_only_backward_compatible() defined?
test_count_tokens_approximately_text_only_backward_compatible() is defined in libs/core/tests/unit_tests/messages/test_utils.py at line 2799.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free