Home / Function/ _unescape() — langchain Function Reference

_unescape() — langchain Function Reference

Architecture documentation for the _unescape() function in xml.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8c6c137c_588e_dafe_5b25_5b37a9f960ad["_unescape()"]
  f2ea7756_ae03_24f7_4d97_422e78f632d9["xml.py"]
  8c6c137c_588e_dafe_5b25_5b37a9f960ad -->|defined in| f2ea7756_ae03_24f7_4d97_422e78f632d9
  e386861e_a7a7_9278_87ae_0d850022a200["parse()"]
  e386861e_a7a7_9278_87ae_0d850022a200 -->|calls| 8c6c137c_588e_dafe_5b25_5b37a9f960ad
  style 8c6c137c_588e_dafe_5b25_5b37a9f960ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/output_parsers/xml.py lines 11–23

def _unescape(text: str) -> str:
    """Convert custom tag delimiters back into XML tags."""
    replacements = {
        "[[tool]]": "<tool>",
        "[[/tool]]": "</tool>",
        "[[tool_input]]": "<tool_input>",
        "[[/tool_input]]": "</tool_input>",
        "[[observation]]": "<observation>",
        "[[/observation]]": "</observation>",
    }
    for repl, orig in replacements.items():
        text = text.replace(repl, orig)
    return text

Subdomains

Called By

Frequently Asked Questions

What does _unescape() do?
_unescape() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/output_parsers/xml.py.
Where is _unescape() defined?
_unescape() is defined in libs/langchain/langchain_classic/agents/output_parsers/xml.py at line 11.
What calls _unescape()?
_unescape() is called by 1 function(s): parse.

Analyze Your Own Codebase

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

Try Supermodel Free