Home / Function/ test_count_tokens_approximately_with_image_only_message() — langchain Function Reference

test_count_tokens_approximately_with_image_only_message() — langchain Function Reference

Architecture documentation for the test_count_tokens_approximately_with_image_only_message() function in test_utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b499da84_dc05_c3f9_0156_2604daa621cc["test_count_tokens_approximately_with_image_only_message()"]
  03f6a5ae_d57a_eb66_626a_b9e082b763ea["test_utils.py"]
  b499da84_dc05_c3f9_0156_2604daa621cc -->|defined in| 03f6a5ae_d57a_eb66_626a_b9e082b763ea
  style b499da84_dc05_c3f9_0156_2604daa621cc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/messages/test_utils.py lines 2829–2845

def test_count_tokens_approximately_with_image_only_message() -> None:
    """Test token counting for a message that only contains an image."""
    message = HumanMessage(
        content=[
            {
                "type": "image_url",
                "image_url": {"url": "data:image/jpeg;base64,AAA"},
            }
        ]
    )

    token_count = count_tokens_approximately([message])

    # Should be roughly tokens_per_image + role + extra per message.
    # Default tokens_per_image is 85 and extra_tokens_per_message is 3,
    # so we expect something in the ~90-110 range.
    assert 80 < token_count < 120

Domain

Subdomains

Frequently Asked Questions

What does test_count_tokens_approximately_with_image_only_message() do?
test_count_tokens_approximately_with_image_only_message() 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_image_only_message() defined?
test_count_tokens_approximately_with_image_only_message() is defined in libs/core/tests/unit_tests/messages/test_utils.py at line 2829.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free