Home / Function/ _count_content() — langchain Function Reference

_count_content() — langchain Function Reference

Architecture documentation for the _count_content() function in test_context_editing.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  95aa2f5d_9849_f57c_96a7_2f6ada598848["_count_content()"]
  95bc2c91_0832_8fb7_f8e0_c4d613e022d3["test_context_editing.py"]
  95aa2f5d_9849_f57c_96a7_2f6ada598848 -->|defined in| 95bc2c91_0832_8fb7_f8e0_c4d613e022d3
  eb6f62e5_f9cc_0bfa_50cc_1d041797cf64["_count_message_tokens()"]
  eb6f62e5_f9cc_0bfa_50cc_1d041797cf64 -->|calls| 95aa2f5d_9849_f57c_96a7_2f6ada598848
  style 95aa2f5d_9849_f57c_96a7_2f6ada598848 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_context_editing.py lines 53–60

def _count_content(content: MessageLikeRepresentation) -> int:
    if isinstance(content, str):
        return len(content)
    if isinstance(content, list):
        return sum(_count_content(block) for block in content)
    if isinstance(content, dict):
        return len(str(content))
    return len(str(content))

Domain

Subdomains

Frequently Asked Questions

What does _count_content() do?
_count_content() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_context_editing.py.
Where is _count_content() defined?
_count_content() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_context_editing.py at line 53.
What calls _count_content()?
_count_content() is called by 1 function(s): _count_message_tokens.

Analyze Your Own Codebase

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

Try Supermodel Free