_cleanup_llm_representation() — langchain Function Reference
Architecture documentation for the _cleanup_llm_representation() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9793f2f3_1136_1a61_b521_e03eff201daf["_cleanup_llm_representation()"] 20f4116a_d26d_2a5f_4a10_67af6940e081["chat_models.py"] 9793f2f3_1136_1a61_b521_e03eff201daf -->|defined in| 20f4116a_d26d_2a5f_4a10_67af6940e081 4fc37aed_deb5_e40b_e6f9_e9ec4aba8bf4["_get_llm_string()"] 4fc37aed_deb5_e40b_e6f9_e9ec4aba8bf4 -->|calls| 9793f2f3_1136_1a61_b521_e03eff201daf style 9793f2f3_1136_1a61_b521_e03eff201daf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/language_models/chat_models.py lines 1784–1806
def _cleanup_llm_representation(serialized: Any, depth: int) -> None:
"""Remove non-serializable objects from a serialized object."""
if depth > _MAX_CLEANUP_DEPTH: # Don't cooperate for pathological cases
return
if not isinstance(serialized, dict):
return
if (
"type" in serialized
and serialized["type"] == "not_implemented"
and "repr" in serialized
):
del serialized["repr"]
if "graph" in serialized:
del serialized["graph"]
if "kwargs" in serialized:
kwargs = serialized["kwargs"]
for value in kwargs.values():
_cleanup_llm_representation(value, depth + 1)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _cleanup_llm_representation() do?
_cleanup_llm_representation() is a function in the langchain codebase, defined in libs/core/langchain_core/language_models/chat_models.py.
Where is _cleanup_llm_representation() defined?
_cleanup_llm_representation() is defined in libs/core/langchain_core/language_models/chat_models.py at line 1784.
What calls _cleanup_llm_representation()?
_cleanup_llm_representation() is called by 1 function(s): _get_llm_string.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free