__init__() — langchain Function Reference
Architecture documentation for the __init__() function in xml.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 50deded1_918c_1dd3_112f_623225519701["__init__()"] 7c8ef0f6_8408_1c9b_5ed7_f17f7f527cbc["_StreamingParser"] 50deded1_918c_1dd3_112f_623225519701 -->|defined in| 7c8ef0f6_8408_1c9b_5ed7_f17f7f527cbc style 50deded1_918c_1dd3_112f_623225519701 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/output_parsers/xml.py lines 49–78
def __init__(self, parser: Literal["defusedxml", "xml"]) -> None:
"""Initialize the streaming parser.
Args:
parser: Parser to use for XML parsing.
Can be either `'defusedxml'` or `'xml'`. See documentation in
`XMLOutputParser` for more information.
Raises:
ImportError: If `defusedxml` is not installed and the `defusedxml` parser is
requested.
"""
if parser == "defusedxml":
if not _HAS_DEFUSEDXML:
msg = (
"defusedxml is not installed. "
"Please install it to use the defusedxml parser."
"You can install it with `pip install defusedxml` "
)
raise ImportError(msg)
parser_ = XMLParser(target=TreeBuilder())
else:
parser_ = None
self.pull_parser = ET.XMLPullParser(["start", "end"], _parser=parser_)
self.xml_start_re = re.compile(r"<[a-zA-Z:_]")
self.current_path: list[str] = []
self.current_path_has_children = False
self.buffer = ""
self.xml_started = False
Domain
Subdomains
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/core/langchain_core/output_parsers/xml.py.
Where is __init__() defined?
__init__() is defined in libs/core/langchain_core/output_parsers/xml.py at line 49.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free