Home / Function/ _unescape_value() — langchain Function Reference

_unescape_value() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8acb1ed0_c0aa_b272_da61_35cb5f1a16c7["_unescape_value()"]
  1b9f9aae_21a8_0928_76d1_c2f1609b2193["_validation.py"]
  8acb1ed0_c0aa_b272_da61_35cb5f1a16c7 -->|defined in| 1b9f9aae_21a8_0928_76d1_c2f1609b2193
  ccadebff_a96e_1077_de96_0bfe137925b9["_is_escaped_dict()"]
  8acb1ed0_c0aa_b272_da61_35cb5f1a16c7 -->|calls| ccadebff_a96e_1077_de96_0bfe137925b9
  style 8acb1ed0_c0aa_b272_da61_35cb5f1a16c7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/load/_validation.py lines 148–174

def _unescape_value(obj: Any) -> Any:
    """Unescape a value, processing escape markers in dict values and lists.

    When an escaped dict is encountered (`{"__lc_escaped__": ...}`), it's
    unwrapped and the contents are returned AS-IS (no further processing).
    The contents represent user data that should not be modified.

    For regular dicts and lists, we recurse to find any nested escape markers.

    Args:
        obj: The value to unescape.

    Returns:
        The unescaped value.
    """
    if isinstance(obj, dict):
        if _is_escaped_dict(obj):
            # Unwrap and return the user data as-is (no further unescaping).
            # The contents are user data that may contain more escape keys,
            # but those are part of the user's actual data.
            return obj[_LC_ESCAPED_KEY]

        # Regular dict - recurse into values to find nested escape markers
        return {k: _unescape_value(v) for k, v in obj.items()}
    if isinstance(obj, list):
        return [_unescape_value(item) for item in obj]
    return obj

Subdomains

Frequently Asked Questions

What does _unescape_value() do?
_unescape_value() is a function in the langchain codebase, defined in libs/core/langchain_core/load/_validation.py.
Where is _unescape_value() defined?
_unescape_value() is defined in libs/core/langchain_core/load/_validation.py at line 148.
What does _unescape_value() call?
_unescape_value() calls 1 function(s): _is_escaped_dict.

Analyze Your Own Codebase

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

Try Supermodel Free