core: xml output parser tags docstring (#28745)

This commit is contained in:
Erick Friis 2024-12-16 10:25:16 -08:00 committed by GitHub
parent ebab2ea81b
commit 1c120e9615
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -142,6 +142,20 @@ class XMLOutputParser(BaseTransformOutputParser):
"""Parse an output using xml format."""
tags: Optional[list[str]] = None
"""Tags to tell the LLM to expect in the XML output.
Note this may not be perfect depending on the LLM implementation.
For example, with tags=["foo", "bar", "baz"]:
1. A well-formatted XML instance:
"<foo>\n <bar>\n <baz></baz>\n </bar>\n</foo>"
2. A badly-formatted XML instance (missing closing tag for 'bar'):
"<foo>\n <bar>\n </foo>"
3. A badly-formatted XML instance (unexpected 'tag' element):
"<foo>\n <tag>\n </tag>\n</foo>"
"""
encoding_matcher: re.Pattern = re.compile(
r"<([^>]*encoding[^>]*)>\n(.*)", re.MULTILINE | re.DOTALL
)