_truncate() — langchain Function Reference
Architecture documentation for the _truncate() function in utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 80987f62_c6a0_4904_aacc_d630b164fa6a["_truncate()"] 0b528c80_0ce7_1c74_8932_bc433bcb03c6["utils.py"] 80987f62_c6a0_4904_aacc_d630b164fa6a -->|defined in| 0b528c80_0ce7_1c74_8932_bc433bcb03c6 8c272a75_04d0_f5f2_a5cd_cd4a21d4dfdd["_format_content_block_xml()"] 8c272a75_04d0_f5f2_a5cd_cd4a21d4dfdd -->|calls| 80987f62_c6a0_4904_aacc_d630b164fa6a style 80987f62_c6a0_4904_aacc_d630b164fa6a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/messages/utils.py lines 135–139
def _truncate(text: str, max_len: int = _XML_CONTENT_BLOCK_MAX_LEN) -> str:
"""Truncate text to `max_len` characters, adding ellipsis if truncated."""
if len(text) <= max_len:
return text
return text[:max_len] + "..."
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _truncate() do?
_truncate() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/utils.py.
Where is _truncate() defined?
_truncate() is defined in libs/core/langchain_core/messages/utils.py at line 135.
What calls _truncate()?
_truncate() is called by 1 function(s): _format_content_block_xml.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free