_escape() — langchain Function Reference
Architecture documentation for the _escape() function in xml.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2edd0b5c_4b75_78ea_9267_b9495c190f7c["_escape()"] b9bf24e2_44fd_b9c4_1e4a_a936f78c742f["xml.py"] 2edd0b5c_4b75_78ea_9267_b9495c190f7c -->|defined in| b9bf24e2_44fd_b9c4_1e4a_a936f78c742f a9d38aeb_60f2_0964_b563_c704ccade390["format_xml()"] a9d38aeb_60f2_0964_b563_c704ccade390 -->|calls| 2edd0b5c_4b75_78ea_9267_b9495c190f7c style 2edd0b5c_4b75_78ea_9267_b9495c190f7c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/format_scratchpad/xml.py lines 6–18
def _escape(xml: str) -> str:
"""Replace XML tags with custom safe delimiters."""
replacements = {
"<tool>": "[[tool]]",
"</tool>": "[[/tool]]",
"<tool_input>": "[[tool_input]]",
"</tool_input>": "[[/tool_input]]",
"<observation>": "[[observation]]",
"</observation>": "[[/observation]]",
}
for orig, repl in replacements.items():
xml = xml.replace(orig, repl)
return xml
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _escape() do?
_escape() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/format_scratchpad/xml.py.
Where is _escape() defined?
_escape() is defined in libs/langchain/langchain_classic/agents/format_scratchpad/xml.py at line 6.
What calls _escape()?
_escape() is called by 1 function(s): format_xml.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free