mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-08 04:25:46 +00:00
core: xml output parser tags docstring (#28745)
This commit is contained in:
parent
ebab2ea81b
commit
1c120e9615
@ -142,6 +142,20 @@ class XMLOutputParser(BaseTransformOutputParser):
|
|||||||
"""Parse an output using xml format."""
|
"""Parse an output using xml format."""
|
||||||
|
|
||||||
tags: Optional[list[str]] = None
|
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(
|
encoding_matcher: re.Pattern = re.compile(
|
||||||
r"<([^>]*encoding[^>]*)>\n(.*)", re.MULTILINE | re.DOTALL
|
r"<([^>]*encoding[^>]*)>\n(.*)", re.MULTILINE | re.DOTALL
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user