Home / Function/ _needs_escaping() — langchain Function Reference

_needs_escaping() — langchain Function Reference

Architecture documentation for the _needs_escaping() function in _validation.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a6efc3e4_8615_15fb_8826_e87e03fb01b4["_needs_escaping()"]
  1b9f9aae_21a8_0928_76d1_c2f1609b2193["_validation.py"]
  a6efc3e4_8615_15fb_8826_e87e03fb01b4 -->|defined in| 1b9f9aae_21a8_0928_76d1_c2f1609b2193
  12e29989_c05d_0426_3212_cc4e68daaa88["_serialize_value()"]
  12e29989_c05d_0426_3212_cc4e68daaa88 -->|calls| a6efc3e4_8615_15fb_8826_e87e03fb01b4
  style a6efc3e4_8615_15fb_8826_e87e03fb01b4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/load/_validation.py lines 36–44

def _needs_escaping(obj: dict[str, Any]) -> bool:
    """Check if a dict needs escaping to prevent confusion with LC objects.

    A dict needs escaping if:

    1. It has an `'lc'` key (could be confused with LC serialization format)
    2. It has only the escape key (would be mistaken for an escaped dict)
    """
    return "lc" in obj or (len(obj) == 1 and _LC_ESCAPED_KEY in obj)

Subdomains

Called By

Frequently Asked Questions

What does _needs_escaping() do?
_needs_escaping() is a function in the langchain codebase, defined in libs/core/langchain_core/load/_validation.py.
Where is _needs_escaping() defined?
_needs_escaping() is defined in libs/core/langchain_core/load/_validation.py at line 36.
What calls _needs_escaping()?
_needs_escaping() is called by 1 function(s): _serialize_value.

Analyze Your Own Codebase

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

Try Supermodel Free